config

package
v0.0.0-...-c8acfb9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0 Imports: 61 Imported by: 0

Documentation

Overview

Package config provides global options, command-line flags, and user settings.

Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under Version 3 of the GNU Affero General Public License (the "AGPL"):
<https://docs.photoprism.app/license/agpl>

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.

The AGPL is supplemented by our Trademark and Brand Guidelines,
which describe how our Brand Assets may be used:
<https://www.photoprism.app/trademark>

Feel free to send an email to hello@photoprism.app 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.app/developer-guide/>

Index

Constants

View Source
const (
	AuthModePublic = "public"
	AuthModePasswd = "password"
)
View Source
const (
	CacheKeyAppManifest  = "app-manifest"
	CacheKeyWallpaperUri = "wallpaper-uri"
)
View Source
const (
	Pro        = "pro"
	Plus       = "plus"
	Essentials = "essentials"
)

Product feature tags used to automatically generate documentation.

View Source
const (
	MySQL    = "mysql"
	MariaDB  = "mariadb"
	Postgres = "postgres"
	SQLite3  = "sqlite3"
)

SQL Databases. TODO: PostgresSQL support requires upgrading GORM, so generic column data types can be used.

View Source
const (
	SQLiteTestDB    = ".test.db"
	SQLiteMemoryDSN = ":memory:"
)

SQLite default DSNs.

View Source
const (
	HttpModeProd  = "release"
	HttpModeDebug = "debug"
)
View Source
const (
	PrivateKeyExt = ".key"
	PublicCertExt = ".crt"
)
View Source
const (
	EnvProd    = "prod"
	EnvUnsafe  = "unsafe"
	EnvDebug   = "debug"
	EnvTrace   = "trace"
	EnvDemo    = "demo"
	EnvSponsor = "sponsor"
	EnvTest    = "test"
)

Environment names.

View Source
const (
	TestDataZip  = "/tmp/photoprism/testdata.zip"
	TestDataURL  = "https://dl.photoprism.app/qa/testdata.zip"
	TestDataHash = "be394d5bee8a5634d415e9e0663eef20b5604510" // sha1sum
)

Download URL and ZIP hash for test files.

View Source
const ApiUri = "/api/v1"

ApiUri defines the standard path for handling REST requests.

View Source
const CustomStaticUri = "/c/static"

CustomStaticUri defines the standard path for serving custom static content.

View Source
const DefaultAutoImportDelay = int(3 * 60) // 3 Minutes
View Source
const DefaultAutoIndexDelay = int(5 * 60) // 5 Minutes

DefaultAutoIndexDelay and DefaultAutoImportDelay set the default safety delay duration before starting to index/import in the background.

View Source
const DefaultResolutionLimit = 150 // 150 Megapixels

DefaultResolutionLimit defines the default resolution limit.

View Source
const DefaultSessionCache = unix.Minute * 15

DefaultSessionCache defines the default session cache duration in seconds.

View Source
const DefaultSessionMaxAge = unix.Week * 2

DefaultSessionMaxAge defines the standard session expiration time in seconds.

View Source
const DefaultSessionTimeout = unix.Week

DefaultSessionTimeout defines the standard session idle time in seconds.

View Source
const DefaultWakeupIntervalSeconds = int(15 * 60) // 15 Minutes
View Source
const Gigabyte = Megabyte * 1000 // 1,000,000,000 Bytes

Gigabyte defines gigabyte in bytes.

View Source
const MaxWakeupInterval = time.Hour * 24 // 1 Day
View Source
const Megabyte = 1000 * 1000 // 1,000,000 Bytes

Megabyte defines a megabyte in bytes.

View Source
const MinMem = Gigabyte

MinMem defines the minimum amount of system memory required.

View Source
const MinWakeupInterval = time.Minute // 1 Minute

MinWakeupInterval and MaxWakeupInterval limit the interval duration in which the background worker can be invoked.

View Source
const RecommendedMem = 3 * Gigabyte // 3,000,000,000 Bytes

RecommendedMem defines the recommended amount of system memory.

View Source
const StaticUri = "/static"

StaticUri defines the standard path for serving static content.

Variables

View Source
var (
	SignUpURL  = "https://www.photoprism.app/membership"
	MsgSponsor = "Become a member today, support our mission and enjoy our member benefits! 💎"
	MsgSignUp  = "Visit " + SignUpURL + " to learn more."
	SignUp     = Map{"message": MsgSponsor, "url": SignUpURL}
)
View Source
var Cache = gc.New(time.Hour, 15*time.Minute)
View Source
var (
	ErrReadOnly = errors.New("not available in read-only mode")
)
View Source
var Flags = CliFlags{}/* 143 elements not displayed */

Flags configures the global command-line interface (CLI) parameters.

View Source
var LowMem = false
View Source
var PkgNameRegexp = regexp.MustCompile("[^a-zA-Z\\-_]+")
View Source
var TotalMem uint64

Functions

func ApplyCliContext

func ApplyCliContext(c interface{}, ctx *cli.Context) error

ApplyCliContext applies the values of the cli context based on the "flag" annotations.

func CliTestContext

func CliTestContext() *cli.Context

CliTestContext returns a CLI context for testing.

func Env

func Env(vars ...string) bool

Env checks the presence of environment and command-line flags.

func EnvVar

func EnvVar(flag string) string

EnvVar returns the name of the environment variable for the specified config flag.

func FlushCache

func FlushCache()

FlushCache clears the config cache.

func LogErr

func LogErr(err error)

func Register

func Register(name string, initConfig func(c *Config) error, clientConfig func(c *Config, t ClientType) Map)

Register registers a new package extension.

func SetNewTestConfig

func SetNewTestConfig()

Types

type CategoryLabel

type CategoryLabel struct {
	LabelUID   string `json:"UID"`
	CustomSlug string `json:"Slug"`
	LabelName  string `json:"Name"`
}

type CategoryLabels

type CategoryLabels []CategoryLabel

type CliFlag

type CliFlag struct {
	Flag cli.DocGenerationFlag
	Tags []string
}

CliFlag represents a command-line parameter.

func (CliFlag) CommandFlag

func (f CliFlag) CommandFlag() string

CommandFlag returns the full command flag based on the name.

func (CliFlag) Default

func (f CliFlag) Default() string

Default returns the default value.

func (CliFlag) EnvVar

func (f CliFlag) EnvVar() string

EnvVar returns the flag environment variable name.

func (CliFlag) Fields

func (f CliFlag) Fields() reflect.Value

Fields returns the flag struct fields.

func (CliFlag) Hidden

func (f CliFlag) Hidden() bool

Hidden checks if the flag is hidden.

func (CliFlag) Name

func (f CliFlag) Name() string

Name returns the command flag name.

func (CliFlag) Skip

func (f CliFlag) Skip(tags []string) bool

Skip checks if the parameter should be skipped based on a list of tags.

func (CliFlag) Usage

func (f CliFlag) Usage() string

Usage returns the command flag usage.

type CliFlags

type CliFlags []CliFlag

CliFlags represents a list of command-line parameters.

func (CliFlags) Cli

func (f CliFlags) Cli() (result []cli.Flag)

Cli returns the currently active command-line parameters.

func (CliFlags) Find

func (f CliFlags) Find(tags []string) (result []cli.Flag)

Find finds command-line parameters based on a list of tags.

func (CliFlags) Insert

func (f CliFlags) Insert(name string, insert []CliFlag) (result CliFlags)

Insert inserts command flags, if possible after name.

func (CliFlags) Prepend

func (f CliFlags) Prepend(el []CliFlag) (result CliFlags)

Prepend adds command flags at the beginning.

func (CliFlags) Remove

func (f CliFlags) Remove(names []string) (result CliFlags)

Remove removes command flags by name.

func (CliFlags) Replace

func (f CliFlags) Replace(name string, replacement CliFlag) CliFlags

Replace replaces an existing command flag by name and returns true if successful.

func (CliFlags) Report

func (f CliFlags) Report() (rows [][]string, cols []string)

Report returns global config values as a table for reporting.

type ClientAssets

type ClientAssets struct {
	BaseUri                   string `json:"-"`
	AppCss                    string `json:"app.css"`
	AppJs                     string `json:"app.js"`
	ShareCss                  string `json:"share.css"`
	ShareJs                   string `json:"share.js"`
	MaterialIconsRegularTtf   string `json:"MaterialIcons-Regular.ttf"`
	MaterialIconsRegularWoff  string `json:"MaterialIcons-Regular.woff"`
	MaterialIconsRegularEot   string `json:"MaterialIcons-Regular.eot"`
	MaterialIconsRegularWoff2 string `json:"MaterialIcons-Regular.woff2"`
	OfflineServiceworker      string `json:"__offline_serviceworker"`
	DefaultSkinSvg            string `json:"default-skin.svg"`
	PreloaderGif              string `json:"preloader.gif"`
	DefaultSkinPng            string `json:"default-skin.png"`
}

func NewClientAssets

func NewClientAssets(baseUri string) ClientAssets

NewClientAssets creates a new ClientAssets instance.

func (*ClientAssets) AppCssUri

func (a *ClientAssets) AppCssUri() string

AppCssUri returns the web app stylesheet URI.

func (*ClientAssets) AppJsUri

func (a *ClientAssets) AppJsUri() string

AppJsUri returns the web app javascript URI.

func (*ClientAssets) Load

func (a *ClientAssets) Load(fileName string) error

