From 7bd47c651c6e8b267a58f2b573bfda9f21d6f6af Mon Sep 17 00:00:00 2001 From: cj <72030708+Teda1@users.noreply.github.com> Date: Wed, 9 Mar 2022 15:24:13 -0600 Subject: [PATCH] Read theme color from config file (#2365) * read theme color from config file * Update manual page --- pkg/api/server.go | 4 +++- pkg/manager/config/config.go | 9 +++++++++ ui/v2.5/index.html | 2 +- ui/v2.5/src/components/Changelog/versions/v0140.md | 1 + ui/v2.5/src/docs/en/Configuration.md | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/api/server.go b/pkg/api/server.go index cf5f4041a..b162312d3 100644 --- a/pkg/api/server.go +++ b/pkg/api/server.go @@ -206,13 +206,15 @@ func Start(uiBox embed.FS, loginUIBox embed.FS) { } if ext == ".html" || ext == "" { + themeColor := c.GetThemeColor() data, err := uiBox.ReadFile(uiRootDir + "/index.html") if err != nil { panic(err) } prefix := getProxyPrefix(r.Header) - baseURLIndex := strings.ReplaceAll(string(data), "/%BASE_URL%", prefix) + baseURLIndex := strings.ReplaceAll(string(data), "%COLOR%", themeColor) + baseURLIndex = strings.ReplaceAll(baseURLIndex, "/%BASE_URL%", prefix) baseURLIndex = strings.Replace(baseURLIndex, "base href=\"/\"", fmt.Sprintf("base href=\"%s\"", prefix+"/"), 1) _, _ = w.Write([]byte(baseURLIndex)) } else { diff --git a/pkg/manager/config/config.go b/pkg/manager/config/config.go index 07780db8c..9af0070a0 100644 --- a/pkg/manager/config/config.go +++ b/pkg/manager/config/config.go @@ -151,6 +151,9 @@ const ( HandyKey = "handy_key" FunscriptOffset = "funscript_offset" + ThemeColor = "theme_color" + DefaultThemeColor = "#202b33" + // Security dangerousAllowPublicWithoutAuth = "dangerous_allow_public_without_auth" dangerousAllowPublicWithoutAuthDefault = "false" @@ -619,6 +622,10 @@ func (i *Instance) GetPort() int { return ret } +func (i *Instance) GetThemeColor() string { + return i.getString(ThemeColor) +} + func (i *Instance) GetExternalHost() string { return i.getString(ExternalHost) } @@ -1175,6 +1182,8 @@ func (i *Instance) setDefaultValues(write bool) error { i.main.SetDefault(PreviewAudio, previewAudioDefault) i.main.SetDefault(SoundOnPreview, false) + i.main.SetDefault(ThemeColor, DefaultThemeColor) + i.main.SetDefault(WriteImageThumbnails, writeImageThumbnailsDefault) i.main.SetDefault(Database, defaultDatabaseFilePath) diff --git a/ui/v2.5/index.html b/ui/v2.5/index.html index f103a9650..5a1a71ce2 100755 --- a/ui/v2.5/index.html +++ b/ui/v2.5/index.html @@ -9,7 +9,7 @@ name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> - +