Add "experimental" feature flag #152 #153 #154

Use this flag to test new features before they are stable.

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2019-12-30 12:38:11 +01:00
parent 5c7b3b471a
commit 7d5bc0619e
11 changed files with 94 additions and 29 deletions

View file

@ -7,6 +7,7 @@ twitter: "@browseyourlife"
debug: false
read-only: false
public: false
experimental: false
admin-password: photoprism
config-path: ~/.config/photoprism
cache-path: ~/.cache/photoprism

View file

@ -32,7 +32,7 @@
window.clientConfig = {{ .clientConfig }};
</script>
</head>
<body>
<body class="{{ .clientConfig.flags }}">
<!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
your browser</a> to improve your experience.</p>

View file

@ -19,6 +19,11 @@ services:
PHOTOPRISM_AUTHOR: "PhotoPrism.org"
PHOTOPRISM_TWITTER: "@browseyourlife"
PHOTOPRISM_DEBUG: "true"
PHOTOPRISM_READONLY: "false"
PHOTOPRISM_PUBLIC: "false"
PHOTOPRISM_EXPERIMENTAL: "true"
PHOTOPRISM_UPLOAD_NSFW: "false"
PHOTOPRISM_HIDE_NSFW: "false"
PHOTOPRISM_SERVER_MODE: "debug"
PHOTOPRISM_ASSETS_PATH: "/go/src/github.com/photoprism/photoprism/assets"
PHOTOPRISM_CACHE_PATH: "/go/src/github.com/photoprism/photoprism/assets/cache"

View file

@ -5,6 +5,14 @@ ENV TF_CPP_MIN_LOG_LEVEL 2
RUN wget -qO- https://dl.photoprism.org/fixtures/demo.tar.gz | tar xvz -C Pictures/Import
# Configure PhotoPrism
ENV PHOTOPRISM_DEBUG false
ENV PHOTOPRISM_READONLY false
ENV PHOTOPRISM_PUBLIC true
ENV PHOTOPRISM_EXPERIMENTAL true
ENV PHOTOPRISM_UPLOAD_NSFW false
ENV PHOTOPRISM_HIDE_NSFW false
# Import example photos
RUN photoprism import

View file

@ -21,8 +21,13 @@ services:
PHOTOPRISM_IMPORT_PATH: "/home/photoprism/Pictures/Import"
PHOTOPRISM_EXPORT_PATH: "/home/photoprism/Pictures/Export"
PHOTOPRISM_ORIGINALS_PATH: "/home/photoprism/Pictures/Originals"
PHOTOPRISM_ADMIN_PASSWORD: "photoprism"
PHOTOPRISM_UPLOAD_NSFW: "true"
PHOTOPRISM_HIDE_NSFW: "false"
PHOTOPRISM_EXPERIMENTAL: "false"
PHOTOPRISM_DEBUG: "false"
PHOTOPRISM_READONLY: "false"
PHOTOPRISM_PUBLIC: "false"
PHOTOPRISM_ADMIN_PASSWORD: "photoprism"
volumes:
- "~/Pictures/Originals:/home/photoprism/Pictures/Originals" # [local path]:[container path]
- "~/Pictures/Import:/home/photoprism/Pictures/Import" # [local path]:[container path] (optional)

View file

@ -159,7 +159,7 @@
</v-list-tile-content>
</v-list-tile>
<v-list-tile to="/discover" @click="" class="p-navigation-discover">
<v-list-tile to="/discover" @click="" class="p-navigation-discover" v-if="config.experimental">
<v-list-tile-action>
<v-icon>color_lens</v-icon>
</v-list-tile-action>

View file

@ -156,3 +156,19 @@ main {
#photoprism .p-rounded {
border-radius: 50%;
}
/* Feature Flags */
.p-experimental,
.p-debug,
.p-public,
.p-readonly {
display: none;
}
body.experimental #photoprism .p-experimental,
body.debug #photoprism .p-debug,
body.public #photoprism .p-public,
body.readonly #photoprism .p-readonly {
display: block;
}

