mirror of https://github.com/mindoc-org/mindoc.git
优化时间显示
parent
c23cb959e8
commit
556ca73a5d
|
@ -57,10 +57,6 @@
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/nfnt/resize"
|
name = "github.com/nfnt/resize"
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/russross/blackfriday"
|
|
||||||
version = "2.0.0"
|
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "gopkg.in/ldap.v2"
|
name = "gopkg.in/ldap.v2"
|
||||||
version = "2.5.1"
|
version = "2.5.1"
|
||||||
|
|
|
@ -44,6 +44,8 @@ func (c *BookController) Index() {
|
||||||
|
|
||||||
for i,book := range books {
|
for i,book := range books {
|
||||||
books[i].Description = utils.StripTags(string(blackfriday.Run([]byte(book.Description))))
|
books[i].Description = utils.StripTags(string(blackfriday.Run([]byte(book.Description))))
|
||||||
|
books[i].ModifyTime = book.ModifyTime.Local()
|
||||||
|
books[i].CreateTime = book.CreateTime.Local()
|
||||||
}
|
}
|
||||||
|
|
||||||
if totalCount > 0 {
|
if totalCount > 0 {
|
||||||
|
|
|
@ -298,6 +298,8 @@ func (c *ManagerController) Books() {
|
||||||
}
|
}
|
||||||
for i,book := range books {
|
for i,book := range books {
|
||||||
books[i].Description = utils.StripTags(string(blackfriday.Run([]byte(book.Description))))
|
books[i].Description = utils.StripTags(string(blackfriday.Run([]byte(book.Description))))
|
||||||
|
books[i].ModifyTime = book.ModifyTime.Local()
|
||||||
|
books[i].CreateTime = book.CreateTime.Local()
|
||||||
}
|
}
|
||||||
c.Data["Lists"] = books
|
c.Data["Lists"] = books
|
||||||
}
|
}
|
||||||
|
@ -319,17 +321,17 @@ func (c *ManagerController) EditBook() {
|
||||||
}
|
}
|
||||||
if c.Ctx.Input.IsPost() {
|
if c.Ctx.Input.IsPost() {
|
||||||
|
|
||||||
book_name := strings.TrimSpace(c.GetString("book_name"))
|
bookName := strings.TrimSpace(c.GetString("book_name"))
|
||||||
description := strings.TrimSpace(c.GetString("description", ""))
|
description := strings.TrimSpace(c.GetString("description", ""))
|
||||||
comment_status := c.GetString("comment_status")
|
commentStatus := c.GetString("comment_status")
|
||||||
tag := strings.TrimSpace(c.GetString("label"))
|
tag := strings.TrimSpace(c.GetString("label"))
|
||||||
order_index, _ := c.GetInt("order_index", 0)
|
orderIndex, _ := c.GetInt("order_index", 0)
|
||||||
|
|
||||||
if strings.Count(description, "") > 500 {
|
if strings.Count(description, "") > 500 {
|
||||||
c.JsonResult(6004, "项目描述不能大于500字")
|
c.JsonResult(6004, "项目描述不能大于500字")
|
||||||
}
|
}
|
||||||
if comment_status != "open" && comment_status != "closed" && comment_status != "group_only" && comment_status != "registered_only" {
|
if commentStatus != "open" && commentStatus != "closed" && commentStatus != "group_only" && commentStatus != "registered_only" {
|
||||||
comment_status = "closed"
|
commentStatus = "closed"
|
||||||
}
|
}
|
||||||
if tag != "" {
|
if tag != "" {
|
||||||
tags := strings.Split(tag, ";")
|
tags := strings.Split(tag, ";")
|
||||||
|
@ -338,11 +340,11 @@ func (c *ManagerController) EditBook() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
book.BookName = book_name
|
book.BookName = bookName
|
||||||
book.Description = description
|
book.Description = description
|
||||||
book.CommentStatus = comment_status
|
book.CommentStatus = commentStatus
|
||||||
book.Label = tag
|
book.Label = tag
|
||||||
book.OrderIndex = order_index
|
book.OrderIndex = orderIndex
|
||||||
|
|
||||||
if err := book.Update(); err != nil {
|
if err := book.Update(); err != nil {
|
||||||
c.JsonResult(6006, "保存失败")
|
c.JsonResult(6006, "保存失败")
|
||||||
|
|
|
@ -125,7 +125,7 @@ func (m *BookResult) FindByIdentify(identify string, memberId int) (*BookResult,
|
||||||
member2 := NewMember()
|
member2 := NewMember()
|
||||||
member2.Find(doc.ModifyAt)
|
member2.Find(doc.ModifyAt)
|
||||||
|
|
||||||
m.LastModifyText = member2.Account + " 于 " + doc.ModifyTime.Format("2006-01-02 15:04:05")
|
m.LastModifyText = member2.Account + " 于 " + doc.ModifyTime.Local().Format("2006-01-02 15:04:05")
|
||||||
}
|
}
|
||||||
|
|
||||||
return m, nil
|
return m, nil
|
||||||
|
@ -168,8 +168,8 @@ func (m *BookResult) ToBookResult(book Book) *BookResult {
|
||||||
m.DocCount = book.DocCount
|
m.DocCount = book.DocCount
|
||||||
m.CommentStatus = book.CommentStatus
|
m.CommentStatus = book.CommentStatus
|
||||||
m.CommentCount = book.CommentCount
|
m.CommentCount = book.CommentCount
|
||||||
m.CreateTime = book.CreateTime
|
m.CreateTime = book.CreateTime.Local()
|
||||||
m.ModifyTime = book.ModifyTime
|
m.ModifyTime = book.ModifyTime.Local()
|
||||||
m.Cover = book.Cover
|
m.Cover = book.Cover
|
||||||
m.Label = book.Label
|
m.Label = book.Label
|
||||||
m.Status = book.Status
|
m.Status = book.Status
|
||||||
|
@ -187,6 +187,20 @@ func (m *BookResult) ToBookResult(book Book) *BookResult {
|
||||||
if book.Editor == "" {
|
if book.Editor == "" {
|
||||||
m.Editor = "markdown"
|
m.Editor = "markdown"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doc := NewDocument()
|
||||||
|
|
||||||
|
o := orm.NewOrm()
|
||||||
|
|
||||||
|
err := o.QueryTable(doc.TableNameWithPrefix()).Filter("book_id", book.BookId).OrderBy("modify_time").One(doc)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
member2 := NewMember()
|
||||||
|
member2.Find(doc.ModifyAt)
|
||||||
|
|
||||||
|
m.LastModifyText = member2.Account + " 于 " + doc.ModifyTime.Local().Format("2006-01-02 15:04:05")
|
||||||
|
}
|
||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue