add usercode

This commit is contained in:
aichy126 2022-12-14 17:09:33 +08:00
parent aa6524a246
commit ba18289fcd
8 changed files with 80 additions and 18 deletions

View File

@ -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": {

View File

@ -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": {

View File

@ -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:

View File

@ -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"] = ""

View File

@ -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

View File

@ -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>

View File

@ -11,6 +11,6 @@
</footer>
</div>
</body>
{{templateHTML .FooterCode}}
</html>
{{end}}

View File

@ -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">