Load themes using the utilities
This commit is contained in:
parent
d741cacc00
commit
30c94deeaa
2 changed files with 16 additions and 7 deletions
|
@ -16,6 +16,7 @@ import (
|
|||
|
||||
_ "net/http/pprof" // Used for debugging if enabled and a web server is running
|
||||
|
||||
"forgejo.org/models/theme"
|
||||
"forgejo.org/modules/container"
|
||||
"forgejo.org/modules/graceful"
|
||||
"forgejo.org/modules/log"
|
||||
|
@ -217,6 +218,13 @@ func serveInstalled(_ context.Context, ctx *cli.Command) error {
|
|||
}
|
||||
}
|
||||
|
||||
// Load themes
|
||||
themes, tlerr := theme.GetThemeIds()
|
||||
if (tlerr != nil) {
|
||||
log.Error("Failed to load themes: ", tlerr)
|
||||
}
|
||||
setting.UI.Themes = themes
|
||||
|
||||
// Set up Chi routes
|
||||
webRoutes := routers.NormalRoutes()
|
||||
err := listen(webRoutes, true)
|
||||
|
|
|
@ -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"
|
||||
|
@ -329,15 +330,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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue