aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/wiki.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-03-20 21:36:19 +0800
committerGitHub <noreply@github.com>2017-03-20 21:36:19 +0800
commitbd8fe49076e0f880fbb923822f2247b57f9799e9 (patch)
tree4b9d66c20d828444142cf2e1c4866e9f9032afcc /routers/repo/wiki.go
parentdbabc35e7157de9482482d97ebfbce3194a44bda (diff)
downloadgitea-bd8fe49076e0f880fbb923822f2247b57f9799e9.tar.gz
gitea-bd8fe49076e0f880fbb923822f2247b57f9799e9.zip
fix wiki bugs (#1294)
Diffstat (limited to 'routers/repo/wiki.go')
-rw-r--r--routers/repo/wiki.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/routers/repo/wiki.go b/routers/repo/wiki.go
index 2633ae9cea..c1c05d305a 100644
--- a/routers/repo/wiki.go
+++ b/routers/repo/wiki.go
@@ -177,6 +177,10 @@ func findWikiRepoCommit(ctx *context.Context) (*git.Repository, *git.Commit, err
// ctx.Handle(500, "OpenRepository", err)
return nil, nil, err
}
+ if !wikiRepo.IsBranchExist("master") {
+ return wikiRepo, nil, nil
+ }
+
commit, err := wikiRepo.GetBranchCommit("master")
if err != nil {
ctx.Handle(500, "GetBranchCommit", err)
@@ -190,6 +194,9 @@ func renderWikiPage(ctx *context.Context, isViewPage bool) (*git.Repository, *gi
if err != nil {
return nil, nil
}
+ if commit == nil {
+ return wikiRepo, nil
+ }
// Get page list.
if isViewPage {
@@ -210,7 +217,7 @@ func renderWikiPage(ctx *context.Context, isViewPage bool) (*git.Repository, *gi
}
pages = append(pages, PageMeta{
Name: models.ToWikiPageName(name),
- URL: models.ToWikiPageURL(name),
+ URL: name,
})
}
}
@@ -308,6 +315,11 @@ func Wiki(ctx *context.Context) {
if ctx.Written() {
return
}
+ if entry == nil {
+ ctx.Data["Title"] = ctx.Tr("repo.wiki")
+ ctx.HTML(200, tplWikiStart)
+ return
+ }
ename := entry.Name()
if !markdown.IsMarkdownFile(ename) {
@@ -362,7 +374,7 @@ func WikiPages(ctx *context.Context) {
}
pages = append(pages, PageMeta{
Name: models.ToWikiPageName(name),
- URL: models.ToWikiPageURL(name),
+ URL: name,
Updated: c.Author.When,
})
}
@@ -480,7 +492,7 @@ func EditWikiPost(ctx *context.Context, form auth.NewWikiForm) {
return
}
- oldWikiPath := ctx.Params(":page")
+ oldWikiPath := models.ToWikiPageURL(ctx.Params(":page"))
newWikiPath := models.ToWikiPageURL(form.Title)
if err := ctx.Repo.Repository.EditWikiPage(ctx.User, oldWikiPath, newWikiPath, form.Content, form.Message); err != nil {
@@ -493,7 +505,7 @@ func EditWikiPost(ctx *context.Context, form auth.NewWikiForm) {
// DeleteWikiPagePost delete wiki page
func DeleteWikiPagePost(ctx *context.Context) {
- pageURL := ctx.Params(":page")
+ pageURL := models.ToWikiPageURL(ctx.Params(":page"))
if len(pageURL) == 0 {
pageURL = "Home"
}