Load loads the frontend assets from a webpack manifest file.

func (*ClientAssets) ShareCssUri

func (a *ClientAssets) ShareCssUri() string

ShareCssUri returns the web sharing stylesheet URI.

func (*ClientAssets) ShareJsUri

func (a *ClientAssets) ShareJsUri() string

ShareJsUri returns the web sharing javascript URI.

type ClientConfig

type ClientConfig struct {
	Mode             string              `json:"mode"`
	Name             string              `json:"name"`
	About            string              `json:"about"`
	Edition          string              `json:"edition"`
	Version          string              `json:"version"`
	Copyright        string              `json:"copyright"`
	Flags            string              `json:"flags"`
	BaseUri          string              `json:"baseUri"`
	StaticUri        string              `json:"staticUri"`
	CssUri           string              `json:"cssUri"`
	JsUri            string              `json:"jsUri"`
	ManifestUri      string              `json:"manifestUri"`
	ApiUri           string              `json:"apiUri"`
	ContentUri       string              `json:"contentUri"`
	VideoUri         string              `json:"videoUri"`
	WallpaperUri     string              `json:"wallpaperUri"`
	SiteUrl          string              `json:"siteUrl"`
	SiteDomain       string              `json:"siteDomain"`
	SiteAuthor       string              `json:"siteAuthor"`
	SiteTitle        string              `json:"siteTitle"`
	SiteCaption      string              `json:"siteCaption"`
	SiteDescription  string              `json:"siteDescription"`
	SitePreview      string              `json:"sitePreview"`
	LegalInfo        string              `json:"legalInfo"`
	LegalUrl         string              `json:"legalUrl"`
	AppName          string              `json:"appName"`
	AppMode          string              `json:"appMode"`
	AppIcon          string              `json:"appIcon"`
	AppColor         string              `json:"appColor"`
	Restart          bool                `json:"restart"`
	Debug            bool                `json:"debug"`
	Trace            bool                `json:"trace"`
	Test             bool                `json:"test"`
	Demo             bool                `json:"demo"`
	Sponsor          bool                `json:"sponsor"`
	ReadOnly         bool                `json:"readonly"`
	UploadNSFW       bool                `json:"uploadNSFW"`
	Public           bool                `json:"public"`
	AuthMode         string              `json:"authMode"`
	UsersPath        string              `json:"usersPath"`
	LoginUri         string              `json:"loginUri"`
	RegisterUri      string              `json:"registerUri"`
	PasswordLength   int                 `json:"passwordLength"`
	PasswordResetUri string              `json:"passwordResetUri"`
	Experimental     bool                `json:"experimental"`
	AlbumCategories  []string            `json:"albumCategories"`
	Albums           entity.Albums       `json:"albums"`
	Cameras          entity.Cameras      `json:"cameras"`
	Lenses           entity.Lenses       `json:"lenses"`
	Countries        entity.Countries    `json:"countries"`
	People           entity.People       `json:"people"`
	Thumbs           ThumbSizes          `json:"thumbs"`
	Tier             int                 `json:"tier"`
	Membership       string              `json:"membership"`
	Customer         string              `json:"customer"`
	MapKey           string              `json:"mapKey"`
	DownloadToken    string              `json:"downloadToken,omitempty"`
	PreviewToken     string              `json:"previewToken,omitempty"`
	Disable          ClientDisable       `json:"disable"`
	Count            ClientCounts        `json:"count"`
	Pos              ClientPosition      `json:"pos"`
	Years            Years               `json:"years"`
	Colors           []map[string]string `json:"colors"`
	Categories       CategoryLabels      `json:"categories"`
	Clip             int                 `json:"clip"`
	Server           env.Resources       `json:"server"`
	Settings         *customize.Settings `json:"settings,omitempty"`
	ACL              acl.Grants          `json:"acl,omitempty"`
	Ext              Map                 `json:"ext"`
}

ClientConfig represents HTTP client / Web UI config options.

func (ClientConfig) ApplyACL

func (c ClientConfig) ApplyACL(a acl.ACL, r acl.Role) ClientConfig

ApplyACL updates the client config values based on the ACL and Role provided.

type ClientCounts

type ClientCounts struct {
	All            int `json:"all"`
	Photos         int `json:"photos"`
	Live           int `json:"live"`
	Videos         int `json:"videos"`
	Cameras        int `json:"cameras"`
	Lenses         int `json:"lenses"`
	Countries      int `json:"countries"`
	Hidden         int `json:"hidden"`
	Archived       int `json:"archived"`
	Favorites      int `json:"favorites"`
	Review         int `json:"review"`
	Stories        int `json:"stories"`
	Private        int `json:"private"`
	Albums         int `json:"albums"`
	PrivateAlbums  int `json:"private_albums"`
	Moments        int `json:"moments"`
	PrivateMoments int `json:"private_moments"`
	Months         int `json:"months"`
	PrivateMonths  int `json:"private_months"`
	States         int `json:"states"`
	PrivateStates  int `json:"private_states"`
	Folders        int `json:"folders"`
	PrivateFolders int `json:"private_folders"`
	Files          int `json:"files"`
	People         int `json:"people"`
	Places         int `json:"places"`
	Labels         int `json:"labels"`
	LabelMaxPhotos int `json:"labelMaxPhotos"`
}

ClientCounts represents photo, video and album counts for the client UI.

type ClientDisable

type ClientDisable struct {
	WebDAV         bool `json:"webdav"`
	Settings       bool `json:"settings"`
	Places         bool `json:"places"`
	Backups        bool `json:"backups"`
	TensorFlow     bool `json:"tensorflow"`
	Faces          bool `json:"faces"`
	Classification bool `json:"classification"`
	Sips           bool `json:"sips"`
	FFmpeg         bool `json:"ffmpeg"`
	ExifTool       bool `json:"exiftool"`
	Darktable      bool `json:"darktable"`
	RawTherapee    bool `json:"rawtherapee"`
	ImageMagick    bool `json:"imagemagick"`
	HeifConvert    bool `json:"heifconvert"`
	Vectors        bool `json:"vectors"`
	JpegXL         bool `json:"jpegxl"`
	Raw            bool `json:"raw"`
}

ClientDisable represents disabled client features a user cannot turn back on.

type ClientPosition

type ClientPosition struct {
	PhotoUID string    `json:"uid"`
	CellID   string    `json:"cid"`
	TakenAt  time.Time `json:"utc"`
	PhotoLat float64   `json:"lat"`
	PhotoLng float64   `json:"lng"`
}

type ClientType

type ClientType string
const (
	ClientPublic ClientType = "public"
	ClientShare  ClientType = "share"
	ClientUser   ClientType = "user"
)

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config holds database, cache and all parameters of photoprism

func NewConfig

func NewConfig(ctx *cli.Context) *Config

NewConfig initialises a new configuration file

func NewTestConfig

func NewTestConfig(pkg string) *Config

NewTestConfig returns a valid test config.

func NewTestErrorConfig

func NewTestErrorConfig() *Config

NewTestErrorConfig returns an invalid test config.

func TestConfig

func TestConfig() *Config

TestConfig returns the existing test config instance or creates a new instance and returns it.

func (*Config) About

func (c *Config) About() string

About returns the app about string.

func (*Config) AdminPassword

func (c *Config) AdminPassword() string

AdminPassword returns the initial admin password.

func (*Config) AdminUser

func (c *Config) AdminUser() string

AdminUser returns the admin auth name.

func (*Config) AlbumsPath

func (c *Config) AlbumsPath() string

AlbumsPath returns the storage path for album YAML files.

func (*Config) ApiUri

func (c *Config) ApiUri() string

ApiUri returns the api URI.

func (*Config) AppColor

func (c *Config) AppColor() string

AppColor returns the app splash screen color when installed on a device.

func (*Config) AppConfig

func (c *Config) AppConfig() pwa.Config

AppConfig returns the progressive web app config.

func (*Config) AppIcon

func (c *Config) AppIcon() string

AppIcon returns the app icon when installed on a device.

func (*Config) AppIconsPath

func (c *Config) AppIconsPath(name ...string) string

AppIconsPath returns the path to the app icons.

func (*Config) AppManifest

func (c *Config) AppManifest() *pwa.Manifest

AppManifest returns the progressive web app manifest.

func (*Config) AppMode

func (c *Config) AppMode() string

AppMode returns the app mode when installed on a device.

func (*Config) AppName

func (c *Config) AppName() string

AppName returns the app name when installed on a device.

func (*Config) AssetsPath

func (c *Config) AssetsPath() string

AssetsPath returns the path to static assets for models and templates.

func (*Config) Auth

func (c *Config) Auth() bool

Auth checks if authentication is required.

func (*Config) AuthMode

func (c *Config) AuthMode() string

AuthMode returns the authentication mode.

func (*Config) AutoImport

func (c *Config) AutoImport() time.Duration

AutoImport returns the auto import delay duration.

func (*Config) AutoIndex

func (c *Config) AutoIndex() time.Duration

AutoIndex returns the auto index delay duration.

func (*Config) BackupPath

func (c *Config) BackupPath() string

BackupPath returns the backup storage path.

func (*Config) BackupYaml

func (c *Config) BackupYaml() bool

BackupYaml checks if creating YAML files is enabled.

func (*Config) BaseUri

func (c *Config) BaseUri(res string) string

BaseUri returns the site base URI for a given resource.

