document.go 702 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package controllers
  2. import (
  3. "github.com/lifei6671/godoc/models"
  4. "github.com/astaxie/beego/logs"
  5. )
  6. type DocumentController struct {
  7. BaseController
  8. }
  9. func (p *DocumentController) Index() {
  10. p.TplName = "document/index.tpl"
  11. }
  12. func (p *DocumentController) Read() {
  13. p.TplName = "document/kancloud.tpl"
  14. }
  15. func (c *DocumentController) Edit() {
  16. c.Prepare()
  17. identify := c.Ctx.Input.Param(":key")
  18. book,err := models.NewBook().FindByFieldFirst("identify",identify)
  19. if err != nil {
  20. logs.Error("DocumentController.Edit => ",err)
  21. c.Abort("500")
  22. }
  23. if book.Editor == "markdown" {
  24. c.TplName = "document/markdown_edit_template.tpl"
  25. }else{
  26. c.TplName = "document/html_edit_template.tpl"
  27. }
  28. }