新增了在每篇文档标题下显示原始作者、创建时间和最后更新时间的功能。

This commit is contained in:
Dandy Cheung
2017-12-20 16:16:41 +08:00
parent 789d46c340
commit 292cf049e2
5 changed files with 130 additions and 99 deletions

View File

@@ -16,8 +16,6 @@ import (
"bytes" "bytes"
"log"
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
"github.com/astaxie/beego" "github.com/astaxie/beego"
"github.com/astaxie/beego/orm" "github.com/astaxie/beego/orm"
@@ -127,9 +125,10 @@ func (c *DocumentController) Index() {
c.Data["Result"] = template.HTML(tree) c.Data["Result"] = template.HTML(tree)
c.Data["Title"] = "概要" c.Data["Title"] = "概要"
c.Data["Content"] = template.HTML(blackfriday.MarkdownBasic([]byte(bookResult.Description))) c.Data["Content"] = template.HTML(blackfriday.MarkdownBasic([]byte(bookResult.Description)))
c.Data["Info"] = ""
c.Data["DocumentId"] = "0" // added by dandycheung, 2017-12-08, for exporting c.Data["DocumentId"] = "0" // added by dandycheung, 2017-12-08, for exporting
log.Println("DocumentController.Index(): c.Data[\"DocumentId\"] = ", 0) beego.Info("DocumentController.Index(): c.Data[\"DocumentId\"] = ", 0)
} }
//阅读文档. //阅读文档.
@@ -140,7 +139,7 @@ func (c *DocumentController) Read() {
id := c.GetString(":id") id := c.GetString(":id")
c.Data["DocumentId"] = id // added by dandycheung, 2017-12-08, for exporting c.Data["DocumentId"] = id // added by dandycheung, 2017-12-08, for exporting
log.Println("DocumentController.Read(): c.Data[\"DocumentId\"] = ", id, ", IsAjax = ", c.IsAjax()) beego.Info("DocumentController.Read(): c.Data[\"DocumentId\"] = ", id, ", IsAjax = ", c.IsAjax())
if identify == "" || id == "" { if identify == "" || id == "" {
c.Abort("404") c.Abort("404")
@@ -200,15 +199,33 @@ func (c *DocumentController) Read() {
} }
} }
// assemble doc info, added by dandycheung, 2017-12-20
docInfo := ""
docCreator, err := models.NewMember().Find(doc.MemberId)
if err == nil {
docInfo += docCreator.Account
}
docInfo += " 创建于 "
docInfo += doc.CreateTime.Format("2006-01-02 15:04")
if doc.ModifyTime != doc.CreateTime {
docInfo += ";更新于 "
docInfo += doc.ModifyTime.Format("2006-01-02 15:04")
}
if c.IsAjax() { if c.IsAjax() {
var data struct { var data struct {
DocTitle string `json:"doc_title"` DocTitle string `json:"doc_title"`
Body string `json:"body"` Body string `json:"body"`
Title string `json:"title"` Title string `json:"title"`
DocInfo string `json:"doc_info"`
} }
data.DocTitle = doc.DocumentName data.DocTitle = doc.DocumentName
data.Body = doc.Release data.Body = doc.Release
data.Title = doc.DocumentName + " - Powered by MinDoc" data.Title = doc.DocumentName + " - Powered by MinDoc"
data.DocInfo = docInfo
c.JsonResult(0, "ok", data) c.JsonResult(0, "ok", data)
} }
@@ -223,6 +240,7 @@ func (c *DocumentController) Read() {
c.Data["Model"] = bookResult c.Data["Model"] = bookResult
c.Data["Result"] = template.HTML(tree) c.Data["Result"] = template.HTML(tree)
c.Data["Title"] = doc.DocumentName c.Data["Title"] = doc.DocumentName
c.Data["Info"] = docInfo
c.Data["Content"] = template.HTML(doc.Release) c.Data["Content"] = template.HTML(doc.Release)
} }
@@ -1188,7 +1206,7 @@ func RecursiveFun(parent_id int, prefix, dpath string, c *DocumentController, bo
for _, sub := range docs { for _, sub := range docs {
if sub.ParentId == item.DocumentId { if sub.ParentId == item.DocumentId {
prefix += strconv.Itoa(item.ParentId) + strconv.Itoa(item.OrderSort) + strconv.Itoa(item.DocumentId); prefix += strconv.Itoa(item.ParentId) + strconv.Itoa(item.OrderSort) + strconv.Itoa(item.DocumentId)
RecursiveFun(item.DocumentId, prefix, dpath, c, book, docs, paths) RecursiveFun(item.DocumentId, prefix, dpath, c, book, docs, paths)
break break
} }

View File

@@ -34,7 +34,6 @@ func init() {
beego.Router("/manager/attach/detailed/:id", &controllers.ManagerController{}, "*:AttachDetailed") beego.Router("/manager/attach/detailed/:id", &controllers.ManagerController{}, "*:AttachDetailed")
beego.Router("/manager/attach/delete", &controllers.ManagerController{}, "post:AttachDelete") beego.Router("/manager/attach/delete", &controllers.ManagerController{}, "post:AttachDelete")
beego.Router("/setting", &controllers.SettingController{}, "*:Index") beego.Router("/setting", &controllers.SettingController{}, "*:Index")
beego.Router("/setting/password", &controllers.SettingController{}, "*:Password") beego.Router("/setting/password", &controllers.SettingController{}, "*:Password")
beego.Router("/setting/upload", &controllers.SettingController{}, "*:Upload") beego.Router("/setting/upload", &controllers.SettingController{}, "*:Upload")
@@ -88,4 +87,3 @@ func init() {
beego.Router("/tag/:key", &controllers.LabelController{}, "get:Index") beego.Router("/tag/:key", &controllers.LabelController{}, "get:Index")
beego.Router("/tags", &controllers.LabelController{}, "get:List") beego.Router("/tags", &controllers.LabelController{}, "get:List")
} }

View File

@@ -417,7 +417,8 @@ table>tbody>tr:hover{
} }
.manual-article .article-head { .manual-article .article-head {
position: relative; position: relative;
zoom:1;padding: 10px 20px zoom: 1;
padding: 10px 20px
} }
.manual-reader .book-title{ .manual-reader .book-title{
color: #333333; color: #333333;
@@ -430,7 +431,7 @@ table>tbody>tr:hover{
.manual-article .article-head h1 { .manual-article .article-head h1 {
margin: 0; margin: 0;
font-size: 20px; font-size: 20px;
font-weight: 200; font-weight: 300;
text-align: center; text-align: center;
line-height: 30px; line-height: 30px;
overflow: hidden; overflow: hidden;
@@ -438,6 +439,17 @@ table>tbody>tr:hover{
white-space: nowrap; white-space: nowrap;
color: #444 color: #444
} }
.manual-article .article-head h3 {
margin: 0;
font-size: 12px;
font-weight: 200;
text-align: center;
line-height: 18px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: #444
}
.manual-article .article-content{ .manual-article .article-content{
min-width: 980px; min-width: 980px;
max-width: 98%; max-width: 98%;

View File

@@ -33,6 +33,7 @@ function loadDocument($url,$id,$callback) {
var body = res.data.body; var body = res.data.body;
var doc_title = res.data.doc_title; var doc_title = res.data.doc_title;
var title = res.data.title; var title = res.data.title;
var doc_info = res.data.doc_info;
$body = body; $body = body;
if (typeof $callback === "function" ){ if (typeof $callback === "function" ){
@@ -41,6 +42,7 @@ function loadDocument($url,$id,$callback) {
$("#page-content").html($body); $("#page-content").html($body);
$("title").text(title); $("title").text(title);
$("#article-title").text(doc_title); $("#article-title").text(doc_title);
$("#article-info").text(doc_info);
events.data('body_' + $id,body); events.data('body_' + $id,body);
events.data('title_' + $id,title); events.data('title_' + $id,title);

View File

@@ -128,6 +128,7 @@
</div> </div>
<div class="col-md-8 text-center"> <div class="col-md-8 text-center">
<h1 id="article-title">{{.Title}}</h1> <h1 id="article-title">{{.Title}}</h1>
<h3 id="article-info">{{.Info}}</h3>
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
</div> </div>