func (*Config) BuildPath

func (c *Config) BuildPath() string

BuildPath returns the static build path.

func (*Config) CORSHeaders

func (c *Config) CORSHeaders() string

CORSHeaders returns the value for the Access-Control-Allow-Headers header, if any.

func (*Config) CORSMethods

func (c *Config) CORSMethods() string

CORSMethods returns the value for the Access-Control-Allow-Methods header, if any.

func (*Config) CORSOrigin

func (c *Config) CORSOrigin() string

CORSOrigin returns the value for the Access-Control-Allow-Origin header, if any.

func (*Config) CachePath

func (c *Config) CachePath() string

CachePath returns the path for cache files.

func (*Config) CaseInsensitive

func (c *Config) CaseInsensitive() (result bool, err error)

CaseInsensitive checks if the storage path is case-insensitive.

func (*Config) CdnDomain

func (c *Config) CdnDomain() string

CdnDomain returns the content delivery network domain name if specified.

func (*Config) CdnUrl

func (c *Config) CdnUrl(res string) string

CdnUrl returns the optional content delivery network URI without trailing slash.

func (*Config) CdnVideo

func (c *Config) CdnVideo() bool

CdnVideo checks if videos should be streamed using the configured CDN.

func (*Config) CertificatesPath

func (c *Config) CertificatesPath() string

CertificatesPath returns the path to the TLS certificates and keys.

func (*Config) CheckPassword

func (c *Config) CheckPassword(p string) bool

CheckPassword compares given password p with the admin password

func (*Config) CliContext

func (c *Config) CliContext() *cli.Context

CliContext returns the cli context if set.

func (*Config) CliGlobalString

func (c *Config) CliGlobalString(name string) string

CliGlobalString returns a global cli string flag value if set.

func (*Config) ClientAssets

func (c *Config) ClientAssets() ClientAssets

ClientAssets returns the frontend build assets.

func (*Config) ClientManifestUri

func (c *Config) ClientManifestUri() string

ClientManifestUri returns the frontend manifest.json URI.

func (*Config) ClientPublic

func (c *Config) ClientPublic() ClientConfig

ClientPublic returns config values for use by the JavaScript UI and other clients.

func (*Config) ClientRole

func (c *Config) ClientRole(role acl.Role) ClientConfig

ClientRole provides the client config values for the specified user role.

func (*Config) ClientSession

func (c *Config) ClientSession(sess *entity.Session) (cfg ClientConfig)

ClientSession provides the client config values for the specified session.

func (*Config) ClientShare

func (c *Config) ClientShare() ClientConfig

ClientShare returns reduced client config values for share link visitors.

func (*Config) ClientUser

func (c *Config) ClientUser(withSettings bool) ClientConfig

ClientUser returns complete client config values for users with full access.

func (*Config) CloseDb

func (c *Config) CloseDb() error

CloseDb closes the db connection (if any).

func (*Config) CmdCachePath

func (c *Config) CmdCachePath() string

CmdCachePath returns a path that external CLI tools can use as cache directory.

func (*Config) CmdLibPath

func (c *Config) CmdLibPath() string

CmdLibPath returns the dynamic loader path that external CLI tools should use.

func (*Config) ConfigPath

func (c *Config) ConfigPath() string

ConfigPath returns the config path.

func (*Config) ContentUri

func (c *Config) ContentUri() string

ContentUri returns the content delivery URI.

func (*Config) Copyright

func (c *Config) Copyright() string

Copyright returns the application copyright.

func (*Config) CreateDarktableCachePath

func (c *Config) CreateDarktableCachePath() (string, error)

CreateDarktableCachePath creates and returns the darktable cache directory.

func (*Config) CreateDarktableConfigPath

func (c *Config) CreateDarktableConfigPath() (string, error)

CreateDarktableConfigPath creates and returns the darktable config directory.

func (*Config) CreateDirectories

func (c *Config) CreateDirectories() error

CreateDirectories creates directories for storing photos, metadata and cache files.

func (*Config) CustomAssetsPath

func (c *Config) CustomAssetsPath() string

CustomAssetsPath returns the path to custom assets such as icons, models and translations.

func (*Config) CustomStaticAssetUri

func (c *Config) CustomStaticAssetUri(res string) string

CustomStaticAssetUri returns the resource URI of the custom static file asset.

func (*Config) CustomStaticFile

func (c *Config) CustomStaticFile(fileName string) string

CustomStaticFile returns the path to a custom static file.

func (*Config) CustomStaticPath

func (c *Config) CustomStaticPath() string

CustomStaticPath returns the custom static assets' path.

func (*Config) CustomStaticUri

func (c *Config) CustomStaticUri() string

CustomStaticUri returns the URI to a custom static resource.

func (*Config) CustomTemplatesPath

func (c *Config) CustomTemplatesPath() string

CustomTemplatesPath returns the path to custom templates.

func (*Config) DarktableBin

func (c *Config) DarktableBin() string

DarktableBin returns the darktable-cli executable file name.

func (*Config) DarktableBlacklist

func (c *Config) DarktableBlacklist() string

DarktableBlacklist returns the darktable file extension blacklist.

func (*Config) DarktableCachePath

func (c *Config) DarktableCachePath() string

DarktableCachePath returns the darktable cache directory.

func (*Config) DarktableConfigPath

func (c *Config) DarktableConfigPath() string

DarktableConfigPath returns the darktable config directory.

func (*Config) DarktableEnabled

func (c *Config) DarktableEnabled() bool

DarktableEnabled checks if Darktable is enabled for RAW conversion.

func (*Config) DatabaseConns

func (c *Config) DatabaseConns() int

DatabaseConns returns the maximum number of open connections to the database.

func (*Config) DatabaseConnsIdle

func (c *Config) DatabaseConnsIdle() int

DatabaseConnsIdle returns the maximum number of idle connections to the database (equal or less than open).

func (*Config) DatabaseDriver

func (c *Config) DatabaseDriver() string

DatabaseDriver returns the database driver name.

func (*Config) DatabaseDsn

func (c *Config) DatabaseDsn() string

DatabaseDsn returns the database data source name (DSN).

func (*Config) DatabaseFile

func (c *Config) DatabaseFile() string

DatabaseFile returns the filename part of a sqlite database DSN.

func (*Config) DatabaseHost

func (c *Config) DatabaseHost() string

DatabaseHost the database server host.

func (*Config) DatabaseName

func (c *Config) DatabaseName() string

DatabaseName the database schema name.

func (*Config) DatabasePassword

func (c *Config) DatabasePassword() string

DatabasePassword returns the database user password.

func (*Config) DatabasePort

func (c *Config) DatabasePort() int

DatabasePort the database server port.

func (*Config) DatabasePortString

func (c *Config) DatabasePortString() string

DatabasePortString the database server port as string.

func (*Config) DatabaseServer

func (c *Config) DatabaseServer() string

DatabaseServer the database server.

func (*Config) DatabaseTimeout

func (c *Config) DatabaseTimeout() int

DatabaseTimeout returns the TCP timeout in seconds for establishing a database connection: - https://github.com/photoprism/photoprism/issues/4059#issuecomment-1989119004 - https://github.com/go-sql-driver/mysql/blob/master/README.md#timeout

func (*Config) DatabaseUser

func (c *Config) DatabaseUser() string

DatabaseUser returns the database user name.

func (*Config) Db

func (c *Config) Db() *gorm.DB

Db returns the db connection.

func (*Config) Debug

func (c *Config) Debug() bool

Debug checks if debug mode is enabled, shows non-essential log messages.

func (*Config) DefaultLocale

func (c *Config) DefaultLocale() string

DefaultLocale returns the default user interface language locale name.

func (*Config) DefaultTLS

func (c *Config) DefaultTLS() bool

DefaultTLS checks if a self-signed certificate should be used to enable HTTPS if no other certificate is available.

func (*Config) DefaultTheme

func (c *Config) DefaultTheme() string

DefaultTheme returns the default user interface theme name.

func (*Config) DefaultsYaml

func (c *Config) DefaultsYaml() string

DefaultsYaml returns the default options YAML filename.

func (*Config) Demo

func (c *Config) Demo() bool

Demo checks if demo mode is enabled.

func (*Config) DetachServer

func (c *Config) DetachServer() bool

DetachServer checks if server should detach from console (daemon mode).

func (*Config) DetectNSFW

func (c *Config) DetectNSFW() bool

DetectNSFW checks if NSFW photos should be detected and flagged.

func (*Config) DisableBackups

func (c *Config) DisableBackups() bool

DisableBackups checks if photo and album metadata files should be disabled.

func (*Config) DisableClassification

func (c *Config) DisableClassification() bool

DisableClassification checks if image classification is disabled.

func (*Config) DisableDarktable

func (c *Config) DisableDarktable() bool

DisableDarktable checks if conversion of RAW images with Darktable is disabled.

func (*Config) DisableExifTool

func (c *Config) DisableExifTool() bool

DisableExifTool checks if ExifTool JSON files should not be created for improved metadata extraction.

func (*Config) DisableFFmpeg

func (c *Config) DisableFFmpeg() bool

DisableFFmpeg checks if FFmpeg is disabled for video transcoding.

func (*Config) DisableFaces

func (c *Config) DisableFaces() bool

DisableFaces checks if face recognition is disabled.

func (*Config) DisableHeifConvert

func (c *Config) DisableHeifConvert() bool

