MCPcopy Index your code
hub / github.com/apache/answer / html

Method html

internal/controller/template_controller.go:561–615  ·  view source on GitHub ↗
(ctx *gin.Context, code int, tpl string, siteInfo *schema.TemplateSiteInfoResp, data gin.H)

Source from the content-addressed store, hash-verified

559}
560
561func (tc *TemplateController) html(ctx *gin.Context, code int, tpl string, siteInfo *schema.TemplateSiteInfoResp, data gin.H) {
562 prefix := ""
563 cssPath := ""
564 scriptPath := make([]string, len(tc.scriptPath))
565
566 _ = plugin.CallCDN(func(fn plugin.CDN) error {
567 prefix = fn.GetStaticPrefix()
568 return nil
569 })
570
571 if prefix != "" {
572 if prefix[len(prefix)-1:] == "/" {
573 prefix = strings.TrimSuffix(prefix, "/")
574 }
575 cssPath = prefix + tc.cssPath
576 for i, path := range tc.scriptPath {
577 scriptPath[i] = prefix + path
578 }
579 } else {
580 cssPath = tc.cssPath
581 scriptPath = tc.scriptPath
582 }
583
584 data["siteinfo"] = siteInfo
585 data["baseURL"] = ""
586 if parsedUrl, err := url.Parse(siteInfo.General.SiteUrl); err == nil {
587 data["baseURL"] = parsedUrl.Path
588 }
589 data["scriptPath"] = scriptPath
590 data["cssPath"] = cssPath
591 data["keywords"] = siteInfo.Keywords
592 if siteInfo.Description == "" {
593 siteInfo.Description = siteInfo.General.Description
594 }
595 data["title"] = siteInfo.Title
596 if siteInfo.Title == "" {
597 data["title"] = siteInfo.General.Name
598 }
599 data["description"] = siteInfo.Description
600 data["language"] = handler.GetLangByCtx(ctx)
601 data["timezone"] = siteInfo.Interface.TimeZone
602 language := strings.ReplaceAll(siteInfo.Interface.Language, "_", "-")
603 data["lang"] = language
604 data["HeadCode"] = siteInfo.CustomCssHtml.CustomHead
605 data["HeaderCode"] = siteInfo.CustomCssHtml.CustomHeader
606 data["FooterCode"] = siteInfo.CustomCssHtml.CustomFooter
607 data["Version"] = constant.Version
608 data["Revision"] = constant.Revision
609 _, ok := data["path"]
610 if !ok {
611 data["path"] = ""
612 }
613 ctx.Header("X-Frame-Options", "DENY")
614 ctx.HTML(code, tpl, data)
615}
616
617func (tc *TemplateController) OpenSearch(ctx *gin.Context) {
618 if tc.checkPrivateMode(ctx) {

Callers 7

IndexMethod · 0.95
QuestionListMethod · 0.95
QuestionInfoMethod · 0.95
TagListMethod · 0.95
TagInfoMethod · 0.95
UserInfoMethod · 0.95
Page404Method · 0.95

Calls 3

GetLangByCtxFunction · 0.92
GetStaticPrefixMethod · 0.80
ParseMethod · 0.80

Tested by

no test coverage detected