渲染markdown. 根据文档id来。
()
| 31 | //渲染markdown. |
| 32 | //根据文档id来。 |
| 33 | func (this *LocalhostController) RenderMarkdown() { |
| 34 | id, _ := this.GetInt("id") |
| 35 | if id > 0 { |
| 36 | var doc models.Document |
| 37 | ModelStore := new(models.DocumentStore) |
| 38 | o := orm.NewOrm() |
| 39 | qs := o.QueryTable("md_documents").Filter("document_id", id) |
| 40 | if this.Ctx.Input.IsPost() { |
| 41 | qs.One(&doc, "identify", "book_id") |
| 42 | var book models.Book |
| 43 | o.QueryTable("md_books").Filter("book_id", doc.BookId).One(&book, "identify") |
| 44 | content := this.GetString("content") |
| 45 | //doc, err := goquery.NewDocumentFromReader(strings.NewReader(content)) |
| 46 | //if err == nil { |
| 47 | // doc.Find("br").Each(func(i int, selection *goquery.Selection) { |
| 48 | // selection.Remove() |
| 49 | // }) |
| 50 | // content, _ = doc.Find("body").Html() |
| 51 | //} |
| 52 | content = this.replaceLinks(book.Identify, content) |
| 53 | qs.Update(orm.Params{ |
| 54 | "release": content, |
| 55 | "modify_time": time.Now(), |
| 56 | }) |
| 57 | //这里要指定更新字段,否则markdown内容会被置空 |
| 58 | ModelStore.InsertOrUpdate(models.DocumentStore{DocumentId: id, Content: content}, "content") |
| 59 | this.JsonResult(0, "成功") |
| 60 | } |
| 61 | |
| 62 | this.Data["Markdown"] = ModelStore.GetFiledById(id, "markdown") |
| 63 | this.TplName = "widgets/render.html" |
| 64 | return |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // 渲染生成封面截图 |
| 69 | func (this *LocalhostController) RenderCover() { |
nothing calls this directly
no test coverage detected