DisableHeifConvert checks if heif-convert is disabled for HEIF conversion.

func (*Config) DisableImageMagick

func (c *Config) DisableImageMagick() bool

DisableImageMagick checks if conversion of files with ImageMagick is disabled.

func (*Config) DisableJpegXL

func (c *Config) DisableJpegXL() bool

DisableJpegXL checks if JPEG XL file format support is disabled.

func (*Config) DisablePlaces

func (c *Config) DisablePlaces() bool

DisablePlaces checks if geocoding and maps should be disabled.

func (*Config) DisableRaw

func (c *Config) DisableRaw() bool

DisableRaw checks if indexing and conversion of RAW images is disabled.

func (*Config) DisableRawTherapee

func (c *Config) DisableRawTherapee() bool

DisableRawTherapee checks if conversion of RAW images with RawTherapee is disabled.

func (*Config) DisableRestart

func (c *Config) DisableRestart() bool

DisableRestart checks if users should not be allowed to restart the server from the user interface.

func (*Config) DisableRsvgConvert

func (c *Config) DisableRsvgConvert() bool

DisableRsvgConvert checks if rsvg-convert is disabled for SVG conversion.

func (*Config) DisableSettings

func (c *Config) DisableSettings() bool

DisableSettings checks if users should not be allowed to change settings.

func (*Config) DisableSips

func (c *Config) DisableSips() bool

DisableSips checks if conversion of RAW images with SIPS is disabled.

func (*Config) DisableTLS

func (c *Config) DisableTLS() bool

DisableTLS checks if HTTPS should be disabled even if the site URL starts with https:// and a certificate is available.

func (*Config) DisableTensorFlow

func (c *Config) DisableTensorFlow() bool

DisableTensorFlow checks if all features depending on TensorFlow should be disabled.

func (*Config) DisableVectors

func (c *Config) DisableVectors() bool

DisableVectors checks if vector graphics support is disabled.

func (*Config) DisableWebDAV

func (c *Config) DisableWebDAV() bool

DisableWebDAV checks if the built-in WebDAV server should be disabled.

func (*Config) DownloadTestData

func (c *Config) DownloadTestData() error

DownloadTestData downloads the test files from the file server.

func (*Config) DownloadToken

func (c *Config) DownloadToken() string

DownloadToken returns the DOWNLOAD api token (you can optionally use a static value for permanent caching).

func (*Config) Edition

func (c *Config) Edition() string

Edition returns the edition nane.

func (*Config) ExamplesPath

func (c *Config) ExamplesPath() string

ExamplesPath returns the example files path.

func (*Config) ExifBruteForce

func (c *Config) ExifBruteForce() bool

ExifBruteForce checks if a brute-force search should be performed when no Exif headers were found.

func (*Config) ExifToolBin

func (c *Config) ExifToolBin() string

ExifToolBin returns the exiftool executable file name.

func (*Config) ExifToolEnabled

func (c *Config) ExifToolEnabled() bool

ExifToolEnabled checks if the use of ExifTool is possible.

func (*Config) ExifToolJson

func (c *Config) ExifToolJson() bool

ExifToolJson checks if creating JSON metadata sidecar files with Exiftool is enabled.

func (*Config) Experimental

func (c *Config) Experimental() bool

Experimental checks if experimental features should be enabled.

func (*Config) FFmpegBin

func (c *Config) FFmpegBin() string

FFmpegBin returns the ffmpeg executable file name.

func (*Config) FFmpegBitrate

func (c *Config) FFmpegBitrate() int

FFmpegBitrate returns the ffmpeg bitrate limit in MBit/s.

func (*Config) FFmpegBitrateExceeded

func (c *Config) FFmpegBitrateExceeded(mbit float64) bool

FFmpegBitrateExceeded tests if the ffmpeg bitrate limit is exceeded.

func (*Config) FFmpegEnabled

func (c *Config) FFmpegEnabled() bool

FFmpegEnabled checks if FFmpeg is enabled for video transcoding.

func (*Config) FFmpegEncoder

func (c *Config) FFmpegEncoder() ffmpeg.AvcEncoder

FFmpegEncoder returns the FFmpeg AVC encoder name.

func (*Config) FFmpegMapAudio

func (c *Config) FFmpegMapAudio() string

FFmpegMapAudio returns the audio streams to be transcoded as string.

func (*Config) FFmpegMapVideo

func (c *Config) FFmpegMapVideo() string

FFmpegMapVideo returns the video streams to be transcoded as string.

func (*Config) FFmpegOptions

func (c *Config) FFmpegOptions(encoder ffmpeg.AvcEncoder, bitrate string) (ffmpeg.Options, error)

FFmpegOptions returns the FFmpeg transcoding options.

func (*Config) FFmpegSize

func (c *Config) FFmpegSize() int

FFmpegSize returns the maximum ffmpeg video encoding size in pixels (720-7680).

func (*Config) FaceClusterCore

func (c *Config) FaceClusterCore() int

FaceClusterCore returns the number of faces forming a cluster core.

func (*Config) FaceClusterDist

func (c *Config) FaceClusterDist() float64

FaceClusterDist returns the radius of faces forming a cluster core.

func (*Config) FaceClusterScore

func (c *Config) FaceClusterScore() int

FaceClusterScore returns the quality threshold for faces forming a cluster.

func (*Config) FaceClusterSize

func (c *Config) FaceClusterSize() int

FaceClusterSize returns the size threshold for faces forming a cluster in pixels.

func (*Config) FaceMatchDist

func (c *Config) FaceMatchDist() float64

FaceMatchDist returns the offset distance when matching faces with clusters.

func (*Config) FaceNetModelPath

func (c *Config) FaceNetModelPath() string

FaceNetModelPath returns the FaceNet model path.

func (*Config) FaceOverlap

func (c *Config) FaceOverlap() int

FaceOverlap returns the face area overlap threshold in percent.

func (*Config) FaceScore

func (c *Config) FaceScore() float64

FaceScore returns the face quality score threshold.

func (*Config) FaceSize

func (c *Config) FaceSize() int

FaceSize returns the face size threshold in pixels.

func (*Config) Flags

func (c *Config) Flags() (flags []string)

Flags returns config flags as string slice.

func (*Config) GeoApi

func (c *Config) GeoApi() string

GeoApi returns the preferred geocoding api (places, or none).

func (*Config) HeifConvertBin

func (c *Config) HeifConvertBin() string

HeifConvertBin returns the heif-convert executable file name.

func (*Config) HeifConvertEnabled

func (c *Config) HeifConvertEnabled() bool

HeifConvertEnabled checks if heif-convert is enabled for HEIF conversion.

func (*Config) HttpCacheMaxAge

func (c *Config) HttpCacheMaxAge() ttl.Duration

HttpCacheMaxAge returns the time in seconds until cached content expires.

func (*Config) HttpCachePublic

func (c *Config) HttpCachePublic() bool

HttpCachePublic checks whether static content may be cached by a CDN or caching proxy.

func (*Config) HttpCompression

func (c *Config) HttpCompression() string

HttpCompression returns the http compression method (gzip, or none).

func (*Config) HttpHost

func (c *Config) HttpHost() string

HttpHost returns the built-in HTTP server host name or IP address (empty for all interfaces).

func (*Config) HttpMode

func (c *Config) HttpMode() string

HttpMode returns the server mode.

func (*Config) HttpPort

func (c *Config) HttpPort() int

HttpPort returns the HTTP server port number.

func (*Config) HttpSocket

func (c *Config) HttpSocket() string

HttpSocket tries to parse the HttpHost as a Unix socket path and returns an empty string otherwise.

func (*Config) HttpVideoMaxAge

func (c *Config) HttpVideoMaxAge() ttl.Duration

HttpVideoMaxAge returns the time in seconds until cached videos expire.

func (*Config) HttpsProxy

func (c *Config) HttpsProxy() string

HttpsProxy returns the HTTPS proxy to use for outgoing connections.

func (*Config) HttpsProxyInsecure

func (c *Config) HttpsProxyInsecure() bool

HttpsProxyInsecure checks if invalid TLS certificates should be ignored when using the configured HTTPS proxy.

func (*Config) Hub

func (c *Config) Hub() *hub.Config

Hub returns the PhotoPrism hub config.

func (*Config) HubConfigFile

func (c *Config) HubConfigFile() string

HubConfigFile returns the backend api config file name.

func (*Config) ImageMagickBin

func (c *Config) ImageMagickBin() string

ImageMagickBin returns the ImageMagick "convert" executable file name.

func (*Config) ImageMagickBlacklist

func (c *Config) ImageMagickBlacklist() string

ImageMagickBlacklist returns the ImageMagick file extension blacklist.

func (*Config) ImageMagickEnabled

func (c *Config) ImageMagickEnabled() bool

ImageMagickEnabled checks if ImageMagick can be used for converting media files.

func (*Config) ImgPath

func (c *Config) ImgPath() string

ImgPath returns the path to static image files.

func (*Config) ImportDest

func (c *Config) ImportDest() string

ImportDest returns the relative originals path to which the files should be imported by default.

func (*Config) ImportPath

func (c *Config) ImportPath() string

ImportPath returns the import directory.

func (*Config) ImportSQL

func (c *Config) ImportSQL(filename string)

ImportSQL imports a file to the currently configured database.

func (*Config) Init

func (c *Config) Init() error

Init creates directories, parses additional config files, opens a database connection and initializes dependencies.

