wiki.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "github.com/Unknwon/com"
  7. "github.com/gogits/gogs/models"
  8. "github.com/gogits/gogs/modules/base"
  9. "github.com/gogits/gogs/modules/middleware"
  10. )
  11. const (
  12. WIKI_START base.TplName = "repo/wiki/start"
  13. WIKI_VIEW base.TplName = "repo/wiki/view"
  14. WIKI_NEW base.TplName = "repo/wiki/new"
  15. )
  16. func Wiki(ctx *middleware.Context) {
  17. ctx.Data["Title"] = ctx.Tr("repo.wiki")
  18. ctx.Data["PageIsWiki"] = true
  19. wikiPath := models.WikiPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
  20. if !com.IsDir(wikiPath) {
  21. ctx.HTML(200, WIKI_START)
  22. return
  23. }
  24. ctx.HTML(200, WIKI_VIEW)
  25. }
  26. func NewWiki(ctx *middleware.Context) {
  27. ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
  28. ctx.Data["PageIsWiki"] = true
  29. ctx.Data["RequireSimpleMDE"] = true
  30. wikiPath := models.WikiPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
  31. if !com.IsDir(wikiPath) {
  32. ctx.Data["title"] = "Home"
  33. }
  34. ctx.HTML(200, WIKI_NEW)
  35. }
  36. func EditWiki(ctx *middleware.Context) {
  37. ctx.PlainText(200, []byte(ctx.Params(":page")))
  38. }