From da4d034ad3d3255a3d46d8fc7bc7738e6f6b718c Mon Sep 17 00:00:00 2001 From: lifei6671 Date: Wed, 19 Sep 2018 16:12:32 +0800 Subject: [PATCH] =?UTF-8?q?perf:1=E3=80=81=E4=BC=98=E5=8C=96=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E8=84=9A=E6=9C=AC=E5=8A=9F=E8=83=BD=202?= =?UTF-8?q?=E3=80=81=E4=BC=98=E5=8C=96=E9=A1=B5=E9=9D=A2=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/BaseController.go | 12 +++++++----- views/account/login.tpl | 5 +++-- views/blog/index.tpl | 1 + views/blog/list.tpl | 13 ++++--------- views/document/default_read.tpl | 2 +- views/home/index.tpl | 12 ++++-------- views/label/index.tpl | 10 +++------- views/label/list.tpl | 9 +++------ views/search/index.tpl | 10 +++------- 9 files changed, 29 insertions(+), 45 deletions(-) diff --git a/controllers/BaseController.go b/controllers/BaseController.go index d9cce7e8..8c5edd10 100644 --- a/controllers/BaseController.go +++ b/controllers/BaseController.go @@ -12,8 +12,9 @@ import ( "github.com/lifei6671/mindoc/conf" "github.com/lifei6671/mindoc/models" "github.com/lifei6671/mindoc/utils" - "github.com/lifei6671/mindoc/utils/filetil" "path/filepath" + "io/ioutil" + "html/template" ) type BaseController struct { @@ -69,13 +70,14 @@ func (c *BaseController) Prepare() { c.Option[item.OptionName] = item.OptionValue } c.EnableAnonymous = strings.EqualFold(c.Option["ENABLE_ANONYMOUS"], "true") - c.EnableDocumentHistory = strings.EqualFold(c.Option["ENABLE_DOCUMENT_HISTORY"],"true") + c.EnableDocumentHistory = strings.EqualFold(c.Option["ENABLE_DOCUMENT_HISTORY"], "true") } - c.Data["HighlightStyle"] = beego.AppConfig.DefaultString("highlight_style","github") + c.Data["HighlightStyle"] = beego.AppConfig.DefaultString("highlight_style", "github") - if filetil.FileExists(filepath.Join(beego.BConfig.WebConfig.ViewsPath,"widgets","scripts.tpl")) { - c.LayoutSections["Scripts"] = "widgets/scripts.tpl" + if b, err := ioutil.ReadFile(filepath.Join(beego.BConfig.WebConfig.ViewsPath, "widgets", "scripts.tpl")); err == nil { + c.Data["Scripts0"] = template.HTML(string(b)) } + } // SetMember 获取或设置当前登录用户信息,如果 MemberId 小于 0 则标识删除 Session diff --git a/views/account/login.tpl b/views/account/login.tpl index 362ff4d4..8766a32e 100644 --- a/views/account/login.tpl +++ b/views/account/login.tpl @@ -6,9 +6,10 @@ - + 用户登录 - Powered by MinDoc - + + diff --git a/views/blog/index.tpl b/views/blog/index.tpl index 03ddb3f1..403a758e 100644 --- a/views/blog/index.tpl +++ b/views/blog/index.tpl @@ -129,5 +129,6 @@ +{{.Scripts}} \ No newline at end of file diff --git a/views/blog/list.tpl b/views/blog/list.tpl index 46660209..d4567c02 100644 --- a/views/blog/list.tpl +++ b/views/blog/list.tpl @@ -4,20 +4,14 @@ - 文章列表 - Powered by MinDoc - + + - - - - +