mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-19 18:22:10 +08:00
实现导出Markdown源文件
This commit is contained in:
@@ -860,7 +860,6 @@ func (c *DocumentController) Content() {
|
||||
// 导出
|
||||
func (c *DocumentController) Export() {
|
||||
c.Prepare()
|
||||
c.TplName = "document/export.tpl"
|
||||
|
||||
identify := c.Ctx.Input.Param(":key")
|
||||
if identify == "" {
|
||||
@@ -896,6 +895,21 @@ func (c *DocumentController) Export() {
|
||||
bookResult.Cover = c.BaseUrl() + bookResult.Cover
|
||||
}
|
||||
|
||||
if output == "markdown" {
|
||||
if bookResult.Editor != "markdown"{
|
||||
c.ShowErrorPage(500,"当前项目不支持Markdown编辑器")
|
||||
}
|
||||
p,err := bookResult.ExportMarkdown(c.CruSession.SessionID())
|
||||
|
||||
if err != nil {
|
||||
c.ShowErrorPage(500,"导出文档失败")
|
||||
}
|
||||
c.Ctx.Output.Download(p, bookResult.BookName+".zip")
|
||||
|
||||
c.StopRun()
|
||||
return
|
||||
}
|
||||
|
||||
eBookResult, err := bookResult.Converter(c.CruSession.SessionID())
|
||||
|
||||
if err != nil {
|
||||
|
@@ -16,6 +16,7 @@ import (
|
||||
"strconv"
|
||||
"github.com/lifei6671/mindoc/utils/pagination"
|
||||
"math"
|
||||
"gopkg.in/russross/blackfriday.v2"
|
||||
)
|
||||
|
||||
type ManagerController struct {
|
||||
@@ -297,7 +298,9 @@ func (c *ManagerController) Books() {
|
||||
} else {
|
||||
c.Data["PageHtml"] = ""
|
||||
}
|
||||
|
||||
for i,book := range books {
|
||||
books[i].Description = utils.StripTags(string(blackfriday.Run([]byte(book.Description))))
|
||||
}
|
||||
c.Data["Lists"] = books
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user