mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-23 20:53:46 +08:00
修改文档底部信息,增加文档创建时间。
This commit is contained in:
@@ -247,7 +247,7 @@ func (c *DocumentController) Edit() {
|
|||||||
if conf.GetUploadFileSize() > 0 {
|
if conf.GetUploadFileSize() > 0 {
|
||||||
c.Data["UploadFileSize"] = conf.GetUploadFileSize()
|
c.Data["UploadFileSize"] = conf.GetUploadFileSize()
|
||||||
} else {
|
} 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 book.BookPassword != "" {
|
||||||
//判断已存在的密码是否正确
|
//判断已存在的密码是否正确
|
||||||
if password, ok := c.GetSession(identify).(string); !ok || !strings.EqualFold(password, 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 {
|
if err != nil {
|
||||||
beego.Error("显示密码页面失败 ->", err)
|
beego.Error("显示密码页面失败 ->", err)
|
||||||
}
|
}
|
||||||
|
@@ -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))
|
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 filetil.FileExists(sourceDir) {
|
||||||
if err := os.RemoveAll(sourceDir); err != nil {
|
if err := os.RemoveAll(sourceDir); err != nil {
|
||||||
beego.Error("删除临时目录失败 ->", sourceDir, err)
|
beego.Error("删除临时目录失败 ->", sourceDir, err)
|
||||||
@@ -485,7 +485,7 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
|
|||||||
}
|
}
|
||||||
beego.Info("文档转换完成:" + m.BookName)
|
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)
|
beego.Error("复制文档失败 -> ", filepath.Join(eBookConverter.OutputPath, "output", "book.mobi"), err)
|
||||||
}
|
}
|
||||||
if err := filetil.CopyFile(filepath.Join(eBookConverter.OutputPath, "output", "book.pdf"), pdfpath); err != nil {
|
if err := filetil.CopyFile(filepath.Join(eBookConverter.OutputPath, "output", "book.pdf"), pdfpath); err != nil {
|
||||||
|
@@ -285,7 +285,7 @@ func (item *Document) Processor() *Document {
|
|||||||
}
|
}
|
||||||
content.WriteString("</ul></div>")
|
content.WriteString("</ul></div>")
|
||||||
if docQuery == nil {
|
if docQuery == nil {
|
||||||
docQuery, err = goquery.NewDocumentFromReader(content);
|
docQuery, err = goquery.NewDocumentFromReader(content)
|
||||||
} else {
|
} else {
|
||||||
if selector := docQuery.Find("div.wiki-bottom").First(); selector.Size() > 0 {
|
if selector := docQuery.Find("div.wiki-bottom").First(); selector.Size() > 0 {
|
||||||
selector.BeforeHtml(content.String())
|
selector.BeforeHtml(content.String())
|
||||||
@@ -303,17 +303,8 @@ func (item *Document) Processor() *Document {
|
|||||||
//处理文档结尾信息
|
//处理文档结尾信息
|
||||||
docCreator, err := NewMember().Find(item.MemberId, "real_name", "account")
|
docCreator, err := NewMember().Find(item.MemberId, "real_name", "account")
|
||||||
release := "<div class=\"wiki-bottom\">"
|
release := "<div class=\"wiki-bottom\">"
|
||||||
if item.ModifyAt > 0 {
|
|
||||||
docModify, err := NewMember().Find(item.ModifyAt, "real_name", "account")
|
release += "作者:"
|
||||||
if err == nil {
|
|
||||||
if docModify.RealName != "" {
|
|
||||||
release += "最后编辑: " + docModify.RealName + " "
|
|
||||||
} else {
|
|
||||||
release += "最后编辑: " + docModify.Account + " "
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
release += "文档更新时间: " + item.ModifyTime.Local().Format("2006-01-02 15:04") + " 作者:"
|
|
||||||
if err == nil && docCreator != nil {
|
if err == nil && docCreator != nil {
|
||||||
if docCreator.RealName != "" {
|
if docCreator.RealName != "" {
|
||||||
release += docCreator.RealName
|
release += docCreator.RealName
|
||||||
@@ -321,6 +312,19 @@ func (item *Document) Processor() *Document {
|
|||||||
release += docCreator.Account
|
release += docCreator.Account
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
release += " 创建时间:" + 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 += " 更新时间:" + item.ModifyTime.Local().Format("2006-01-02 15:04") + "<br>"
|
||||||
release += "</div>"
|
release += "</div>"
|
||||||
|
|
||||||
if selector := docQuery.Find("div.markdown-article").First(); selector.Size() > 0 {
|
if selector := docQuery.Find("div.markdown-article").First(); selector.Size() > 0 {
|
||||||
|
Reference in New Issue
Block a user