photoprism: github.com/photoprism/photoprism/internal/form Index | Files

package form

import "github.com/photoprism/photoprism/internal/form"

Package form contains tagged structs for input value validation.

Copyright (c) 2018 - 2020 Michael Mayer <hello@photoprism.org>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

PhotoPrism™ is a registered trademark of Michael Mayer.  You may use it as required
to describe our software, run your own server, for educational purposes, but not for
offering commercial goods, products, or services without prior written permission.
In other words, please ask.

Feel free to send an e-mail to hello@photoprism.org if you have questions, want to support our work, or just want to say hello.

Additional information can be found in our Developer Guide: https://docs.photoprism.org/developer-guide/

Index

Package Files

account.go account_search.go account_share.go album.go album_search.go change_password.go folder.go folder_search.go form.go geo_search.go import_options.go index_options.go label.go label_search.go link.go login.go photo.go photo_search.go search.go selection.go serialize.go

func ParseQueryString Uses

func ParseQueryString(f SearchForm) (result error)

func Serialize Uses

func Serialize(f interface{}, all bool) string

Serialize returns a string containing all non-empty fields and values of a struct.

func Unserialize Uses

func Unserialize(f SearchForm, q string) (result error)

type Account Uses

type Account struct {
    AccName       string `json:"AccName"`
    AccOwner      string `json:"AccOwner"`
    AccURL        string `json:"AccURL"`
    AccType       string `json:"AccType"`
    AccKey        string `json:"AccKey"`
    AccUser       string `json:"AccUser"`
    AccPass       string `json:"AccPass"`
    AccError      string `json:"AccError"`
    AccShare      bool   `json:"AccShare"`
    AccSync       bool   `json:"AccSync"`
    RetryLimit    int    `json:"RetryLimit"`
    SharePath     string `json:"SharePath"`
    ShareSize     string `json:"ShareSize"`
    ShareExpires  int    `json:"ShareExpires"`
    SyncPath      string `json:"SyncPath"`
    SyncInterval  int    `json:"SyncInterval"`
    SyncUpload    bool   `json:"SyncUpload"`
    SyncDownload  bool   `json:"SyncDownload"`
    SyncFilenames bool   `json:"SyncFilenames"`
    SyncRaw       bool   `json:"SyncRaw"`
}

Account represents a remote service account form for uploading, downloading or syncing media files.

func NewAccount Uses

func NewAccount(m interface{}) (f Account, err error)

func (*Account) ServiceDiscovery Uses

func (f *Account) ServiceDiscovery() error

type AccountSearch Uses

type AccountSearch struct {
    Query  string `form:"q"`
    Share  bool   `form:"share"`
    Sync   bool   `form:"sync"`
    Status string `form:"status"`
    Count  int    `form:"count" binding:"required" serialize:"-"`
    Offset int    `form:"offset" serialize:"-"`
    Order  string `form:"order" serialize:"-"`
}

AccountSearch represents search form fields for "/api/v1/accounts".

func NewAccountSearch Uses

func NewAccountSearch(query string) AccountSearch

func (*AccountSearch) GetQuery Uses

func (f *AccountSearch) GetQuery() string

func (*AccountSearch) ParseQueryString Uses

func (f *AccountSearch) ParseQueryString() error

func (*AccountSearch) SetQuery Uses

func (f *AccountSearch) SetQuery(q string)

type AccountShare Uses

type AccountShare struct {
    Photos      []string `json:"photos"`
    Destination string   `json:"destination"`
}

type Album Uses

type Album struct {
    CoverUID         string `json:"CoverUID"`
    FolderUID        string `json:"FolderUID"`
    AlbumType        string `json:"Type"`
    AlbumTitle       string `json:"Title"`
    AlbumLocation    string `json:"Location"`
    AlbumCategory    string `json:"Category"`
    AlbumCaption     string `json:"Caption"`
    AlbumDescription string `json:"Description"`
    AlbumNotes       string `json:"Notes"`
    AlbumFilter      string `json:"Filter"`
    AlbumOrder       string `json:"Order"`
    AlbumTemplate    string `json:"Template"`
    AlbumCountry     string `json:"Country"`
    AlbumYear        int    `json:"Year"`
    AlbumMonth       int    `json:"Month"`
    AlbumFavorite    bool   `json:"Favorite"`
    AlbumPrivate     bool   `json:"Private"`
}

Album represents an album edit form.

func NewAlbum Uses

func NewAlbum(m interface{}) (f Album, err error)

type AlbumSearch Uses

