1、完善日志配置

2、文章自动生成摘要
3、修正文档名称问题
4、修复Redis无法读取缓存的BUG
This commit is contained in:
lifei6671
2018-07-25 14:46:56 +08:00
parent 774530bbc2
commit 1cbdd4baca
11 changed files with 226 additions and 73 deletions

View File

@@ -15,6 +15,7 @@ import (
"github.com/astaxie/beego/orm"
"html/template"
"encoding/json"
"github.com/lifei6671/mindoc/utils"
)
type BlogController struct{
@@ -58,6 +59,13 @@ func (c *BlogController) Index() {
c.Data["Model"] = blog
c.Data["Content"] = template.HTML(blog.BlogRelease)
if blog.BlogExcerpt == "" {
c.Data["Description"] = utils.AutoSummary(blog.BlogRelease,120)
}else{
c.Data["Description"] = blog.BlogExcerpt
}
if nextBlog,err := models.NewBlog().QueryNext(blogId);err == nil {
c.Data["Next"] = nextBlog
}
@@ -86,6 +94,10 @@ func (c *BlogController) List() {
pager := pagination.NewPagination(c.Ctx.Request, totalCount, conf.PageSize, c.BaseUrl())
c.Data["PageHtml"] = pager.HtmlPages()
for _,blog := range blogList {
//如果没有添加文章摘要,则自动提取
if blog.BlogExcerpt == "" {
blog.BlogExcerpt = utils.AutoSummary(blog.BlogRelease,120)
}
blog.Link()
}
} else {

View File

@@ -70,6 +70,7 @@ func (c *DocumentController) Index() {
c.Data["Title"] = doc.DocumentName
c.Data["Content"] = template.HTML(doc.Release)
c.Data["Description"] = utils.AutoSummary(doc.Release,120)
}
}else {
c.Data["Title"] = "概要"
@@ -208,6 +209,10 @@ func (c *DocumentController) Read() {
c.Abort("500")
}
c.Data["Description"] = utils.AutoSummary(doc.Release,120)
c.Data["Model"] = bookResult
c.Data["Result"] = template.HTML(tree)
c.Data["Title"] = doc.DocumentName