diff --git a/docs/docs.go b/docs/docs.go index 0f7f6559..e0fab59c 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -4865,6 +4865,26 @@ const docTemplate = `{ } } }, + "/custom.css": { + "get": { + "description": "get site robots information", + "produces": [ + "application/json" + ], + "tags": [ + "site" + ], + "summary": "get site robots information", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + } + } + }, "/installation/base-info": { "post": { "description": "init base info", @@ -6944,7 +6964,7 @@ const docTemplate = `{ "login": { "$ref": "#/definitions/schema.SiteLoginResp" }, - "siteseo": { + "site_seo": { "$ref": "#/definitions/schema.SiteSeoReq" }, "theme": { diff --git a/docs/swagger.json b/docs/swagger.json index e34b4227..c117ec39 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -4853,6 +4853,26 @@ } } }, + "/custom.css": { + "get": { + "description": "get site robots information", + "produces": [ + "application/json" + ], + "tags": [ + "site" + ], + "summary": "get site robots information", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + } + } + }, "/installation/base-info": { "post": { "description": "init base info", @@ -6932,7 +6952,7 @@ "login": { "$ref": "#/definitions/schema.SiteLoginResp" }, - "siteseo": { + "site_seo": { "$ref": "#/definitions/schema.SiteSeoReq" }, "theme": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 5e7b8ccd..e3c68553 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1292,7 +1292,7 @@ definitions: $ref: '#/definitions/schema.SiteInterfaceResp' login: $ref: '#/definitions/schema.SiteLoginResp' - siteseo: + site_seo: $ref: '#/definitions/schema.SiteSeoReq' theme: $ref: '#/definitions/schema.SiteThemeResp' @@ -4814,6 +4814,19 @@ paths: summary: vote up tags: - Activity + /custom.css: + get: + description: get site robots information + produces: + - application/json + responses: + "200": + description: OK + schema: + type: string + summary: get site robots information + tags: + - site /installation/base-info: post: consumes: diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.go index bfc2299f..384640d4 100644 --- a/internal/controller/template_controller.go +++ b/internal/controller/template_controller.go @@ -81,6 +81,10 @@ func (tc *TemplateController) SiteInfo(ctx *gin.Context) *schema.TemplateSiteInf log.Error(err) } + resp.CustomCssHtml, err = tc.siteInfoService.GetSiteCustomCssHTML(ctx) + if err != nil { + log.Error(err) + } resp.Year = fmt.Sprintf("%d", time.Now().Year()) return resp } @@ -414,6 +418,9 @@ func (tc *TemplateController) html(ctx *gin.Context, code int, tpl string, siteI data["description"] = siteInfo.Description data["language"] = handler.GetLang(ctx) data["timezone"] = siteInfo.Interface.TimeZone + data["HeadCode"] = siteInfo.CustomCssHtml.CustomHead + data["HeaderCode"] = siteInfo.CustomCssHtml.CustomHeader + data["FooterCode"] = siteInfo.CustomCssHtml.CustomFooter _, ok := data["path"] if !ok { data["path"] = "" diff --git a/internal/schema/siteinfo_schema.go b/internal/schema/siteinfo_schema.go index 1c1e068b..c97ddc9f 100644 --- a/internal/schema/siteinfo_schema.go +++ b/internal/schema/siteinfo_schema.go @@ -140,16 +140,17 @@ type SiteInfoResp struct { SiteSeo *SiteSeoReq `json:"site_seo"` } type TemplateSiteInfoResp struct { - General *SiteGeneralResp `json:"general"` - Interface *SiteInterfaceResp `json:"interface"` - Branding *SiteBrandingResp `json:"branding"` - SiteSeo *SiteSeoReq `json:"site_seo"` - Title string - Year string - Canonical string - JsonLD string - Keywords string - Description string + General *SiteGeneralResp `json:"general"` + Interface *SiteInterfaceResp `json:"interface"` + Branding *SiteBrandingResp `json:"branding"` + SiteSeo *SiteSeoReq `json:"site_seo"` + CustomCssHtml *SiteCustomCssHTMLResp `json:"custom_css_html"` + Title string + Year string + Canonical string + JsonLD string + Keywords string + Description string } // UpdateSMTPConfigReq get smtp config request diff --git a/ui/build/index.html b/ui/build/index.html index 430813a0..716dba25 100644 --- a/ui/build/index.html +++ b/ui/build/index.html @@ -5,10 +5,10 @@ <meta name="viewport" content="width=device-width,initial-scale=1" /> <meta name="theme-color" content="#000000" /> <link rel="manifest" href="/manifest.json" /> - <link href="/custom.css" rel="stylesheet"> <title>Answer</title> <script defer="defer" src="/static/js/main.9de9552b.js"></script> - <link href="/static/css/main.d4180d41.css" rel="stylesheet" /> + <link href="/static/css/main.d4180d41.css" rel="stylesheet"> + <link href="/custom.css" rel="stylesheet"> {{.HeadCode}} </head> <body> diff --git a/ui/template/footer.html b/ui/template/footer.html index f83ed4f5..28115406 100644 --- a/ui/template/footer.html +++ b/ui/template/footer.html @@ -11,6 +11,6 @@ </footer> </div> </body> - +{{templateHTML .FooterCode}} </html> {{end}} diff --git a/ui/template/header.html b/ui/template/header.html index 17013bcd..2346e3ed 100644 --- a/ui/template/header.html +++ b/ui/template/header.html @@ -11,13 +11,14 @@ <link rel="canonical" href="{{.siteinfo.Canonical}}" /> <link rel="manifest" href="/manifest.json"/> <link href="{{.cssPath}}" rel="stylesheet" /> + <link href="/custom.css" rel="stylesheet"> <script defer="defer" src="{{.scriptPath}}"></script> + {{templateHTML .HeadCode}} {{if $.siteinfo.JsonLD }}{{ .siteinfo.JsonLD | templateHTML}}{{end}} </head> <body> - - +{{templateHTML .HeaderCode}} <noscript>You need to enable JavaScript to run this app.</noscript> <div id="root"> <nav id="header" class="sticky-top navbar navbar-expand-lg navbar-dark">