type AlbumSearch struct {
    Query    string `form:"q"`
    ID       string `form:"id"`
    Type     string `form:"type"`
    Location string `form:"location"`
    Category string `form:"category"`
    Slug     string `form:"slug"`
    Title    string `form:"title"`
    Country  string `json:"country"`
    Year     int    `json:"year"`
    Month    int    `json:"month"`
    Day      int    `json:"day"`
    Favorite bool   `form:"favorite"`
    Private  bool   `form:"private"`
    Count    int    `form:"count" binding:"required" serialize:"-"`
    Offset   int    `form:"offset" serialize:"-"`
    Order    string `form:"order" serialize:"-"`
}

AlbumSearch represents search form fields for "/api/v1/albums".

func NewAlbumSearch Uses

func NewAlbumSearch(query string) AlbumSearch

func (*AlbumSearch) GetQuery Uses

func (f *AlbumSearch) GetQuery() string

func (*AlbumSearch) ParseQueryString Uses

func (f *AlbumSearch) ParseQueryString() error

func (*AlbumSearch) SetQuery Uses

func (f *AlbumSearch) SetQuery(q string)

type ChangePassword Uses

type ChangePassword struct {
    OldPassword string `json:"old"`
    NewPassword string `json:"new"`
}

ChangePassword represents a password update form.

type Details Uses

type Details struct {
    PhotoID   uint   `json:"PhotoID" deepcopier:"skip"`
    Keywords  string `json:"Keywords"`
    Notes     string `json:"Notes"`
    Subject   string `json:"Subject"`
    Artist    string `json:"Artist"`
    Copyright string `json:"Copyright"`
    License   string `json:"License"`
}

type Folder Uses

type Folder struct {
    Path              string `json:"Path"`
    Root              string `json:"Root"`
    FolderType        string `json:"Type"`
    FolderTitle       string `json:"Title"`
    FolderCategory    string `json:"Category"`
    FolderDescription string `json:"Description"`
    FolderOrder       string `json:"Order"`
    FolderCountry     string `json:"Country"`
    FolderYear        int    `json:"Year"`
    FolderMonth       int    `json:"Month"`
    FolderFavorite    bool   `json:"Favorite"`
    FolderPrivate     bool   `json:"Private"`
    FolderIgnore      bool   `json:"Ignore"`
    FolderWatch       bool   `json:"Watch"`
}

Folder represents a file system directory edit form.

func NewFolder Uses

func NewFolder(m interface{}) (f Folder, err error)

type FolderSearch Uses

type FolderSearch struct {
    Query     string `form:"q"`
    Recursive bool   `form:"recursive"`
    Files     bool   `form:"files"`
    Uncached  bool   `form:"uncached"`
    Count     int    `form:"count" serialize:"-"`
    Offset    int    `form:"offset" serialize:"-"`
}

FolderSearch represents search form fields for "/api/v1/folders".

func (*FolderSearch) GetQuery Uses

func (f *FolderSearch) GetQuery() string

func (*FolderSearch) ParseQueryString Uses

func (f *FolderSearch) ParseQueryString() error

func (*FolderSearch) Serialize Uses

func (f *FolderSearch) Serialize() string

Serialize returns a string containing non-empty fields and values of a struct.

func (*FolderSearch) SerializeAll Uses

func (f *FolderSearch) SerializeAll() string

SerializeAll returns a string containing all non-empty fields and values of a struct.

func (*FolderSearch) SetQuery Uses

func (f *FolderSearch) SetQuery(q string)

type GeoSearch Uses

type GeoSearch struct {
    Query    string    `form:"q"`
    Type     string    `form:"type"`
    Path     string    `form:"path"`
    Folder   string    `form:"folder"` // Alias for Path
    Name     string    `form:"name"`
    Before   time.Time `form:"before" time_format:"2006-01-02"`
    After    time.Time `form:"after" time_format:"2006-01-02"`
    Favorite bool      `form:"favorite"`
    Video    bool      `form:"video"`
    Photo    bool      `form:"photo"`
    Archived bool      `form:"archived"`
    Public   bool      `form:"public"`
    Private  bool      `form:"private"`
    Review   bool      `form:"review"`
    Quality  int       `form:"quality"`
    Lat      float32   `form:"lat"`
    Lng      float32   `form:"lng"`
    S2       string    `form:"s2"`
    Olc      string    `form:"olc"`
    Dist     uint      `form:"dist"`
    Album    string    `form:"album"`
    Country  string    `form:"country"`
    Year     int       `form:"year"`
    Month    int       `form:"month"`
    Color    string    `form:"color"`
    Camera   int       `form:"camera"`
    Lens     int       `form:"lens"`
}