func (*Config) InitDb

func (c *Config) InitDb()

InitDb initializes the database without running previously failed migrations.

func (*Config) InitSerial

func (c *Config) InitSerial() (err error)

InitSerial initializes storage directories with a random serial.

func (*Config) InitTestDb

func (c *Config) InitTestDb()

InitTestDb drops all tables in the currently configured database and re-creates them.

func (*Config) InitializeTestData

func (c *Config) InitializeTestData() (err error)

InitializeTestData resets the test file directory.

func (*Config) InvalidDownloadToken

func (c *Config) InvalidDownloadToken(t string) bool

InvalidDownloadToken checks if the token is invalid.

func (*Config) InvalidPreviewToken

func (c *Config) InvalidPreviewToken(t string) bool

InvalidPreviewToken checks if the preview token is invalid.

func (*Config) JpegQuality

func (c *Config) JpegQuality() thumb.Quality

JpegQuality returns the jpeg image quality as thumb.Quality (25-100).

func (*Config) JpegSize

func (c *Config) JpegSize() int

JpegSize returns the size limit for automatically converted files in `PIXELS` (720-30000).

func (*Config) JpegXLDecoderBin

func (c *Config) JpegXLDecoderBin() string

JpegXLDecoderBin returns the JPEG XL decoder executable file name.

func (*Config) JpegXLEnabled

func (c *Config) JpegXLEnabled() bool

JpegXLEnabled checks if JPEG XL file format support is enabled.

func (*Config) LegalInfo

func (c *Config) LegalInfo() string

LegalInfo returns the legal info text for the page footer.

func (*Config) LegalUrl

func (c *Config) LegalUrl() string

LegalUrl returns the legal info url.

func (*Config) LocalesPath

func (c *Config) LocalesPath() string

LocalesPath returns the translation locales path.

func (*Config) LogFilename

func (c *Config) LogFilename() string

LogFilename returns the filename for storing server logs.

func (*Config) LogLevel

func (c *Config) LogLevel() logrus.Level

LogLevel returns the Logrus log level.

func (*Config) LoginUri

func (c *Config) LoginUri() string

LoginUri returns the user authentication page URI.

func (*Config) MariadbBin

func (c *Config) MariadbBin() string

MariadbBin returns the mariadb executable file name.

func (*Config) MariadbDumpBin

func (c *Config) MariadbDumpBin() string

MariadbDumpBin returns the mariadb-dump executable file name.

func (*Config) MediaCachePath

func (c *Config) MediaCachePath() string

MediaCachePath returns the main media cache path.

func (*Config) MediaFileCachePath

func (c *Config) MediaFileCachePath(hash string) string

MediaFileCachePath returns the cache subdirectory path for a given file hash.

func (*Config) MigrateDb

func (c *Config) MigrateDb(runFailed bool, ids []string)

MigrateDb initializes the database and migrates the schema if needed.

func (*Config) NSFWModelPath

func (c *Config) NSFWModelPath() string

NSFWModelPath returns the "not safe for work" TensorFlow model path.

func (*Config) Name

func (c *Config) Name() string

Name returns the app name.

func (*Config) NoCdn

func (c *Config) NoCdn() bool

NoCdn checks if there is no Content Deliver Network (CDN) configured to serve static content.

func (*Config) Options

func (c *Config) Options() *Options

Options returns the raw config options.

func (*Config) OptionsYaml

func (c *Config) OptionsYaml() string

OptionsYaml returns the config options YAML filename.

func (*Config) OriginalsAlbumsPath

func (c *Config) OriginalsAlbumsPath() string

OriginalsAlbumsPath returns the optional album YAML file path inside originals.

func (*Config) OriginalsByteLimit

func (c *Config) OriginalsByteLimit() int64

OriginalsByteLimit returns the maximum size of originals in bytes.

func (*Config) OriginalsDeletable

func (c *Config) OriginalsDeletable() bool

OriginalsDeletable checks if originals can be deleted.

func (*Config) OriginalsLimit

func (c *Config) OriginalsLimit() int

OriginalsLimit returns the maximum size of originals in MB.

func (*Config) OriginalsPath

func (c *Config) OriginalsPath() string

OriginalsPath returns the originals.

func (*Config) PIDFilename

func (c *Config) PIDFilename() string

PIDFilename returns the filename for storing the server process id (pid).

func (*Config) ParseDatabaseDsn

func (c *Config) ParseDatabaseDsn()

ParseDatabaseDsn parses the database dsn and extracts user, password, database server, and name.

func (*Config) PasswordLength

func (c *Config) PasswordLength() int

PasswordLength returns the minimum password length in characters.

func (*Config) PasswordResetUri

func (c *Config) PasswordResetUri() string

PasswordResetUri returns the password reset page URI, if any.

func (*Config) PngSize

func (c *Config) PngSize() int

PngSize returns the size limit for automatically converted files in `PIXELS` (720-30000).

func (*Config) PreviewToken

func (c *Config) PreviewToken() string

PreviewToken returns the preview image api token (based on the unique storage serial by default).

func (*Config) Prod

func (c *Config) Prod() bool

Prod checks if production mode is enabled, hides non-essential log messages.

func (*Config) Propagate

func (c *Config) Propagate()

Propagate updates config options in other packages as needed.

func (*Config) ProxyProtoHeader

func (c *Config) ProxyProtoHeader() []string

ProxyProtoHeader returns the proxy protocol header names.

func (*Config) ProxyProtoHeaders

func (c *Config) ProxyProtoHeaders() map[string]string

ProxyProtoHeaders returns a map with the proxy https protocol headers.

func (*Config) ProxyProtoHttps

func (c *Config) ProxyProtoHttps() []string

ProxyProtoHttps returns the proxy protocol header HTTPS values.

func (*Config) Public

func (c *Config) Public() bool

Public checks if app runs in public mode and requires no authentication.

func (*Config) PublicSettings

func (c *Config) PublicSettings() *customize.Settings

PublicSettings returns the public app settings.

func (*Config) RawEnabled

func (c *Config) RawEnabled() bool

RawEnabled checks if indexing and conversion of RAW images is enabled.

func (*Config) RawPresets

func (c *Config) RawPresets() bool

RawPresets checks if RAW converter presents should be used (may reduce performance).

func (*Config) RawTherapeeBin

func (c *Config) RawTherapeeBin() string

RawTherapeeBin returns the rawtherapee-cli executable file name.

func (*Config) RawTherapeeBlacklist

func (c *Config) RawTherapeeBlacklist() string

RawTherapeeBlacklist returns the RawTherapee file extension blacklist.

func (*Config) RawTherapeeEnabled

func (c *Config) RawTherapeeEnabled() bool

RawTherapeeEnabled checks if RawTherapee is enabled for RAW conversion.

func (*Config) ReadOnly

func (c *Config) ReadOnly() bool

ReadOnly checks if photo directories are write protected.

func (*Config) RegisterDb

func (c *Config) RegisterDb()

RegisterDb sets the database options and connection provider.

func (*Config) RegisterUri

func (c *Config) RegisterUri() string

RegisterUri returns the user registration page URI, if any.

func (*Config) RemoveTestData

func (c *Config) RemoveTestData() error

RemoveTestData deletes files in import, export, originals, and cache folders.

func (*Config) RenewApiKeys

func (c *Config) RenewApiKeys()

RenewApiKeys renews the api credentials for maps and places.

func (*Config) RenewApiKeysWithToken

func (c *Config) RenewApiKeysWithToken(token string) error

RenewApiKeysWithToken renews the api credentials for maps and places with an activation token.

func (*Config) Report

func (c *Config) Report() (rows [][]string, cols []string)

Report returns global config values as a table for reporting.

func (*Config) ResolutionLimit

func (c *Config) ResolutionLimit() int

ResolutionLimit returns the maximum resolution of originals in megapixels (width x height).

func (*Config) Restart

func (c *Config) Restart() bool

Restart checks if the application should be restarted, e.g. after an update or a config changes.

func (*Config) RsvgConvertBin

func (c *Config) RsvgConvertBin() string

RsvgConvertBin returns the rsvg-convert executable file name.

func (*Config) RsvgConvertEnabled

func (c *Config) RsvgConvertEnabled() bool

RsvgConvertEnabled checks if rsvg-convert is enabled for SVG conversion.

func (*Config) Serial

func (c *Config) Serial() string

Serial returns the random storage serial.

func (*Config) SerialChecksum

func (c *Config) SerialChecksum() string

SerialChecksum returns the CRC32 checksum of the storage serial.

func (*Config) SessionCache

func (c *Config) SessionCache() int64

SessionCache returns the default session cache duration in seconds.

func (*Config) SessionCacheDuration

func (c *Config) SessionCacheDuration() time.Duration

SessionCacheDuration returns the default session cache duration.

func (*Config) SessionMaxAge

func (c *Config) SessionMaxAge() int64

SessionMaxAge returns the standard session expiration time in seconds.

func (*Config) SessionSettings

func (c *Config) SessionSettings(sess *entity.Session) *customize.Settings

SessionSettings returns the app settings for the specified session.

func (*Config) SessionTimeout

func (c *Config) SessionTimeout() int64

SessionTimeout returns the standard session idle time in seconds.

func (*Config) SetAuthMode

func (c *Config) SetAuthMode(mode string)

SetAuthMode changes the authentication mode (for use in tests only).

func (*Config) SetDbOptions

