diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 0614bcf167..d8e3f90777 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -812,6 +812,10 @@ manage_themes = Default theme manage_openid = OpenID addresses email_desc = Your primary email address will be used for notifications, password recovery and, provided that it is not hidden, web-based Git operations. theme_desc = This theme will be used for the web interface when you are logged in. +theme_recommended = Recommended +theme_light = Light +theme_dark = Dark +theme_auto = Auto (per system) primary = Primary activated = Activated requires_activation = Requires activation diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index e0ce88b582..d76dfc111a 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -19,6 +19,7 @@ import ( "forgejo.org/models/db" "forgejo.org/models/organization" repo_model "forgejo.org/models/repo" + "forgejo.org/models/theme" user_model "forgejo.org/models/user" "forgejo.org/modules/base" "forgejo.org/modules/log" @@ -335,15 +336,15 @@ func Repos(ctx *context.Context) { func Appearance(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings.appearance") ctx.Data["PageIsSettingsAppearance"] = true - ctx.Data["AllThemes"] = setting.UI.Themes - ctx.Data["ThemeName"] = func(themeName string) string { - fullThemeName := "themes.names." + themeName - if ctx.Locale.HasKey(fullThemeName) { - return ctx.Locale.TrString(fullThemeName) - } - return themeName + + themes, err := theme.GetThemes() + if err != nil { + ctx.ServerError("Failed to load themes", err) + return } + ctx.Data["AllThemes"] = themes + var hiddenCommentTypes *big.Int val, err := user_model.GetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes) if err != nil { diff --git a/templates/user/settings/appearance.tmpl b/templates/user/settings/appearance.tmpl index df4d6f3999..a0db0eb9c6 100644 --- a/templates/user/settings/appearance.tmpl +++ b/templates/user/settings/appearance.tmpl @@ -7,37 +7,64 @@
-
- {{ctx.Locale.Tr "settings.theme_desc"}} -
- -
- {{.CsrfTokenHtml}} -
- - + {{$theme := index .AllThemes $.SignedUser.Theme}} + {{if $theme.Author}} +
+

+ {{$theme.Name}} + by {{$theme.Author}} {{if $theme.Recommended}}{{svg "octicon-verified" 16 "dropdown icon"}}{{end}} +

+ {{if $theme.Description}} +

"{{$theme.Description}}"

+ {{end}}
-
- -
- +
+ {{ctx.Locale.Tr "settings.theme_desc"}} +
+ {{else}} +
+ {{ctx.Locale.Tr "settings.theme_desc"}} +
+ {{end}} + +
+ {{.CsrfTokenHtml}} +
+ + +
+ +
+ +
+