GeoSearch represents search form fields for "/api/v1/geo".

func NewGeoSearch Uses

func NewGeoSearch(query string) GeoSearch

func (*GeoSearch) GetQuery Uses

func (f *GeoSearch) GetQuery() string

GetQuery returns the query parameter as string.

func (*GeoSearch) ParseQueryString Uses

func (f *GeoSearch) ParseQueryString() error

ParseQueryString parses the query parameter if possible.

func (*GeoSearch) Serialize Uses

func (f *GeoSearch) Serialize() string

Serialize returns a string containing non-empty fields and values of a struct.

func (*GeoSearch) SerializeAll Uses

func (f *GeoSearch) SerializeAll() string

SerializeAll returns a string containing all non-empty fields and values of a struct.

func (*GeoSearch) SetQuery Uses

func (f *GeoSearch) SetQuery(q string)

SetQuery sets the query parameter.

type ImportOptions Uses

type ImportOptions struct {
    Albums []string `json:"albums"`
    Path   string   `json:"path"`
    Move   bool     `json:"move"`
}

type IndexOptions Uses

type IndexOptions struct {
    Path    string `json:"path"`
    Convert bool   `json:"convert"`
    Rescan  bool   `json:"rescan"`
}

type Label Uses

type Label struct {
    LabelName     string `json:"Name"`
    Uncertainty   int    `json:"Uncertainty"`
    LabelPriority int    `json:"Priority"`
}

Label represents a label edit form.

type LabelSearch Uses

type LabelSearch struct {
    Query    string `form:"q"`
    ID       string `form:"id"`
    Slug     string `form:"slug"`
    Name     string `form:"name"`
    All      bool   `form:"all"`
    Favorite bool   `form:"favorite"`
    Count    int    `form:"count" binding:"required" serialize:"-"`
    Offset   int    `form:"offset" serialize:"-"`
    Order    string `form:"order" serialize:"-"`
}

PhotoSearch represents search form fields for "/api/v1/labels".

func NewLabelSearch Uses

func NewLabelSearch(query string) LabelSearch

func (*LabelSearch) GetQuery Uses

func (f *LabelSearch) GetQuery() string

func (*LabelSearch) ParseQueryString Uses

func (f *LabelSearch) ParseQueryString() error

func (*LabelSearch) SetQuery Uses

func (f *LabelSearch) SetQuery(q string)
type Link struct {
    Password    string `json:"Password"`
    ShareSlug   string `json:"Slug"`
    LinkToken   string `json:"Token"`
    LinkExpires int    `json:"Expires"`
    MaxViews    uint   `json:"MaxViews"`
    CanComment  bool   `json:"CanComment"`
    CanEdit     bool   `json:"CanEdit"`
}

Link represents a link sharing form.

type Login Uses

type Login struct {
    Email    string `json:"email"`
    UserName string `json:"username"`
    Password string `json:"password"`
    Token    string `json:"token"`
}

func (Login) HasCredentials Uses

func (f Login) HasCredentials() bool

func (Login) HasPassword Uses

func (f Login) HasPassword() bool

func (Login) HasToken Uses

func (f Login) HasToken() bool

func (Login) HasUserName Uses

func (f Login) HasUserName() bool

type Photo Uses

type Photo struct {
    PhotoType        string    `json:"Type"`
    TypeSrc          string    `json:"TypeSrc"`
    TakenAt          time.Time `json:"TakenAt"`
    TakenAtLocal     time.Time `json:"TakenAtLocal"`
    TakenSrc         string    `json:"TakenSrc"`
    TimeZone         string    `json:"TimeZone"`
    PhotoYear        int       `json:"Year"`
    PhotoMonth       int       `json:"Month"`
    PhotoDay         int       `json:"Day"`
    PhotoTitle       string    `json:"Title"`
    TitleSrc         string    `json:"TitleSrc"`
    PhotoDescription string    `json:"Description"`
    DescriptionSrc   string    `json:"DescriptionSrc"`
    Details          Details   `json:"Details"`
    PhotoFavorite    bool      `json:"Favorite"`
    PhotoPrivate     bool      `json:"Private"`
    PhotoReview      bool      `json:"Review"`
    PhotoScan        bool      `json:"Scan"`
    PhotoPanorama    bool      `json:"Panorama"`
    PhotoAltitude    int       `json:"Altitude"`
    PhotoLat         float32   `json:"Lat"`
    PhotoLng         float32   `json:"Lng"`
    PhotoIso         int       `json:"Iso"`
    PhotoFocalLength int       `json:"FocalLength"`
    PhotoFNumber     float32   `json:"FNumber"`
    PhotoExposure    string    `json:"Exposure"`
    PhotoCountry     string    `json:"Country"`
    CellID           string    `json:"CellID"`
    CellAccuracy     int       `json:"CellAccuracy"`
    PlaceID          string    `json:"PlaceID"`
    PlaceSrc         string    `json:"PlaceSrc"`
    CameraID         uint      `json:"CameraID"`
    CameraSrc        string    `json:"CameraSrc"`
    LensID           uint      `json:"LensID"`
    OriginalName     string    `json:"OriginalName"`
}