View file

@ -30,6 +30,7 @@ func configAction(ctx *cli.Context) error {
fmt.Printf("debug %t\n", conf.Debug())
fmt.Printf("read-only %t\n", conf.ReadOnly())
fmt.Printf("public %t\n", conf.Public())
fmt.Printf("experimental %t\n", conf.Experimental())
fmt.Printf("admin-password %s\n", conf.AdminPassword())
fmt.Printf("log-level %s\n", conf.LogLevel())
fmt.Printf("log-filename %s\n", conf.LogFilename())

View file

@ -251,6 +251,11 @@ func (c *Config) Public() bool {
return c.config.Public
}
// Experimental returns true if experimental features should be enabled.
func (c *Config) Experimental() bool {
return c.config.Experimental
}
// ReadOnly returns true if photo directories are write protected.
func (c *Config) ReadOnly() bool {
return c.config.ReadOnly
@ -680,33 +685,51 @@ func (c *Config) ClientConfig() ClientConfig {
jsHash := util.Hash(c.HttpStaticBuildPath() + "/app.js")
cssHash := util.Hash(c.HttpStaticBuildPath() + "/app.css")
// Feature Flags
var flags []string
if c.Public() {
flags = append(flags, "public")
}
if c.Debug() {
flags = append(flags, "debug")
}
if c.Experimental() {
flags = append(flags, "experimental")
}
if c.ReadOnly() {
flags = append(flags, "readonly")
}
result := ClientConfig{
"name": c.Name(),
"url": c.Url(),
"title": c.Title(),
"subtitle": c.Subtitle(),
"description": c.Description(),
"author": c.Author(),
"twitter": c.Twitter(),
"version": c.Version(),
"copyright": c.Copyright(),
"debug": c.Debug(),
"readonly": c.ReadOnly(),
"uploadNSFW": c.UploadNSFW(),
"public": c.Public(),
"albums": albums,
"cameras": cameras,
"lenses": lenses,
"countries": countries,
"thumbnails": Thumbnails,
"jsHash": jsHash,
"cssHash": cssHash,
"settings": c.Settings(),
"count": count,
"pos": position,
"years": years,
"colors": colors.All.List(),
"categories": categories,
"flags": strings.Join(flags, " "),
"name": c.Name(),
"url": c.Url(),
"title": c.Title(),
"subtitle": c.Subtitle(),
"description": c.Description(),
"author": c.Author(),
"twitter": c.Twitter(),
"version": c.Version(),
"copyright": c.Copyright(),
"debug": c.Debug(),
"readonly": c.ReadOnly(),
"uploadNSFW": c.UploadNSFW(),
"public": c.Public(),
"experimental": c.Experimental(),
"albums": albums,
"cameras": cameras,
"lenses": lenses,
"countries": countries,
"thumbnails": Thumbnails,
"jsHash": jsHash,
"cssHash": cssHash,
"settings": c.Settings(),
"count": count,
"pos": position,
"years": years,
"colors": colors.All.List(),
"categories": categories,
}
return result

View file

@ -21,6 +21,11 @@ var GlobalFlags = []cli.Flag{
Usage: "no authentication required",
EnvVar: "PHOTOPRISM_PUBLIC",
},
cli.BoolFlag{
Name: "experimental, e",
Usage: "enable experimental features",
EnvVar: "PHOTOPRISM_EXPERIMENTAL",
},
cli.StringFlag{
Name: "url",
Usage: "canonical site URL",

View file

@ -37,6 +37,7 @@ type Params struct {
Version string
Copyright string
Debug bool `yaml:"debug" flag:"debug"`
Experimental bool `yaml:"experimental" flag:"experimental"`
ReadOnly bool `yaml:"read-only" flag:"read-only"`
Public bool `yaml:"public" flag:"public"`
AdminPassword string `yaml:"admin-password" flag:"admin-password"`