split theme configuration flags

This commit is contained in:
Willy Kloucek
2021-10-12 16:27:39 +02:00
parent d17b13af2b
commit 03e60fe63d
3 changed files with 22 additions and 5 deletions
+2
View File
@@ -43,6 +43,8 @@ type Asset struct {
// WebConfig defines the available web configuration for a dynamically rendered config.json. // WebConfig defines the available web configuration for a dynamically rendered config.json.
type WebConfig struct { type WebConfig struct {
Server string `json:"server,omitempty"` Server string `json:"server,omitempty"`
ThemeServer string `json:"omit"` // only used to build Theme
ThemePath string `json:"omit"` // only used to build Theme
Theme string `json:"theme,omitempty"` Theme string `json:"theme,omitempty"`
Version string `json:"version,omitempty"` // TODO what is version used for? Version string `json:"version,omitempty"` // TODO what is version used for?
OpenIDConnect OIDC `json:"openIdConnect,omitempty"` OpenIDConnect OIDC `json:"openIdConnect,omitempty"`
+12 -5
View File
@@ -164,16 +164,23 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
&cli.StringFlag{ &cli.StringFlag{
Name: "web-config-server", Name: "web-config-server",
Value: flags.OverrideDefaultString(cfg.Web.Config.Server, "https://localhost:9200"), Value: flags.OverrideDefaultString(cfg.Web.Config.Server, "https://localhost:9200"),
Usage: "Server URL", Usage: "Configuration server URL",
EnvVars: []string{"WEB_UI_CONFIG_SERVER", "OCIS_URL"}, // WEB_UI_CONFIG_SERVER takes precedence over OCIS_URL EnvVars: []string{"WEB_UI_CONFIG_SERVER", "OCIS_URL"}, // WEB_UI_CONFIG_SERVER takes precedence over OCIS_URL
Destination: &cfg.Web.Config.Server, Destination: &cfg.Web.Config.Server,
}, },
&cli.StringFlag{
Name: "web-theme-server",
Value: flags.OverrideDefaultString(cfg.Web.Config.ThemeServer, "https://localhost:9200"),
Usage: "Theme server URL",
EnvVars: []string{"WEB_UI_THEME_SERVER", "OCIS_URL"}, // WEB_UI_CONFIG_SERVER takes precedence over OCIS_URL
Destination: &cfg.Web.Config.ThemeServer,
},
&cli.StringFlag{ &cli.StringFlag{
Name: "web-config-theme", Name: "web-config-theme",
Value: flags.OverrideDefaultString(cfg.Web.Config.Theme, "https://localhost:9200/themes/owncloud/theme.json"), Value: flags.OverrideDefaultString(cfg.Web.Config.ThemePath, "/themes/owncloud/theme.json"),
Usage: "Theme", Usage: "Theme path on the theme server",
EnvVars: []string{"WEB_UI_CONFIG_THEME"}, EnvVars: []string{"WEB_UI_THEME_PATH"},
Destination: &cfg.Web.Config.Theme, Destination: &cfg.Web.Config.ThemePath,
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "web-config-version", Name: "web-config-version",
+8
View File
@@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url"
"os" "os"
"strings" "strings"
"time" "time"
@@ -69,6 +70,13 @@ func (p Web) getPayload() (payload []byte, err error) {
p.config.Web.Config.Options["hideSearchBar"] = true p.config.Web.Config.Options["hideSearchBar"] = true
} }
// build theme url
if themeServer, err := url.Parse(p.config.Web.Config.ThemeServer); err == nil {
p.config.Web.Config.Theme = themeServer.String() + p.config.Web.Config.ThemePath
} else {
p.config.Web.Config.Theme = p.config.Web.Config.ThemePath
}
if p.config.Web.Config.ExternalApps == nil { if p.config.Web.Config.ExternalApps == nil {
p.config.Web.Config.ExternalApps = []config.ExternalApp{ p.config.Web.Config.ExternalApps = []config.ExternalApp{
{ {