Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-07-24 22:32:08 +08:00
commit 2476cb4ccd
3 changed files with 39 additions and 0 deletions

View File

@ -90,6 +90,22 @@ func exportMd(c *gin.Context) {
} }
} }
func exportNotebookSY(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
id := arg["id"].(string)
zipPath := model.ExportNotebookSY(id)
ret.Data = map[string]interface{}{
"zip": zipPath,
}
}
func exportSY(c *gin.Context) { func exportSY(c *gin.Context) {
ret := gulu.Ret.NewResult() ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret) defer c.JSON(http.StatusOK, ret)

View File

@ -191,6 +191,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/export/batchExportMd", model.CheckAuth, batchExportMd) ginServer.Handle("POST", "/api/export/batchExportMd", model.CheckAuth, batchExportMd)
ginServer.Handle("POST", "/api/export/exportMd", model.CheckAuth, exportMd) ginServer.Handle("POST", "/api/export/exportMd", model.CheckAuth, exportMd)
ginServer.Handle("POST", "/api/export/exportSY", model.CheckAuth, exportSY) ginServer.Handle("POST", "/api/export/exportSY", model.CheckAuth, exportSY)
ginServer.Handle("POST", "/api/export/exportNotebookSY", model.CheckAuth, exportNotebookSY)
ginServer.Handle("POST", "/api/export/exportMdContent", model.CheckAuth, exportMdContent) ginServer.Handle("POST", "/api/export/exportMdContent", model.CheckAuth, exportMdContent)
ginServer.Handle("POST", "/api/export/exportHTML", model.CheckAuth, exportHTML) ginServer.Handle("POST", "/api/export/exportHTML", model.CheckAuth, exportHTML)
ginServer.Handle("POST", "/api/export/exportMdHTML", model.CheckAuth, exportMdHTML) ginServer.Handle("POST", "/api/export/exportMdHTML", model.CheckAuth, exportMdHTML)

View File

@ -47,6 +47,11 @@ import (
"github.com/siyuan-note/siyuan/kernel/util" "github.com/siyuan-note/siyuan/kernel/util"
) )
func ExportNotebookSY(id string) (zipPath string) {
zipPath = exportBoxSYZip(id)
return
}
func ExportSY(id string) (name, zipPath string) { func ExportSY(id string) (name, zipPath string) {
block := treenode.GetBlockTree(id) block := treenode.GetBlockTree(id)
if nil == block { if nil == block {
@ -612,6 +617,23 @@ func exportMarkdownZip(boxID, baseFolderName string, docPaths []string) (zipPath
return return
} }
func exportBoxSYZip(boxID string) (zipPath string) {
box := Conf.Box(boxID)
if nil == box {
logging.LogErrorf("not found box [%s]", boxID)
return
}
baseFolderName := box.Name
var docPaths []string
docFiles := box.ListFiles("/")
for _, docFile := range docFiles {
docPaths = append(docPaths, docFile.path)
}
zipPath = exportSYZip(boxID, "/", baseFolderName, docPaths)
return
}
func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (zipPath string) { func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (zipPath string) {
dir, name := path.Split(baseFolderName) dir, name := path.Split(baseFolderName)
name = util.FilterFileName(name) name = util.FilterFileName(name)