修改文档底部信息,增加文档创建时间。

This commit is contained in:
wangbin8909 2021-03-26 08:43:33 +08:00
parent f616985036
commit 79eefb56ac
3 changed files with 20 additions and 16 deletions

View File

@ -247,7 +247,7 @@ func (c *DocumentController) Edit() {
if conf.GetUploadFileSize() > 0 {
c.Data["UploadFileSize"] = conf.GetUploadFileSize()
} else {
c.Data["UploadFileSize"] = "undefined";
c.Data["UploadFileSize"] = "undefined"
}
}
@ -1258,7 +1258,7 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu
if book.BookPassword != "" {
//判断已存在的密码是否正确
if password, ok := c.GetSession(identify).(string); !ok || !strings.EqualFold(password, book.BookPassword) {
body, err := c.ExecuteViewPathTemplate("document/document_password.tpl", map[string]string{"Identify": book.Identify});
body, err := c.ExecuteViewPathTemplate("document/document_password.tpl", map[string]string{"Identify": book.Identify})
if err != nil {
beego.Error("显示密码页面失败 ->", err)
}

View File

@ -272,7 +272,7 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
//先将转换的文件储存到临时目录
tempOutputPath := filepath.Join(os.TempDir(), sessionId, m.Identify, "source") //filepath.Abs(filepath.Join("cache", sessionId))
sourceDir := strings.TrimSuffix(tempOutputPath, "source");
sourceDir := strings.TrimSuffix(tempOutputPath, "source")
if filetil.FileExists(sourceDir) {
if err := os.RemoveAll(sourceDir); err != nil {
beego.Error("删除临时目录失败 ->", sourceDir, err)
@ -485,7 +485,7 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
}
beego.Info("文档转换完成:" + m.BookName)
if err := filetil.CopyFile(filepath.Join(eBookConverter.OutputPath, "output", "book.mobi"), mobipath, ); err != nil {
if err := filetil.CopyFile(filepath.Join(eBookConverter.OutputPath, "output", "book.mobi"), mobipath); err != nil {
beego.Error("复制文档失败 -> ", filepath.Join(eBookConverter.OutputPath, "output", "book.mobi"), err)
}
if err := filetil.CopyFile(filepath.Join(eBookConverter.OutputPath, "output", "book.pdf"), pdfpath); err != nil {

View File

@ -285,7 +285,7 @@ func (item *Document) Processor() *Document {
}
content.WriteString("</ul></div>")
if docQuery == nil {
docQuery, err = goquery.NewDocumentFromReader(content);
docQuery, err = goquery.NewDocumentFromReader(content)
} else {
if selector := docQuery.Find("div.wiki-bottom").First(); selector.Size() > 0 {
selector.BeforeHtml(content.String())
@ -303,17 +303,8 @@ func (item *Document) Processor() *Document {
//处理文档结尾信息
docCreator, err := NewMember().Find(item.MemberId, "real_name", "account")
release := "<div class=\"wiki-bottom\">"
if item.ModifyAt > 0 {
docModify, err := NewMember().Find(item.ModifyAt, "real_name", "account")
if err == nil {
if docModify.RealName != "" {
release += "最后编辑: " + docModify.RealName + " &nbsp;"
} else {
release += "最后编辑: " + docModify.Account + " &nbsp;"
}
}
}
release += "文档更新时间: " + item.ModifyTime.Local().Format("2006-01-02 15:04") + " &nbsp;&nbsp;作者:"
release += "作者:"
if err == nil && docCreator != nil {
if docCreator.RealName != "" {
release += docCreator.RealName
@ -321,6 +312,19 @@ func (item *Document) Processor() *Document {
release += docCreator.Account
}
}
release += " &nbsp;创建时间:" + item.CreateTime.Local().Format("2006-01-02 15:04") + "<br>"
if item.ModifyAt > 0 {
docModify, err := NewMember().Find(item.ModifyAt, "real_name", "account")
if err == nil {
if docModify.RealName != "" {
release += "最后编辑:" + docModify.RealName
} else {
release += "最后编辑:" + docModify.Account
}
}
}
release += " &nbsp;更新时间:" + item.ModifyTime.Local().Format("2006-01-02 15:04") + "<br>"
release += "</div>"
if selector := docQuery.Find("div.markdown-article").First(); selector.Size() > 0 {