fix首页markdown

This commit is contained in:
deepzz0
2016-10-11 00:43:11 +08:00
parent 0dc40d518b
commit 03e0609790
8 changed files with 22 additions and 9 deletions

View File

@@ -9,4 +9,5 @@ vendor
vendor/**
*.go
*.sh
setting
*.DS_Store
setting

View File

@@ -11,7 +11,7 @@ pagenum: 10
# 管理界面
pagesize: 20
# 自动截取预览, 字符数
length: 200
length: 400
# 截取预览标识
identifier: <!--more-->
# favicon

16
db.go
View File

@@ -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("</nav></div>")
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)))
}
// 读取草稿箱

View File

@@ -115,6 +115,8 @@ type Article struct {
Prev *Article `bson:"-"`
// 下篇文章
Next *Article `bson:"-"`
// Header
Header string `bson:"-"`
// 预览信息
Excerpt string `bson:"-"`
}

View File

@@ -1 +1 @@
{{define "about"}}<div id=content class=inner>{{with .Article}}<article class="post post-{{.ID}}" itemscope itemtype="http://schema.org/Article"><h1 class=title itemprop=headline>{{.Title}}</h1><div class="entry-content" itemprop=articleBody>{{str2html .Content}}</div></article><section id=comments><h1 class=title>Comments<span id=switch_thread_mode></h1><div id=disqus_thread class=ds-thread data-identifier="post-{{.Slug}}" data-url="https://{{$.Domain}}/post/{{.Slug}}.html"></div><div id=simple_thread data-id="golomb-coded-sets"></div></section>{{end}}</div>{{end}}
{{define "about"}}<div id=content class=inner>{{with .Article}}<article class="post post-{{.ID}}" itemscope itemtype="http://schema.org/Article"><h1 class=title itemprop=headline>{{.Title}}</h1><div class="entry-content" itemprop=articleBody>{{str2html .Header}}{{str2html .Content}}</div></article><section id=comments><h1 class=title>Comments<span id=switch_thread_mode></h1><div id=disqus_thread class=ds-thread data-identifier="post-{{.Slug}}" data-url="https://{{$.Domain}}/post/{{.Slug}}.html"></div><div id=simple_thread data-id="golomb-coded-sets"></div></section>{{end}}</div>{{end}}

View File

@@ -1 +1 @@
{{define "archives"}}<div id=content class=inner><article class="post post-archives"><h1 class=title>归档</h1><div class="entry-content">{{str2html .Article}}</div></article></div>{{end}}
{{define "archives"}}<div id=content class=inner><article class="post post-archives"><h1 class=title>归档</h1><div class="entry-content">{{str2html .Article}}</div></article></div>{{end}}

View File

@@ -1 +1 @@
{{define "article"}}<div id=content class=inner>{{with .Article}}<article class="post post-{{.ID}}" itemscope itemtype="http://schema.org/Article"><div class=meta><div class=date><time itemprop=datePublished content="{{dateformat .CreateTime " 2006-01-02 "}}">{{dateformat .CreateTime "Jan 02, 2006"}}</time></div><div class=comment><a href="#comments">{{.Count}} Comments</a></div></div><h1 class=title itemprop=headline>{{.Title}}</h1><div class="entry-content" itemprop=articleBody>{{str2html .Content}}<p>本文链接:<a rel="bookmark" title="Permalink to {{.Title}}" href="//{{$.Domain}}/post/{{.Slug}}.html" itemprop="url">https://{{$.Domain}}/post/{{.Slug}}.html</a><a href="//{{$.Domain}}/post/{{.Slug}}.html#comments">参与评论 »</a></p><p>--<acronym title="End of File">EOF</acronym>--</p><p class="post-info">发表于 <span class="date">{{dateformat .CreateTime "2006-01-02 15:04:05"}}</span>{{if gt (.Tags|len) 0}},并被添加「{{range $index, $elem := .Tags}}{{if gt $index 0}}、{{end}}<a href="/search.html?q=tag:{{$elem}}">{{$elem}}</a>{{end}}」标签{{end}}{{if .UpdateTime|isnotzero}},最后修改于 <span class="date">{{dateformat .UpdateTime "2006-01-02 15:04:05"}}</span>{{end}}。</p>{{with $.Copyright}}<p class="copyright-info">{{str2html $.Copyright}}<a href="//{{$.Domain}}/post/about.html#toc-1">更多说明 »</a></p>{{end}}{{if gt $.Days 100}}<p class="expire-tips">提醒:本文最后更新于 {{$.Days}} 天前,文中所描述的信息可能已发生改变,请谨慎使用。</p>{{end}}{{with $.Serie}}<div class="entry-series"><h3>专题「{{.Name}}」的其它文章 <a href="/series.html#toc-{{.ID}}" title="更多">»</a></h3><ul>{{range .Articles}}{{if ne .ID $.Article.ID}}<li><a href="/post/{{.Slug}}.html">{{.Title}}</a> <span class="date">({{dateformat .CreateTime "Jan 02, 2006"}})</span></li>{{end}}{{end}}</ul></div>{{end}}</div></article><nav class="page-navi">{{with .Prev}}<a href="/post/{{.Slug}}.html" class=prev>« {{.Title}}</a>{{end}}{{with .Next}}<a href="/post/{{.Slug}}.html" class=next>{{.Title}} »</a>{{end}}</nav><section id=comments><h1 class=title>Comments<span id=switch_thread_mode></h1><div id=disqus_thread class=ds-thread data-identifier="post-{{.Slug}}" data-url="https://{{$.Domain}}/post/{{.Slug}}.html"></div><div id=simple_thread data-id="{{.Slug}}"></div></section>{{end}}</div>{{end}}
{{define "article"}}<div id=content class=inner>{{with .Article}}<article class="post post-{{.ID}}" itemscope itemtype="http://schema.org/Article"><div class=meta><div class=date><time itemprop=datePublished content="{{dateformat .CreateTime " 2006-01-02 "}}">{{dateformat .CreateTime "Jan 02, 2006"}}</time></div><div class=comment><a href="#comments">{{.Count}} Comments</a></div></div><h1 class=title itemprop=headline>{{.Title}}</h1><div class="entry-content" itemprop=articleBody>{{str2html .Header}}{{str2html .Content}}<p>本文链接:<a rel="bookmark" title="Permalink to {{.Title}}" href="//{{$.Domain}}/post/{{.Slug}}.html" itemprop="url">https://{{$.Domain}}/post/{{.Slug}}.html</a><a href="//{{$.Domain}}/post/{{.Slug}}.html#comments">参与评论 »</a></p><p>--<acronym title="End of File">EOF</acronym>--</p><p class="post-info">发表于 <span class="date">{{dateformat .CreateTime "2006-01-02 15:04:05"}}</span>{{if gt (.Tags|len) 0}},并被添加「{{range $index, $elem := .Tags}}{{if gt $index 0}}、{{end}}<a href="/search.html?q=tag:{{$elem}}">{{$elem}}</a>{{end}}」标签{{end}}{{if .UpdateTime|isnotzero}},最后修改于 <span class="date">{{dateformat .UpdateTime "2006-01-02 15:04:05"}}</span>{{end}}。</p>{{with $.Copyright}}<p class="copyright-info">{{str2html $.Copyright}}<a href="//{{$.Domain}}/post/about.html#toc-1">更多说明 »</a></p>{{end}}{{if gt $.Days 100}}<p class="expire-tips">提醒:本文最后更新于 {{$.Days}} 天前,文中所描述的信息可能已发生改变,请谨慎使用。</p>{{end}}{{with $.Serie}}<div class="entry-series"><h3>专题「{{.Name}}」的其它文章 <a href="/series.html#toc-{{.ID}}" title="更多">»</a></h3><ul>{{range .Articles}}{{if ne .ID $.Article.ID}}<li><a href="/post/{{.Slug}}.html">{{.Title}}</a> <span class="date">({{dateformat .CreateTime "Jan 02, 2006"}})</span></li>{{end}}{{end}}</ul></div>{{end}}</div></article><nav class="page-navi">{{with .Prev}}<a href="/post/{{.Slug}}.html" class=prev>« {{.Title}}</a>{{end}}{{with .Next}}<a href="/post/{{.Slug}}.html" class=next>{{.Title}} »</a>{{end}}</nav><section id=comments><h1 class=title>Comments<span id=switch_thread_mode></h1><div id=disqus_thread class=ds-thread data-identifier="post-{{.Slug}}" data-url="https://{{$.Domain}}/post/{{.Slug}}.html"></div><div id=simple_thread data-id="{{.Slug}}"></div></section>{{end}}</div>{{end}}

View File

@@ -1 +1 @@
{{define "series"}}<div id=content class=inner><article class="post post-series"><h1 class=title>专题</h1><div class="entry-content">{{str2html .Article}}</div></article></div>{{end}}
{{define "series"}}<div id=content class=inner><article class="post post-series"><h1 class=title>专题</h1><div class="entry-content">{{str2html .Article}}</div></article></div>{{end}}