mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-04 13:52:26 +08:00
fix首页markdown
This commit is contained in:
@@ -9,4 +9,5 @@ vendor
|
||||
vendor/**
|
||||
*.go
|
||||
*.sh
|
||||
*.DS_Store
|
||||
setting
|
||||
@@ -11,7 +11,7 @@ pagenum: 10
|
||||
# 管理界面
|
||||
pagesize: 20
|
||||
# 自动截取预览, 字符数
|
||||
length: 200
|
||||
length: 400
|
||||
# 截取预览标识
|
||||
identifier: <!--more-->
|
||||
# favicon
|
||||
|
||||
16
db.go
16
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("</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)))
|
||||
}
|
||||
|
||||
// 读取草稿箱
|
||||
|
||||
2
model.go
2
model.go
@@ -115,6 +115,8 @@ type Article struct {
|
||||
Prev *Article `bson:"-"`
|
||||
// 下篇文章
|
||||
Next *Article `bson:"-"`
|
||||
// Header
|
||||
Header string `bson:"-"`
|
||||
// 预览信息
|
||||
Excerpt string `bson:"-"`
|
||||
}
|
||||
|
||||
@@ -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}}
|
||||
|
||||
@@ -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}}
|
||||
|
||||
Reference in New Issue
Block a user