func (c *Config) SetDbOptions()

SetDbOptions sets the database collation to unicode if supported.

func (*Config) SetLogLevel

func (c *Config) SetLogLevel(level logrus.Level)

SetLogLevel sets the Logrus log level.

func (*Config) SetWallpaperUri

func (c *Config) SetWallpaperUri(uri string) *Config

SetWallpaperUri changes the login screen background image URI.

func (*Config) Settings

func (c *Config) Settings() *customize.Settings

Settings returns the global app settings.

func (*Config) SettingsYaml

func (c *Config) SettingsYaml() string

SettingsYaml returns the settings YAML filename.

func (*Config) SettingsYamlDefaults

func (c *Config) SettingsYamlDefaults(settingsYml string) string

SettingsYamlDefaults returns the default settings YAML filename.

func (*Config) ShareSettings

func (c *Config) ShareSettings() *customize.Settings

ShareSettings returns the app settings for share link visitors.

func (*Config) Shutdown

func (c *Config) Shutdown()

Shutdown services and workers.

func (*Config) SidecarPath

func (c *Config) SidecarPath() string

SidecarPath returns the storage path for generated sidecar files (relative or absolute).

func (*Config) SidecarPathIsAbs

func (c *Config) SidecarPathIsAbs() bool

SidecarPathIsAbs checks if sidecar path is absolute.

func (*Config) SidecarWritable

func (c *Config) SidecarWritable() bool

SidecarWritable checks if sidecar files can be created.

func (*Config) SipsBin

func (c *Config) SipsBin() string

SipsBin returns the SIPS executable file name.

func (*Config) SipsBlacklist

func (c *Config) SipsBlacklist() string

SipsBlacklist returns the Sips file extension blacklist.

func (*Config) SipsEnabled

func (c *Config) SipsEnabled() bool

SipsEnabled checks if SIPS is enabled for RAW conversion.

func (*Config) SiteAuthor

func (c *Config) SiteAuthor() string

SiteAuthor returns the site author / copyright.

func (*Config) SiteCaption

func (c *Config) SiteCaption() string

SiteCaption returns a short site caption.

func (*Config) SiteDescription

func (c *Config) SiteDescription() string

SiteDescription returns a long site description.

func (*Config) SiteDomain

func (c *Config) SiteDomain() string

SiteDomain returns the public server domain.

func (*Config) SiteHttps

func (c *Config) SiteHttps() bool

SiteHttps checks if the site URL uses HTTPS.

func (*Config) SitePreview

func (c *Config) SitePreview() string

SitePreview returns the site preview image URL for sharing.

func (*Config) SiteTitle

func (c *Config) SiteTitle() string

SiteTitle returns the main site title (default is application name).

func (*Config) SiteUrl

func (c *Config) SiteUrl() string

SiteUrl returns the public server URL (default is "http://localhost:2342/").

func (*Config) Sponsor

func (c *Config) Sponsor() bool

Sponsor reports if you have chosen to support our mission.

func (*Config) SqliteBin

func (c *Config) SqliteBin() string

SqliteBin returns the sqlite executable file name.

func (*Config) StaticAssetUri

func (c *Config) StaticAssetUri(res string) string

StaticAssetUri returns the resource URI of the static file asset.

func (*Config) StaticFile

func (c *Config) StaticFile(fileName string) string

StaticFile returns the path to a static file.

func (*Config) StaticPath

func (c *Config) StaticPath() string

StaticPath returns the static assets' path.

func (*Config) StaticUri

func (c *Config) StaticUri() string

StaticUri returns the static content URI.

func (*Config) StoragePath

func (c *Config) StoragePath() string

StoragePath returns the path for generated files like cache and index.

func (*Config) TLS

func (c *Config) TLS() (publicCert, privateKey string)

TLS returns the HTTPS certificate and private key file name.

func (*Config) TLSCert

func (c *Config) TLSCert() string

TLSCert returns the public certificate required to enable TLS.

func (*Config) TLSEmail

func (c *Config) TLSEmail() string

TLSEmail returns the email address to enable automatic HTTPS via Let's Encrypt

func (*Config) TLSKey

func (c *Config) TLSKey() string

TLSKey returns the private key required to enable TLS.

func (*Config) TempPath

func (c *Config) TempPath() string

TempPath returns the cached temporary directory name e.g. for uploads and downloads.

func (*Config) TemplateExists

func (c *Config) TemplateExists(name string) bool

TemplateExists checks if a template with the given name exists (e.g. index.gohtml).

func (*Config) TemplateFiles

func (c *Config) TemplateFiles() []string

TemplateFiles returns the file paths of all templates found.

func (*Config) TemplateName

func (c *Config) TemplateName() string

TemplateName returns the name of the default template (e.g. index.gohtml).

func (*Config) TemplatesPath

func (c *Config) TemplatesPath() string

TemplatesPath returns the server templates path.

func (*Config) TensorFlowModelPath

func (c *Config) TensorFlowModelPath() string

TensorFlowModelPath returns the TensorFlow model path.

func (*Config) TensorFlowVersion

func (c *Config) TensorFlowVersion() string

TensorFlowVersion returns the TenorFlow framework version.

func (*Config) Test

func (c *Config) Test() bool

Test checks if test mode is enabled.

func (*Config) TestdataPath

func (c *Config) TestdataPath() string

TestdataPath returns the test files path.

func (*Config) ThumbCachePath

func (c *Config) ThumbCachePath() string

ThumbCachePath returns the thumbnail storage path.

func (*Config) ThumbColor

func (c *Config) ThumbColor() string

ThumbColor returns the color profile name for thumbnails.

func (*Config) ThumbFilter

func (c *Config) ThumbFilter() thumb.ResampleFilter

ThumbFilter returns the thumbnail resample filter (best to worst: blackman, lanczos, cubic or linear).

func (*Config) ThumbSRGB

func (c *Config) ThumbSRGB() bool

ThumbSRGB checks if colors should be normalized to standard RGB in thumbnails.

func (*Config) ThumbSizePrecached

func (c *Config) ThumbSizePrecached() int

ThumbSizePrecached returns the pre-cached thumbnail size limit in pixels (720-7680).

func (*Config) ThumbSizeUncached

func (c *Config) ThumbSizeUncached() int

ThumbSizeUncached returns the on-demand rendering size limit in pixels (720-7680).

func (*Config) ThumbUncached

func (c *Config) ThumbUncached() bool

ThumbUncached checks if on-demand thumbnail rendering is enabled (high memory and cpu usage).

func (*Config) Trace

func (c *Config) Trace() bool

Trace checks if trace mode is enabled, shows all log messages.

func (*Config) TrustedProxies

func (c *Config) TrustedProxies() []string

TrustedProxies returns proxy server ranges from which reverse proxy headers can be trusted.

func (*Config) TrustedProxy

func (c *Config) TrustedProxy() string

TrustedProxy returns the ranges from which reverse proxy headers can be trusted as comma-separated list.

func (*Config) Unsafe

func (c *Config) Unsafe() bool

Unsafe checks if unsafe settings are allowed.

func (*Config) UnzipTestData

func (c *Config) UnzipTestData() error

UnzipTestData extracts tests files from the zip archive.

func (*Config) UploadNSFW

func (c *Config) UploadNSFW() bool

UploadNSFW checks if NSFW photos can be uploaded.

func (*Config) UseCdn

func (c *Config) UseCdn() bool

UseCdn checks if a Content Deliver Network (CDN) is used to serve static content.

func (*Config) UserAgent

func (c *Config) UserAgent() string

UserAgent returns an HTTP user agent string based on the app config and version.

func (*Config) UserStoragePath

func (c *Config) UserStoragePath(userUid string) string

UserStoragePath returns the storage path for user assets.

func (*Config) UserUploadPath

func (c *Config) UserUploadPath(userUid, token string) (string, error)

UserUploadPath returns the upload path for the specified user.

func (*Config) UsersOriginalsPath

func (c *Config) UsersOriginalsPath() string

UsersOriginalsPath returns the users originals base path.

func (*Config) UsersPath

func (c *Config) UsersPath() string

UsersPath returns the relative base path for user assets.

func (*Config) UsersStoragePath

func (c *Config) UsersStoragePath() string

UsersStoragePath returns the users storage base path.

func (*Config) VectorEnabled

func (c *Config) VectorEnabled() bool

VectorEnabled checks if indexing and conversion of vector graphics is enabled.

func (*Config) Version

func (c *Config) Version() string

Version returns the application version.

func (*Config) VersionChecksum

func (c *Config) VersionChecksum() uint32

VersionChecksum returns the application version checksum.

func (*Config) VideoUri

func (c *Config) VideoUri() string

VideoUri returns the video streaming URI.

func (*Config) WakeupInterval

func (c *Config) WakeupInterval() time.Duration

WakeupInterval returns the duration between background worker runs required for face recognition and index maintenance(1-86400s).

func (*Config) WallpaperUri

func (c *Config) WallpaperUri() string

WallpaperUri returns the login screen background image URI.

func (*Config) Workers

func (c *Config) Workers() int

Workers returns the number of workers e.g. for indexing files.

type DSN

type DSN struct {
	Driver   string
	User     string
	Password string
	Net      string
	Server   string
	Name     string
	Params   string
}

DSN represents parts of a data source name.

func NewDSN

func NewDSN(dsn string) DSN

NewDSN creates a new DSN struct from a string.

