diff options
author | Unknwon <u@gogs.io> | 2015-11-26 17:33:45 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-11-26 17:33:45 -0500 |
commit | c50a3503e6e8ece0dabd109932a72fe093c3cab3 (patch) | |
tree | d9918c4b9c5d5efc94771cae22231fdcc0796102 /routers/repo/wiki.go | |
parent | 2b10fdc4dcb987b347b031f460cf4f02fd48a31a (diff) | |
download | gitea-c50a3503e6e8ece0dabd109932a72fe093c3cab3.tar.gz gitea-c50a3503e6e8ece0dabd109932a72fe093c3cab3.zip |
introduce git-shell
Diffstat (limited to 'routers/repo/wiki.go')
-rw-r--r-- | routers/repo/wiki.go | 27 |
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"))) } |