aboutsummaryrefslogtreecommitdiff
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/install.go3
-rw-r--r--routers/repo/http.go2
-rw-r--r--routers/repo/pull.go14
-rw-r--r--routers/repo/wiki.go27
4 files changed, 27 insertions, 19 deletions
diff --git a/routers/install.go b/routers/install.go
index f3c51d06..dc0ff2f2 100644
--- a/routers/install.go
+++ b/routers/install.go
@@ -17,6 +17,8 @@ import (
"gopkg.in/ini.v1"
"gopkg.in/macaron.v1"
+ "github.com/gogits/git-shell"
+
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/models/cron"
"github.com/gogits/gogs/modules/auth"
@@ -39,6 +41,7 @@ func checkRunMode() {
macaron.Env = macaron.PROD
macaron.ColorLog = false
setting.ProdMode = true
+ git.Debug = false
}
log.Info("Run Mode: %s", strings.Title(macaron.Env))
}
diff --git a/routers/repo/http.go b/routers/repo/http.go
index 7bc5f1af..e8f29ebe 100644
--- a/routers/repo/http.go
+++ b/routers/repo/http.go
@@ -31,7 +31,7 @@ import (
func authRequired(ctx *middleware.Context) {
ctx.Resp.Header().Set("WWW-Authenticate", "Basic realm=\".\"")
ctx.Data["ErrorMsg"] = "no basic auth and digit auth"
- ctx.HTML(401, base.TplName("status/401"))
+ ctx.Error(401)
}
func HTTP(ctx *middleware.Context) {
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index d7b4828a..8d6b4c7d 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -210,13 +210,7 @@ func PrepareViewPullInfo(ctx *middleware.Context, pull *models.Issue) *git.PullR
}
if pull.HeadRepo != nil {
- headRepoPath, err := pull.HeadRepo.RepoPath()
- if err != nil {
- ctx.Handle(500, "HeadRepo.RepoPath", err)
- return nil
- }
-
- headGitRepo, err = git.OpenRepository(headRepoPath)
+ headGitRepo, err = git.OpenRepository(pull.HeadRepo.RepoPath())
if err != nil {
ctx.Handle(500, "OpenRepository", err)
return nil
@@ -496,11 +490,7 @@ func PrepareCompareDiff(
)
// Get diff information.
- ctx.Data["CommitRepoLink"], err = headRepo.RepoLink()
- if err != nil {
- ctx.Handle(500, "RepoLink", err)
- return false
- }
+ ctx.Data["CommitRepoLink"] = headRepo.RepoLink()
headCommitID, err := headGitRepo.GetCommitIdOfBranch(headBranch)
if err != nil {
diff --git a/routers/repo/wiki.go b/routers/repo/wiki.go
index c18e67de..30bd7b63 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")))
}