func (*DSN) Parse

func (d *DSN) Parse(dsn string)

Parse parses a data source name string.

type Extension

type Extension struct {
	// contains filtered or unexported fields
}

Extension represents a named package extension with callbacks.

type Extensions

type Extensions []Extension

Extensions represents a list of package extensions.

func Ext

func Ext() (ext Extensions)

Ext returns all registered package extensions.

func (Extensions) Init

func (ext Extensions) Init(c *Config)

Init initializes the registered extensions.

type Map

type Map map[string]interface{}

Map is an alias for map[string]interface{}.

func ClientExt

func ClientExt(c *Config, t ClientType) Map

ClientExt returns optional client config values by namespace.

type Options

type Options struct {
	Name                  string        `json:"-"`
	About                 string        `json:"-"`
	Edition               string        `json:"-"`
	Version               string        `json:"-"`
	Copyright             string        `json:"-"`
	PartnerID             string        `yaml:"-" json:"-" flag:"partner-id"`
	AuthMode              string        `yaml:"AuthMode" json:"-" flag:"auth-mode"`
	Public                bool          `yaml:"Public" json:"-" flag:"public"`
	AdminUser             string        `yaml:"AdminUser" json:"-" flag:"admin-user"`
	AdminPassword         string        `yaml:"AdminPassword" json:"-" flag:"admin-password"`
	PasswordLength        int           `yaml:"PasswordLength" json:"-" flag:"password-length"`
	PasswordResetUri      string        `yaml:"PasswordResetUri" json:"-" flag:"password-reset-uri"`
	RegisterUri           string        `yaml:"RegisterUri" json:"-" flag:"register-uri"`
	LoginUri              string        `yaml:"LoginUri" json:"-" flag:"login-uri"`
	SessionMaxAge         int64         `yaml:"SessionMaxAge" json:"-" flag:"session-maxage"`
	SessionTimeout        int64         `yaml:"SessionTimeout" json:"-" flag:"session-timeout"`
	SessionCache          int64         `yaml:"SessionCache" json:"-" flag:"session-cache"`
	LogLevel              string        `yaml:"LogLevel" json:"-" flag:"log-level"`
	Prod                  bool          `yaml:"Prod" json:"Prod" flag:"prod"`
	Debug                 bool          `yaml:"Debug" json:"Debug" flag:"debug"`
	Trace                 bool          `yaml:"Trace" json:"Trace" flag:"trace"`
	Test                  bool          `yaml:"-" json:"Test,omitempty" flag:"test"`
	Unsafe                bool          `yaml:"-" json:"-" flag:"unsafe"`
	Demo                  bool          `yaml:"-" json:"-" flag:"demo"`
	Sponsor               bool          `yaml:"-" json:"-" flag:"sponsor"`
	ConfigPath            string        `yaml:"ConfigPath" json:"-" flag:"config-path"`
	DefaultsYaml          string        `json:"-" yaml:"-" flag:"defaults-yaml"`
	OriginalsPath         string        `yaml:"OriginalsPath" json:"-" flag:"originals-path"`
	OriginalsLimit        int           `yaml:"OriginalsLimit" json:"OriginalsLimit" flag:"originals-limit"`
	ResolutionLimit       int           `yaml:"ResolutionLimit" json:"ResolutionLimit" flag:"resolution-limit"`
	UsersPath             string        `yaml:"UsersPath" json:"-" flag:"users-path"`
	StoragePath           string        `yaml:"StoragePath" json:"-" flag:"storage-path"`
	SidecarPath           string        `yaml:"SidecarPath" json:"-" flag:"sidecar-path"`
	BackupPath            string        `yaml:"BackupPath" json:"-" flag:"backup-path"`
	CachePath             string        `yaml:"CachePath" json:"-" flag:"cache-path"`
	ImportPath            string        `yaml:"ImportPath" json:"-" flag:"import-path"`
	ImportDest            string        `yaml:"ImportDest" json:"-" flag:"import-dest"`
	AssetsPath            string        `yaml:"AssetsPath" json:"-" flag:"assets-path"`
	CustomAssetsPath      string        `yaml:"-" json:"-" flag:"custom-assets-path"`
	TempPath              string        `yaml:"TempPath" json:"-" flag:"temp-path"`
	Workers               int           `yaml:"Workers" json:"Workers" flag:"workers"`
	WakeupInterval        time.Duration `yaml:"WakeupInterval" json:"WakeupInterval" flag:"wakeup-interval"`
	AutoIndex             int           `yaml:"AutoIndex" json:"AutoIndex" flag:"auto-index"`
	AutoImport            int           `yaml:"AutoImport" json:"AutoImport" flag:"auto-import"`
	ReadOnly              bool          `yaml:"ReadOnly" json:"ReadOnly" flag:"read-only"`
	Experimental          bool          `yaml:"Experimental" json:"Experimental" flag:"experimental"`
	DisableSettings       bool          `yaml:"DisableSettings" json:"-" flag:"disable-settings"`
	DisableRestart        bool          `yaml:"DisableRestart" json:"-" flag:"disable-restart"`
	DisableBackups        bool          `yaml:"DisableBackups" json:"DisableBackups" flag:"disable-backups"`
	DisableWebDAV         bool          `yaml:"DisableWebDAV" json:"DisableWebDAV" flag:"disable-webdav"`
	DisablePlaces         bool          `yaml:"DisablePlaces" json:"DisablePlaces" flag:"disable-places"`
	DisableTensorFlow     bool          `yaml:"DisableTensorFlow" json:"DisableTensorFlow" flag:"disable-tensorflow"`
	DisableFaces          bool          `yaml:"DisableFaces" json:"DisableFaces" flag:"disable-faces"`
	DisableClassification bool          `yaml:"DisableClassification" json:"DisableClassification" flag:"disable-classification"`
	DisableFFmpeg         bool          `yaml:"DisableFFmpeg" json:"DisableFFmpeg" flag:"disable-ffmpeg"`
	DisableExifTool       bool          `yaml:"DisableExifTool" json:"DisableExifTool" flag:"disable-exiftool"`
	DisableSips           bool          `yaml:"DisableSips" json:"DisableSips" flag:"disable-sips"`
	DisableDarktable      bool          `yaml:"DisableDarktable" json:"DisableDarktable" flag:"disable-darktable"`
	DisableRawTherapee    bool          `yaml:"DisableRawTherapee" json:"DisableRawTherapee" flag:"disable-rawtherapee"`
	DisableImageMagick    bool          `yaml:"DisableImageMagick" json:"DisableImageMagick" flag:"disable-imagemagick"`
	DisableHeifConvert    bool          `yaml:"DisableHeifConvert" json:"DisableHeifConvert" flag:"disable-heifconvert"`
	DisableVectors        bool          `yaml:"DisableVectors" json:"DisableVectors" flag:"disable-vectors"`
	DisableJpegXL         bool          `yaml:"DisableJpegXL" json:"DisableJpegXL" flag:"disable-jpegxl"`
	DisableRaw            bool          `yaml:"DisableRaw" json:"DisableRaw" flag:"disable-raw"`
	RawPresets            bool          `yaml:"RawPresets" json:"RawPresets" flag:"raw-presets"`
	ExifBruteForce        bool          `yaml:"ExifBruteForce" json:"ExifBruteForce" flag:"exif-bruteforce"`
	DetectNSFW            bool          `yaml:"DetectNSFW" json:"DetectNSFW" flag:"detect-nsfw"`
	UploadNSFW            bool          `yaml:"UploadNSFW" json:"-" flag:"upload-nsfw"`
	DefaultTheme          string        `yaml:"DefaultTheme" json:"DefaultTheme" flag:"default-theme"`
	DefaultLocale         string        `yaml:"DefaultLocale" json:"DefaultLocale" flag:"default-locale"`
	AppName               string        `yaml:"AppName" json:"AppName" flag:"app-name"`
	AppMode               string        `yaml:"AppMode" json:"AppMode" flag:"app-mode"`
	AppIcon               string        `yaml:"AppIcon" json:"AppIcon" flag:"app-icon"`
	AppColor              string        `yaml:"AppColor" json:"AppColor" flag:"app-color"`
	LegalInfo             string        `yaml:"LegalInfo" json:"LegalInfo" flag:"legal-info"`
	LegalUrl              string        `yaml:"LegalUrl" json:"LegalUrl" flag:"legal-url"`
	WallpaperUri          string        `yaml:"WallpaperUri" json:"WallpaperUri" flag:"wallpaper-uri"`
	SiteUrl               string        `yaml:"SiteUrl" json:"SiteUrl" flag:"site-url"`
	SiteAuthor            string        `yaml:"SiteAuthor" json:"SiteAuthor" flag:"site-author"`
	SiteTitle             string        `yaml:"SiteTitle" json:"SiteTitle" flag:"site-title"`
	SiteCaption           string        `yaml:"SiteCaption" json:"SiteCaption" flag:"site-caption"`
	SiteDescription       string        `yaml:"SiteDescription" json:"SiteDescription" flag:"site-description"`
	SitePreview           string        `yaml:"SitePreview" json:"SitePreview" flag:"site-preview"`
	CdnUrl                string        `yaml:"CdnUrl" json:"CdnUrl" flag:"cdn-url"`
	CdnVideo              bool          `yaml:"CdnVideo" json:"CdnVideo" flag:"cdn-video"`
	CORSOrigin            string        `yaml:"CORSOrigin" json:"-" flag:"cors-origin"`
	CORSHeaders           string        `yaml:"CORSHeaders" json:"-" flag:"cors-headers"`
	CORSMethods           string        `yaml:"CORSMethods" json:"-" flag:"cors-methods"`
	HttpsProxy            string        `yaml:"HttpsProxy" json:"HttpsProxy" flag:"https-proxy"`
	HttpsProxyInsecure    bool          `yaml:"HttpsProxyInsecure" json:"HttpsProxyInsecure" flag:"https-proxy-insecure"`
	TrustedProxies        []string      `yaml:"TrustedProxies" json:"-" flag:"trusted-proxy"`
	ProxyProtoHeaders     []string      `yaml:"ProxyProtoHeaders" json:"-" flag:"proxy-proto-header"`
	ProxyProtoHttps       []string      `yaml:"ProxyProtoHttps" json:"-" flag:"proxy-proto-https"`
	DisableTLS            bool          `yaml:"DisableTLS" json:"DisableTLS" flag:"disable-tls"`
	DefaultTLS            bool          `yaml:"DefaultTLS" json:"DefaultTLS" flag:"default-tls"`
	TLSEmail              string        `yaml:"TLSEmail" json:"TLSEmail" flag:"tls-email"`
	TLSCert               string        `yaml:"TLSCert" json:"TLSCert" flag:"tls-cert"`
	TLSKey                string        `yaml:"TLSKey" json:"TLSKey" flag:"tls-key"`
	HttpMode              string        `yaml:"HttpMode" json:"-" flag:"http-mode"`
	HttpCompression       string        `yaml:"HttpCompression" json:"-" flag:"http-compression"`
	HttpCachePublic       bool          `yaml:"HttpCachePublic" json:"HttpCachePublic" flag:"http-cache-public"`
	HttpCacheMaxAge       int           `yaml:"HttpCacheMaxAge" json:"HttpCacheMaxAge" flag:"http-cache-maxage"`
	HttpVideoMaxAge       int           `yaml:"HttpVideoMaxAge" json:"HttpVideoMaxAge" flag:"http-video-maxage"`
	HttpHost              string        `yaml:"HttpHost" json:"-" flag:"http-host"`
	HttpPort              int           `yaml:"HttpPort" json:"-" flag:"http-port"`
	HttpSocket            string        `yaml:"-" json:"-" flag:"-"`
	DatabaseDriver        string        `yaml:"DatabaseDriver" json:"-" flag:"database-driver"`
	DatabaseDsn           string        `yaml:"DatabaseDsn" json:"-" flag:"database-dsn"`
	DatabaseName          string        `yaml:"DatabaseName" json:"-" flag:"database-name"`
	DatabaseServer        string        `yaml:"DatabaseServer" json:"-" flag:"database-server"`
	DatabaseUser          string        `yaml:"DatabaseUser" json:"-" flag:"database-user"`
	DatabasePassword      string        `yaml:"DatabasePassword" json:"-" flag:"database-password"`
	DatabaseTimeout       int           `yaml:"DatabaseTimeout" json:"-" flag:"database-timeout"`
	DatabaseConns         int           `yaml:"DatabaseConns" json:"-" flag:"database-conns"`
	DatabaseConnsIdle     int           `yaml:"DatabaseConnsIdle" json:"-" flag:"database-conns-idle"`
	SipsBin               string        `yaml:"SipsBin" json:"-" flag:"sips-bin"`
	SipsBlacklist         string        `yaml:"SipsBlacklist" json:"-" flag:"sips-blacklist"`
	FFmpegBin             string        `yaml:"FFmpegBin" json:"-" flag:"ffmpeg-bin"`
	FFmpegEncoder         string        `yaml:"FFmpegEncoder" json:"FFmpegEncoder" flag:"ffmpeg-encoder"`
	FFmpegSize            int           `yaml:"FFmpegSize" json:"FFmpegSize" flag:"ffmpeg-size"`
	FFmpegBitrate         int           `yaml:"FFmpegBitrate" json:"FFmpegBitrate" flag:"ffmpeg-bitrate"`
	FFmpegMapVideo        string        `yaml:"FFmpegMapVideo" json:"FFmpegMapVideo" flag:"ffmpeg-map-video"`
	FFmpegMapAudio        string        `yaml:"FFmpegMapAudio" json:"FFmpegMapAudio" flag:"ffmpeg-map-audio"`
	ExifToolBin           string        `yaml:"ExifToolBin" json:"-" flag:"exiftool-bin"`
	DarktableBin          string        `yaml:"DarktableBin" json:"-" flag:"darktable-bin"`
	DarktableCachePath    string        `yaml:"DarktableCachePath" json:"-" flag:"darktable-cache-path"`
	DarktableConfigPath   string        `yaml:"DarktableConfigPath" json:"-" flag:"darktable-config-path"`
	DarktableBlacklist    string        `yaml:"DarktableBlacklist" json:"-" flag:"darktable-blacklist"`
	RawTherapeeBin        string        `yaml:"RawTherapeeBin" json:"-" flag:"rawtherapee-bin"`
	RawTherapeeBlacklist  string        `yaml:"RawTherapeeBlacklist" json:"-" flag:"rawtherapee-blacklist"`
	ImageMagickBin        string        `yaml:"ImageMagickBin" json:"-" flag:"imagemagick-bin"`
	ImageMagickBlacklist  string        `yaml:"ImageMagickBlacklist" json:"-" flag:"imagemagick-blacklist"`
	HeifConvertBin        string        `yaml:"HeifConvertBin" json:"-" flag:"heifconvert-bin"`
	RsvgConvertBin        string        `yaml:"RsvgConvertBin" json:"-" flag:"rsvgconvert-bin"`
	DownloadToken         string        `yaml:"DownloadToken" json:"-" flag:"download-token"`
	PreviewToken          string        `yaml:"PreviewToken" json:"-" flag:"preview-token"`
	ThumbColor            string        `yaml:"ThumbColor" json:"ThumbColor" flag:"thumb-color"`
	ThumbFilter           string        `yaml:"ThumbFilter" json:"ThumbFilter" flag:"thumb-filter"`
	ThumbSize             int           `yaml:"ThumbSize" json:"ThumbSize" flag:"thumb-size"`
	ThumbSizeUncached     int           `yaml:"ThumbSizeUncached" json:"ThumbSizeUncached" flag:"thumb-size-uncached"`
	ThumbUncached         bool          `yaml:"ThumbUncached" json:"ThumbUncached" flag:"thumb-uncached"`
	JpegQuality           string        `yaml:"JpegQuality" json:"JpegQuality" flag:"jpeg-quality"`
	JpegSize              int           `yaml:"JpegSize" json:"JpegSize" flag:"jpeg-size"`
	PngSize               int           `yaml:"PngSize" json:"PngSize" flag:"png-size"`
	FaceSize              int           `yaml:"-" json:"-" flag:"face-size"`
	FaceScore             float64       `yaml:"-" json:"-" flag:"face-score"`
	FaceOverlap           int           `yaml:"-" json:"-" flag:"face-overlap"`
	FaceClusterSize       int           `yaml:"-" json:"-" flag:"face-cluster-size"`
	FaceClusterScore      int           `yaml:"-" json:"-" flag:"face-cluster-score"`
	FaceClusterCore       int           `yaml:"-" json:"-" flag:"face-cluster-core"`
	FaceClusterDist       float64       `yaml:"-" json:"-" flag:"face-cluster-dist"`
	FaceMatchDist         float64       `yaml:"-" json:"-" flag:"face-match-dist"`
	PIDFilename           string        `yaml:"PIDFilename" json:"-" flag:"pid-filename"`
	LogFilename           string        `yaml:"LogFilename" json:"-" flag:"log-filename"`
	DetachServer          bool          `yaml:"DetachServer" json:"-" flag:"detach-server"`
}

