Skip to content

Commit 7bd47c6

Browse files
authored
Read theme color from config file (stashapp#2365)
* read theme color from config file * Update manual page
1 parent a059528 commit 7bd47c6

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

Diff for: pkg/api/server.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,15 @@ func Start(uiBox embed.FS, loginUIBox embed.FS) {
206206
}
207207

208208
if ext == ".html" || ext == "" {
209+
themeColor := c.GetThemeColor()
209210
data, err := uiBox.ReadFile(uiRootDir + "/index.html")
210211
if err != nil {
211212
panic(err)
212213
}
213214

214215
prefix := getProxyPrefix(r.Header)
215-
baseURLIndex := strings.ReplaceAll(string(data), "/%BASE_URL%", prefix)
216+
baseURLIndex := strings.ReplaceAll(string(data), "%COLOR%", themeColor)
217+
baseURLIndex = strings.ReplaceAll(baseURLIndex, "/%BASE_URL%", prefix)
216218
baseURLIndex = strings.Replace(baseURLIndex, "base href=\"/\"", fmt.Sprintf("base href=\"%s\"", prefix+"/"), 1)
217219
_, _ = w.Write([]byte(baseURLIndex))
218220
} else {

Diff for: pkg/manager/config/config.go

+9
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ const (
151151
HandyKey = "handy_key"
152152
FunscriptOffset = "funscript_offset"
153153

154+
ThemeColor = "theme_color"
155+
DefaultThemeColor = "#202b33"
156+
154157
// Security
155158
dangerousAllowPublicWithoutAuth = "dangerous_allow_public_without_auth"
156159
dangerousAllowPublicWithoutAuthDefault = "false"
@@ -619,6 +622,10 @@ func (i *Instance) GetPort() int {
619622
return ret
620623
}
621624

625+
func (i *Instance) GetThemeColor() string {
626+
return i.getString(ThemeColor)
627+
}
628+
622629
func (i *Instance) GetExternalHost() string {
623630
return i.getString(ExternalHost)
624631
}
@@ -1175,6 +1182,8 @@ func (i *Instance) setDefaultValues(write bool) error {
11751182
i.main.SetDefault(PreviewAudio, previewAudioDefault)
11761183
i.main.SetDefault(SoundOnPreview, false)
11771184

1185+
i.main.SetDefault(ThemeColor, DefaultThemeColor)
1186+
11781187
i.main.SetDefault(WriteImageThumbnails, writeImageThumbnailsDefault)
11791188

11801189
i.main.SetDefault(Database, defaultDatabaseFilePath)

Diff for: ui/v2.5/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
name="viewport"
1010
content="width=device-width, initial-scale=1, maximum-scale=1"
1111
/>
12-
<meta name="theme-color" content="#202b33" />
12+
<meta name="theme-color" content="%COLOR%" />
1313
<!--
1414
manifest.json provides metadata used when your web app is installed on a
1515
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/

Diff for: ui/v2.5/src/components/Changelog/versions/v0140.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
### 🎨 Improvements
2+
* Allow customisation of UI theme color using `theme_color` property in `config.yml` ([#2365](https://github.com/stashapp/stash/pull/2365))
23
* Improved autotag performance. ([#2368](https://github.com/stashapp/stash/pull/2368))

Diff for: ui/v2.5/src/docs/en/Configuration.md

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ These options are typically not exposed in the UI and must be changed manually i
120120
| `custom_served_folders` | A map of URLs to file system folders. See below. |
121121
| `custom_ui_location` | The file system folder where the UI files will be served from, instead of using the embedded UI. Empty to disable. Stash must be restarted to take effect. |
122122
| `max_upload_size` | Maximum file upload size for import files. Defaults to 1GB. |
123+
| `theme_color` | Sets the `theme-color` property in the UI. |
123124

124125
### Custom served folders
125126

0 commit comments

Comments
 (0)