diff --git a/.dockerignore b/.dockerignore index c5e3e21..ede0043 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,4 +9,5 @@ vendor vendor/** *.go *.sh -setting \ No newline at end of file +*.DS_Store +setting diff --git a/conf/app.yml b/conf/app.yml index cf0b79f..927265a 100644 --- a/conf/app.yml +++ b/conf/app.yml @@ -11,7 +11,7 @@ pagenum: 10 # 管理界面 pagesize: 20 # 自动截取预览, 字符数 -length: 200 +length: 400 # 截取预览标识 identifier: # favicon diff --git a/db.go b/db.go index 3d5d571..8e5dd40 100644 --- a/db.go +++ b/db.go @@ -351,9 +351,20 @@ func ManageArchivesArticle(artc *Article, s bool, do string) { // 渲染markdown操作和截取摘要操作 var reg = regexp.MustCompile(setting.Conf.Identifier) +// header +var regH = regexp.MustCompile("") + func GenerateExcerptAndRender(artc *Article) { - index := reg.FindStringIndex(artc.Content) - if len(index) > 0 { + content := renderPage([]byte(artc.Content)) + index := regH.FindIndex(content) + if index != nil { + artc.Header = string(content[0:index[1]]) + artc.Content = string(content[index[1]:]) + } else { + artc.Content = string(content) + } + index = reg.FindStringIndex(artc.Content) + if index != nil { artc.Excerpt = IgnoreHtmlTag(artc.Content[0:index[0]]) } else { uc := []rune(artc.Content) @@ -363,7 +374,6 @@ func GenerateExcerptAndRender(artc *Article) { } artc.Excerpt = IgnoreHtmlTag(string(uc[0:length])) } - artc.Content = string(renderPage([]byte(artc.Content))) } // 读取草稿箱 diff --git a/model.go b/model.go index b225cf6..83f2f8c 100644 --- a/model.go +++ b/model.go @@ -115,6 +115,8 @@ type Article struct { Prev *Article `bson:"-"` // 下篇文章 Next *Article `bson:"-"` + // Header + Header string `bson:"-"` // 预览信息 Excerpt string `bson:"-"` } diff --git a/views/about.html b/views/about.html index e50438d..71cc47a 100644 --- a/views/about.html +++ b/views/about.html @@ -1 +1 @@ -{{define "about"}}
本文链接:https://{{$.Domain}}/post/{{.Slug}}.html,参与评论 »
--EOF--
发表于 {{dateformat .CreateTime "2006-01-02 15:04:05"}}{{if gt (.Tags|len) 0}},并被添加「{{range $index, $elem := .Tags}}{{if gt $index 0}}、{{end}}{{$elem}}{{end}}」标签{{end}}{{if .UpdateTime|isnotzero}},最后修改于 {{dateformat .UpdateTime "2006-01-02 15:04:05"}}{{end}}。
{{with $.Copyright}}{{str2html $.Copyright}}更多说明 »
{{end}}{{if gt $.Days 100}}提醒:本文最后更新于 {{$.Days}} 天前,文中所描述的信息可能已发生改变,请谨慎使用。
{{end}}{{with $.Serie}}本文链接:https://{{$.Domain}}/post/{{.Slug}}.html,参与评论 »
--EOF--
发表于 {{dateformat .CreateTime "2006-01-02 15:04:05"}}{{if gt (.Tags|len) 0}},并被添加「{{range $index, $elem := .Tags}}{{if gt $index 0}}、{{end}}{{$elem}}{{end}}」标签{{end}}{{if .UpdateTime|isnotzero}},最后修改于 {{dateformat .UpdateTime "2006-01-02 15:04:05"}}{{end}}。
{{with $.Copyright}}{{str2html $.Copyright}}更多说明 »
{{end}}{{if gt $.Days 100}}提醒:本文最后更新于 {{$.Days}} 天前,文中所描述的信息可能已发生改变,请谨慎使用。
{{end}}{{with $.Serie}}
Comments