Skip to content

Commit

Permalink
Config: Make options available to all users
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Mayer <michael@photoprism.app>
  • Loading branch information
lastzero committed May 13, 2023
1 parent 6da54f9 commit 0e415fe
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 64 deletions.
4 changes: 2 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**By using the software and services we provide, you agree to our [Terms of Service](https://www.photoprism.app/terms), including our [Privacy Policy](https://www.photoprism.app/privacy) and the following Code of Conduct. It explains the "dos and don’ts" when interacting with our team and other community members.**

*Last Updated: May 12, 2023*
*Last Updated: May 13, 2023*

## Rules

Expand All @@ -18,7 +18,7 @@ Because we want our Code of Conduct to be easy to understand and implement, we h

Not everyone has experience with Open Source communities and intuitively knows what is acceptable. In that case, the following guidelines and examples are meant to provide a quick overview and help you avoid the most common pitfalls:

(a) Do not feel entitled to free software, support, or advice, especially if you are not a contributor, [member](https://link.photoprism.app/membership), or paying customer. Don't expect contributors to report to you and [meet deadlines](https://docs.photoprism.app/developer-guide/code-quality/#go-slow-before-you-go-fast) as if they work for you or owe you something, even if you donated a small amount. We also ask that you do not use GitHub Issues or other development tools to start general discussions, get technical support, or express personal opinions.
(a) Do not [feel entitled](https://www.reddit.com/r/photoprism/comments/13emwf0/did_you_guys_really_nerf_hardware_transcoding/) to free software, support, or advice, especially if you are not a contributor, [member](https://link.photoprism.app/membership), or paying customer. Don't expect contributors to report to you and [meet deadlines](https://docs.photoprism.app/developer-guide/code-quality/#go-slow-before-you-go-fast) as if they work for you or owe you something, even if you donated a small amount. We also ask that you do not use GitHub Issues or other development tools to start general discussions, get technical support, or express personal opinions.

(b) Honor **Rule &#35;2**, [read the docs](https://docs.photoprism.app) and [determine the cause of your problem](https://docs.photoprism.app/getting-started/troubleshooting/) before opening invalid bug reports, starting a public "shitstorm", or insulting other community members in our chat rooms. Aside from being annoying for everyone, it also keeps our team from working on features and enhancements that users like you are waiting for.

Expand Down
23 changes: 3 additions & 20 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,16 +426,12 @@ func (c *Config) ApiUri() string {

// CdnUrl returns the optional content delivery network URI without trailing slash.
func (c *Config) CdnUrl(res string) string {
if c.NoSponsor() {
return res
}

return strings.TrimRight(c.options.CdnUrl, "/") + res
}

// CdnVideo checks if videos should be streamed using the configured CDN.
func (c *Config) CdnVideo() bool {
if c.NoSponsor() || c.options.CdnUrl == "" {
if c.options.CdnUrl == "" {
return false
}

Expand Down Expand Up @@ -500,7 +496,7 @@ func (c *Config) SiteAuthor() string {

// SiteTitle returns the main site title (default is application name).
func (c *Config) SiteTitle() string {
if c.options.SiteTitle == "" || c.NoSponsor() {
if c.options.SiteTitle == "" {
return c.Name()
}

Expand All @@ -519,7 +515,7 @@ func (c *Config) SiteDescription() string {

// SitePreview returns the site preview image URL for sharing.
func (c *Config) SitePreview() string {
if c.options.SitePreview == "" || c.NoSponsor() {
if c.options.SitePreview == "" {
return fmt.Sprintf("https://i.photoprism.app/prism?cover=64&style=centered%%20dark&caption=none&title=%s", url.QueryEscape(c.AppName()))
}

Expand All @@ -532,10 +528,6 @@ func (c *Config) SitePreview() string {

// LegalInfo returns the legal info text for the page footer.
func (c *Config) LegalInfo() string {
if c.NoSponsor() {
return SignUpInfo
}

if s := c.CliGlobalString("imprint"); s != "" {
log.Warnf("config: option 'imprint' is deprecated, please use 'legal-info'")
return s
Expand All @@ -546,10 +538,6 @@ func (c *Config) LegalInfo() string {

// LegalUrl returns the legal info url.
func (c *Config) LegalUrl() string {
if c.NoSponsor() {
return SignUpURL
}

if s := c.CliGlobalString("imprint-url"); s != "" {
log.Warnf("config: option 'imprint-url' is deprecated, please use 'legal-url'")
return s
Expand Down Expand Up @@ -604,11 +592,6 @@ func (c *Config) Sponsor() bool {
return Sponsor
}

// NoSponsor reports if you prefer not to support our mission.
func (c *Config) NoSponsor() bool {
return !c.Sponsor() && !c.Demo()
}

// Experimental checks if experimental features should be enabled.
func (c *Config) Experimental() bool {
return c.options.Experimental
Expand Down
4 changes: 2 additions & 2 deletions internal/config/config_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func (c *Config) AppName() string {
name := strings.TrimSpace(c.options.AppName)

if c.NoSponsor() || name == "" {
if name == "" {
name = c.SiteTitle()
}

Expand Down Expand Up @@ -44,7 +44,7 @@ func (c *Config) AppMode() string {
func (c *Config) AppIcon() string {
defaultIcon := "logo"

if c.NoSponsor() || c.options.AppIcon == "" || c.options.AppIcon == defaultIcon {
if c.options.AppIcon == "" || c.options.AppIcon == defaultIcon {
// Default.
} else if strings.Contains(c.options.AppIcon, "/") {
return c.options.AppIcon
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config_customize.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

// DefaultTheme returns the default user interface theme name.
func (c *Config) DefaultTheme() string {
if c.options.DefaultTheme == "" || c.NoSponsor() {
if c.options.DefaultTheme == "" {
return "default"
}

Expand Down
6 changes: 3 additions & 3 deletions internal/config/config_customize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ func TestConfig_DefaultTheme(t *testing.T) {
c.options.Sponsor = false
c.options.Test = false
c.options.DefaultTheme = "grayscale"
assert.Equal(t, "default", c.DefaultTheme())
assert.Equal(t, "grayscale", c.DefaultTheme())
c.options.Sponsor = true
assert.Equal(t, "grayscale", c.DefaultTheme())
c.options.Sponsor = false
c.options.Test = true
assert.Equal(t, "default", c.DefaultTheme())
assert.Equal(t, "grayscale", c.DefaultTheme())
c.options.Sponsor = false
c.options.Test = false
assert.Equal(t, "default", c.DefaultTheme())
assert.Equal(t, "grayscale", c.DefaultTheme())
c.options.Sponsor = true
c.options.DefaultTheme = ""
assert.Equal(t, "default", c.DefaultTheme())
Expand Down
10 changes: 5 additions & 5 deletions internal/config/config_faces.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (c *Config) FaceOverlap() int {

// FaceClusterSize returns the size threshold for faces forming a cluster in pixels.
func (c *Config) FaceClusterSize() int {
if c.NoSponsor() || c.options.FaceClusterSize < 20 || c.options.FaceClusterSize > 10000 {
if c.options.FaceClusterSize < 20 || c.options.FaceClusterSize > 10000 {
return face.ClusterSizeThreshold
}

Expand All @@ -40,7 +40,7 @@ func (c *Config) FaceClusterSize() int {

// FaceClusterScore returns the quality threshold for faces forming a cluster.
func (c *Config) FaceClusterScore() int {
if c.NoSponsor() || c.options.FaceClusterScore < 1 || c.options.FaceClusterScore > 100 {
if c.options.FaceClusterScore < 1 || c.options.FaceClusterScore > 100 {
return face.ClusterScoreThreshold
}

Expand All @@ -49,7 +49,7 @@ func (c *Config) FaceClusterScore() int {

// FaceClusterCore returns the number of faces forming a cluster core.
func (c *Config) FaceClusterCore() int {
if c.NoSponsor() || c.options.FaceClusterCore < 1 || c.options.FaceClusterCore > 100 {
if c.options.FaceClusterCore < 1 || c.options.FaceClusterCore > 100 {
return face.ClusterCore
}

Expand All @@ -58,7 +58,7 @@ func (c *Config) FaceClusterCore() int {

// FaceClusterDist returns the radius of faces forming a cluster core.
func (c *Config) FaceClusterDist() float64 {
if c.NoSponsor() || c.options.FaceClusterDist < 0.1 || c.options.FaceClusterDist > 1.5 {
if c.options.FaceClusterDist < 0.1 || c.options.FaceClusterDist > 1.5 {
return face.ClusterDist
}

Expand All @@ -67,7 +67,7 @@ func (c *Config) FaceClusterDist() float64 {

// FaceMatchDist returns the offset distance when matching faces with clusters.
func (c *Config) FaceMatchDist() float64 {
if c.NoSponsor() || c.options.FaceMatchDist < 0.1 || c.options.FaceMatchDist > 1.5 {
if c.options.FaceMatchDist < 0.1 || c.options.FaceMatchDist > 1.5 {
return face.MatchDist
}

Expand Down
3 changes: 0 additions & 3 deletions internal/config/config_ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ func (c *Config) FFmpegEnabled() bool {
func (c *Config) FFmpegEncoder() ffmpeg.AvcEncoder {
if c.options.FFmpegEncoder == "" || c.options.FFmpegEncoder == ffmpeg.SoftwareEncoder.String() {
return ffmpeg.SoftwareEncoder
} else if c.NoSponsor() {
log.Infof("ffmpeg: hardware transcoding is available to members only")
return ffmpeg.SoftwareEncoder
}

return ffmpeg.FindEncoder(c.options.FFmpegEncoder)
Expand Down
42 changes: 14 additions & 28 deletions internal/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,13 @@ var Flags = CliFlags{
Name: "default-theme",
Usage: "standard user interface theme `NAME`",
EnvVar: EnvVar("DEFAULT_THEME"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.StringFlag{
Name: "app-name",
Usage: "progressive web app `NAME` when installed on a device",
Value: "",
EnvVar: EnvVar("APP_NAME"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.StringFlag{
Name: "app-mode",
Usage: "progressive web app `MODE` (fullscreen, standalone, minimal-ui, browser)",
Expand All @@ -346,8 +344,7 @@ var Flags = CliFlags{
Name: "app-icon",
Usage: "home screen `ICON` (logo, app, crisp, mint, bold, square)",
EnvVar: EnvVar("APP_ICON"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.StringFlag{
Name: "app-color",
Usage: "splash screen `COLOR` code",
Expand All @@ -360,30 +357,26 @@ var Flags = CliFlags{
Value: "",
Hidden: true,
EnvVar: EnvVar("IMPRINT"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.StringFlag{
Name: "legal-info",
Usage: "legal information `TEXT`, displayed in the page footer",
Value: "",
EnvVar: EnvVar("LEGAL_INFO"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.StringFlag{
Name: "imprint-url",
Usage: "legal information `URL`",
Value: "",
Hidden: true,
EnvVar: EnvVar("IMPRINT_URL"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.StringFlag{
Name: "legal-url",
Usage: "legal information `URL`",
Value: "",
EnvVar: EnvVar("LEGAL_URL"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.StringFlag{
Name: "wallpaper-uri",
Usage: "login screen background image `URI`",
Expand All @@ -394,14 +387,12 @@ var Flags = CliFlags{
Name: "cdn-url",
Usage: "content delivery network `URL`",
EnvVar: EnvVar("CDN_URL"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.BoolFlag{
Name: "cdn-video",
Usage: "stream videos over the specified CDN",
EnvVar: EnvVar("CDN_VIDEO"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.StringFlag{
Name: "site-url, url",
Usage: "public site `URL`",
Expand All @@ -418,8 +409,7 @@ var Flags = CliFlags{
Usage: "site `TITLE`",
Value: "",
EnvVar: EnvVar("SITE_TITLE"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.StringFlag{
Name: "site-caption",
Usage: "site `CAPTION`",
Expand Down Expand Up @@ -583,8 +573,7 @@ var Flags = CliFlags{
Usage: "FFmpeg AVC encoder `NAME`",
Value: "libx264",
EnvVar: EnvVar("FFMPEG_ENCODER"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.IntFlag{
Name: "ffmpeg-bitrate, vb",
Usage: "maximum FFmpeg encoding `BITRATE` (Mbit/s)",
Expand Down Expand Up @@ -755,22 +744,19 @@ var Flags = CliFlags{
Usage: "`NUMBER` of faces forming a cluster core (1-100)",
Value: face.ClusterCore,
EnvVar: EnvVar("FACE_CLUSTER_CORE"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.Float64Flag{
Name: "face-cluster-dist",
Usage: "similarity `DISTANCE` of faces forming a cluster core (0.1-1.5)",
Value: face.ClusterDist,
EnvVar: EnvVar("FACE_CLUSTER_DIST"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.Float64Flag{
Name: "face-match-dist",
Usage: "similarity `OFFSET` for matching faces with existing clusters (0.1-1.5)",
Value: face.MatchDist,
EnvVar: EnvVar("FACE_MATCH_DIST"),
},
Tags: []string{Essentials}}, {
}}, {
Flag: cli.StringFlag{
Name: "pid-filename",
Usage: "process id `FILE` *daemon-mode only*",
Expand Down

0 comments on commit 0e415fe

Please sign in to comment.