diff --git a/modules/theme/theme.go b/modules/theme/theme.go index 762926d78f..370e02592c 100644 --- a/modules/theme/theme.go +++ b/modules/theme/theme.go @@ -16,6 +16,8 @@ const ( key string = "load-themes" ) +var FriendlyThemes map[string]string + var ( group singleflight.Group assetFs *assetfs.LayeredFS @@ -42,6 +44,7 @@ func LoadThemes() error { group.Forget(key) } else { setting.UI.Themes = themes + FriendlyThemes = convertToFriendly(themes) loaded = true } @@ -78,3 +81,20 @@ func loadThemesInner(assetFs *assetfs.LayeredFS) ([]string, error) { return nil, fmt.Errorf("no themes found") } } + +func convertToFriendly(themes []string) map[string]string { + themesFriendly := make(map[string]string) + + for _, theme := range themes { + friendly := theme + + friendly = strings.ReplaceAll(friendly, "-", " ") + + friendly = strings.ToLower(friendly) + friendly = strings.Title(friendly) + + themesFriendly[theme] = friendly + } + + return themesFriendly +} diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index 18ad2bf10c..8513caf7c7 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -332,6 +332,7 @@ func Appearance(ctx *context.Context) { } ctx.Data["AllThemes"] = setting.UI.Themes + ctx.Data["FriendlyThemes"] = theme.FriendlyThemes ctx.Data["Title"] = ctx.Tr("settings.appearance") ctx.Data["PageIsSettingsAppearance"] = true diff --git a/templates/user/settings/appearance.tmpl b/templates/user/settings/appearance.tmpl index 3315b7f32e..fb56edf34f 100644 --- a/templates/user/settings/appearance.tmpl +++ b/templates/user/settings/appearance.tmpl @@ -15,20 +15,19 @@