MCPcopy Index your code
hub / github.com/TruthHun/BookStack / Export2Markdown

Method Export2Markdown

controllers/BookController.go:1361–1383  ·  view source on GitHub ↗

ExportMarkdown 将书籍导出为markdown 注意:系统管理员和书籍参与者有权限导出

()

Source from the content-addressed store, hash-verified

1359// ExportMarkdown 将书籍导出为markdown
1360// 注意:系统管理员和书籍参与者有权限导出
1361func (this *BookController) Export2Markdown() {
1362 identify := this.GetString("identify")
1363 if this.Member.MemberId == 0 {
1364 this.JsonResult(1, "请先登录")
1365 }
1366 if !this.Member.IsAdministrator() {
1367 if _, err := models.NewBookResult().FindByIdentify(identify, this.Member.MemberId); err != nil {
1368 this.JsonResult(1, "无操作权限")
1369 }
1370 }
1371 path, err := models.NewBook().Export2Markdown(identify)
1372 if err != nil {
1373 this.JsonResult(1, err.Error())
1374 }
1375 defer func() {
1376 os.Remove(path)
1377 }()
1378 attchmentName := filepath.Base(path)
1379 if book, _ := models.NewBook().FindByIdentify(identify, "book_name", "book_id"); book != nil && book.BookId > 0 {
1380 attchmentName = book.BookName + ".zip"
1381 }
1382 this.Ctx.Output.Download(strings.TrimLeft(path, "./"), attchmentName)
1383}

Callers

nothing calls this directly

Calls 6

NewBookResultFunction · 0.92
NewBookFunction · 0.92
JsonResultMethod · 0.80
IsAdministratorMethod · 0.80
DownloadMethod · 0.80
FindByIdentifyMethod · 0.45

Tested by

no test coverage detected