同步操作将从 进击的皇虫/BookStack 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package controllersimport ("strconv""time""github.com/TruthHun/BookStack/models""github.com/astaxie/beego""github.com/astaxie/beego/orm")//只有请求头的host为localhost的才能访问。type LocalhostController struct {BaseController}func (c *LocalhostController) Prepare() {c.NoNeedLoginRouter = true}//渲染markdown.//根据文档id来。func (this *LocalhostController) RenderMarkdown() {if this.Ctx.Request.Host != "localhost:"+beego.AppConfig.String("httpport") {this.Abort("404")}id, _ := this.GetInt("id")if id > 0 {var doc models.DocumentModelStore := new(models.DocumentStore)o := orm.NewOrm()qs := o.QueryTable("md_documents").Filter("document_id", id)if this.Ctx.Input.IsPost() {qs.One(&doc, "identify", "book_id")var book models.Booko.QueryTable("md_books").Filter("book_id", doc.BookId).One(&book, "identify")content := this.GetString("content")//doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))//if err == nil {// doc.Find("br").Each(func(i int, selection *goquery.Selection) {// selection.Remove()// })// content, _ = doc.Find("body").Html()//}content = this.replaceLinks(book.Identify, content)qs.Update(orm.Params{"release": content,"modify_time": time.Now(),})//这里要指定更新字段,否则markdown内容会被置空ModelStore.InsertOrUpdate(models.DocumentStore{DocumentId: id, Content: content}, "content")this.JsonResult(0, "成功")}this.Data["Markdown"] = ModelStore.GetFiledById(id, "markdown")this.TplName = "widgets/render.html"return}}// 渲染生成封面截图func (this *LocalhostController) RenderCover() {if this.Ctx.Request.Host != "localhost:"+beego.AppConfig.String("httpport") {this.Abort("404")return}identify := this.GetString("id")id, err := strconv.Atoi(identify)if identify == "" && err != nil {this.Abort("404")return}book := models.NewBook()q := orm.NewOrm().QueryTable(book)if id > 0 {err = q.Filter("book_id", id).One(book)} else {err = q.Filter("identify", identify).One(book)}if err != nil {beego.Error(err)}if book.BookId == 0 {this.Abort("404")return}this.Data["Book"] = bookthis.TplName = "ebook/cover.html"}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。