Photo represents a photo edit form.

func NewPhoto Uses

func NewPhoto(m interface{}) (f Photo, err error)

type PhotoSearch Uses

type PhotoSearch struct {
    Query    string    `form:"q"`
    Filter   string    `form:"filter"`
    ID       string    `form:"id"`
    Type     string    `form:"type"`
    Path     string    `form:"path"`
    Folder   string    `form:"folder"` // Alias for Path
    Name     string    `form:"name"`
    Original string    `form:"original"`
    Title    string    `form:"title"`
    Hash     string    `form:"hash"`
    Primary  bool      `form:"primary"`
    Video    bool      `form:"video"`
    Photo    bool      `form:"photo"`
    Scan     bool      `form:"scan"`
    Panorama bool      `form:"panorama"`
    Error    bool      `form:"error"`
    Hidden   bool      `form:"hidden"`
    Archived bool      `form:"archived"`
    Public   bool      `form:"public"`
    Private  bool      `form:"private"`
    Favorite bool      `form:"favorite"`
    Unsorted bool      `form:"unsorted"`
    Stack    bool      `form:"stack"`
    Lat      float32   `form:"lat"`
    Lng      float32   `form:"lng"`
    Dist     uint      `form:"dist"`
    Fmin     float32   `form:"fmin"`
    Fmax     float32   `form:"fmax"`
    Chroma   uint8     `form:"chroma"`
    Diff     uint32    `form:"diff"`
    Mono     bool      `form:"mono"`
    Portrait bool      `form:"portrait"`
    Geo      bool      `form:"geo"`
    Album    string    `form:"album"`
    Label    string    `form:"label"`
    Category string    `form:"category"` // Moments
    Country  string    `form:"country"`  // Moments
    State    string    `form:"state"`    // Moments
    Year     int       `form:"year"`     // Moments
    Month    int       `form:"month"`    // Moments
    Day      int       `form:"day"`      // Moments
    Color    string    `form:"color"`
    Quality  int       `form:"quality"`
    Review   bool      `form:"review"`
    Camera   int       `form:"camera"`
    Lens     int       `form:"lens"`
    Before   time.Time `form:"before" time_format:"2006-01-02"`
    After    time.Time `form:"after" time_format:"2006-01-02"`
    Count    int       `form:"count" binding:"required" serialize:"-"`
    Offset   int       `form:"offset" serialize:"-"`
    Order    string    `form:"order" serialize:"-"`
    Merged   bool      `form:"merged" serialize:"-"`
}

PhotoSearch represents search form fields for "/api/v1/photos".

func NewPhotoSearch Uses

func NewPhotoSearch(query string) PhotoSearch

func (*PhotoSearch) GetQuery Uses

func (f *PhotoSearch) GetQuery() string

func (*PhotoSearch) ParseQueryString Uses

func (f *PhotoSearch) ParseQueryString() error

func (*PhotoSearch) Serialize Uses

func (f *PhotoSearch) Serialize() string

Serialize returns a string containing non-empty fields and values of a struct.

func (*PhotoSearch) SerializeAll Uses

func (f *PhotoSearch) SerializeAll() string

SerializeAll returns a string containing all non-empty fields and values of a struct.

func (*PhotoSearch) SetQuery Uses

func (f *PhotoSearch) SetQuery(q string)

type SearchForm Uses

type SearchForm interface {
    GetQuery() string
    SetQuery(q string)
}

type Selection Uses

type Selection struct {
    Files  []string `json:"files"`
    Photos []string `json:"photos"`
    Albums []string `json:"albums"`
    Labels []string `json:"labels"`
    Places []string `json:"places"`
}

func (Selection) All Uses

func (f Selection) All() []string

func (Selection) Empty Uses

func (f Selection) Empty() bool

func (Selection) String Uses

func (f Selection) String() string

Package form imports 11 packages (graph) and is imported by 5 packages. Updated 2020-07-20. Refresh now. Tools for package owners.