aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/wiki.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/repo/wiki.go')
-rw-r--r--routers/repo/wiki.go27
1 files changed, 21 insertions, 6 deletions
diff --git a/routers/repo/wiki.go b/routers/repo/wiki.go
index c18e67de67..30bd7b63c7 100644
--- a/routers/repo/wiki.go
+++ b/routers/repo/wiki.go
@@ -5,9 +5,8 @@
package repo
import (
- "github.com/Unknwon/com"
-
"github.com/gogits/gogs/models"
+ "github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/middleware"
)
@@ -22,8 +21,7 @@ func Wiki(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.wiki")
ctx.Data["PageIsWiki"] = true
- wikiPath := models.WikiPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
- if !com.IsDir(wikiPath) {
+ if !ctx.Repo.Repository.HasWiki() {
ctx.HTML(200, WIKI_START)
return
}
@@ -36,14 +34,31 @@ func NewWiki(ctx *middleware.Context) {
ctx.Data["PageIsWiki"] = true
ctx.Data["RequireSimpleMDE"] = true
- wikiPath := models.WikiPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
- if !com.IsDir(wikiPath) {
+ if !ctx.Repo.Repository.HasWiki() {
ctx.Data["title"] = "Home"
}
ctx.HTML(200, WIKI_NEW)
}
+func NewWikiPost(ctx *middleware.Context, form auth.NewWikiForm) {
+ ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
+ ctx.Data["PageIsWiki"] = true
+ ctx.Data["RequireSimpleMDE"] = true
+
+ if ctx.HasError() {
+ ctx.HTML(200, WIKI_NEW)
+ return
+ }
+
+ if err := ctx.Repo.Repository.AddWikiPage(form.Title, form.Content, form.Message); err != nil {
+ ctx.Handle(500, "AddWikiPage", err)
+ return
+ }
+
+ ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + models.ToWikiPageName(form.Title))
+}
+
func EditWiki(ctx *middleware.Context) {
ctx.PlainText(200, []byte(ctx.Params(":page")))
}