From e306c292ac478c0f09b2c02908e485132669aacb Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Thu, 3 Dec 2020 06:53:21 -0600 Subject: [PATCH] Expose default theme in meta and API (#13809) Signed-off-by: jolheiser Co-authored-by: 6543 <6543@obermui.de> --- modules/structs/settings.go | 1 + routers/api/v1/settings/settings.go | 1 + templates/base/head.tmpl | 1 + templates/swagger/v1_json.tmpl | 4 ++++ 4 files changed, 7 insertions(+) diff --git a/modules/structs/settings.go b/modules/structs/settings.go index 6874d6705..0cb7b3284 100644 --- a/modules/structs/settings.go +++ b/modules/structs/settings.go @@ -12,6 +12,7 @@ type GeneralRepoSettings struct { // GeneralUISettings contains global ui settings exposed by API type GeneralUISettings struct { + DefaultTheme string `json:"default_theme"` AllowedReactions []string `json:"allowed_reactions"` } diff --git a/routers/api/v1/settings/settings.go b/routers/api/v1/settings/settings.go index 2b7b11bfd..c94a3141e 100644 --- a/routers/api/v1/settings/settings.go +++ b/routers/api/v1/settings/settings.go @@ -23,6 +23,7 @@ func GetGeneralUISettings(ctx *context.APIContext) { // "200": // "$ref": "#/responses/GeneralUISettings" ctx.JSON(http.StatusOK, api.GeneralUISettings{ + DefaultTheme: setting.UI.DefaultTheme, AllowedReactions: setting.UI.Reactions, }) } diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index c8e669387..953654504 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -7,6 +7,7 @@ {{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}} {{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} + diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index b121451ba..bf8467ff2 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -13523,6 +13523,10 @@ "type": "string" }, "x-go-name": "AllowedReactions" + }, + "default_theme": { + "type": "string", + "x-go-name": "DefaultTheme" } }, "x-go-package": "code.gitea.io/gitea/modules/structs"