Options hold the global configuration values without further validation or processing. Application code should retrieve option values via getter functions since they provide validation and return defaults if a value is empty.

func NewOptions

func NewOptions(ctx *cli.Context) *Options

NewOptions creates a new configuration entity by using two methods:

1. Load: This will initialize options from a yaml config file.

  1. ApplyCliContext: Which comes after Load and overrides any previous options giving an option two override file configs through the CLI.

func NewTestOptions

func NewTestOptions(pkg string) *Options

NewTestOptions returns valid config options for tests.

func NewTestOptionsError

func NewTestOptionsError() *Options

NewTestOptionsError returns invalid config options for tests.

func (*Options) ApplyCliContext

func (c *Options) ApplyCliContext(ctx *cli.Context) error

ApplyCliContext uses options from the CLI to setup configuration overrides for the entity.

func (*Options) Load

func (c *Options) Load(fileName string) error

Load uses a yaml config file to initiate the configuration entity.

func (Options) Report

func (c Options) Report() (rows [][]string, cols []string)

Report returns global config values as a table for reporting.

type ThumbSize

type ThumbSize struct {
	Size   string `json:"size"`
	Usage  string `json:"usage"`
	Width  int    `json:"w"`
	Height int    `json:"h"`
}

ThumbSize represents thumbnail info for use in client apps.

type ThumbSizes

type ThumbSizes []ThumbSize

ThumbSizes represents a list of thumbnail types.

var Thumbs ThumbSizes

Thumbs is a list of thumbnails for use in client apps.

type Years

type Years []int

Years represents a list of years.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL