Browse Source

:sparkles: Support for more export formats https://github.com/siyuan-note/siyuan/issues/8127

Liang Ding 2 years ago
parent
commit
c6e66eaa06
3 changed files with 29 additions and 0 deletions
  1. 11 0
      app/src/menus/commonMenuItem.ts
  2. 17 0
      kernel/api/export.go
  3. 1 0
      kernel/api/router.go

+ 11 - 0
app/src/menus/commonMenuItem.ts

@@ -656,6 +656,17 @@ export const exportMd = (id: string) => {
                             openByMobile(response.data.zip);
                         });
                     }
+                },{
+                    label: "Textile",
+                    click: () => {
+                        const msgId = showMessage(window.siyuan.languages.exporting, -1);
+                        fetchPost("/api/export/exportTextile", {
+                            id,
+                        }, response => {
+                            hideMessage(msgId);
+                            openByMobile(response.data.zip);
+                        });
+                    }
                 },
                 ]
             }

+ 17 - 0
kernel/api/export.go

@@ -31,6 +31,23 @@ import (
 	"github.com/siyuan-note/siyuan/kernel/util"
 )
 
+func exportTextile(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)
+	name, zipPath := model.ExportPandocConvertZip(id, "textile", ".textile")
+	ret.Data = map[string]interface{}{
+		"name": name,
+		"zip":  zipPath,
+	}
+}
+
 func exportAsciiDoc(c *gin.Context) {
 	ret := gulu.Ret.NewResult()
 	defer c.JSON(http.StatusOK, ret)

+ 1 - 0
kernel/api/router.go

@@ -247,6 +247,7 @@ func ServeAPI(ginServer *gin.Engine) {
 	ginServer.Handle("POST", "/api/export/export2Liandi", model.CheckAuth, export2Liandi)
 	ginServer.Handle("POST", "/api/export/exportReStructuredText", model.CheckAuth, exportReStructuredText)
 	ginServer.Handle("POST", "/api/export/exportAsciiDoc", model.CheckAuth, exportAsciiDoc)
+	ginServer.Handle("POST", "/api/export/exportTextile", model.CheckAuth, exportTextile)
 
 	ginServer.Handle("POST", "/api/import/importStdMd", model.CheckAuth, model.CheckReadonly, importStdMd)
 	ginServer.Handle("POST", "/api/import/importData", model.CheckAuth, model.CheckReadonly, importData)