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 | |
parent | 2b10fdc4dcb987b347b031f460cf4f02fd48a31a (diff) | |
download | gitea-c50a3503e6e8ece0dabd109932a72fe093c3cab3.tar.gz gitea-c50a3503e6e8ece0dabd109932a72fe093c3cab3.zip |
introduce git-shell
Diffstat (limited to 'routers')
-rw-r--r-- | routers/install.go | 3 | ||||
-rw-r--r-- | routers/repo/http.go | 2 | ||||
-rw-r--r-- | routers/repo/pull.go | 14 | ||||
-rw-r--r-- | routers/repo/wiki.go | 27 |
4 files changed, 27 insertions, 19 deletions
diff --git a/routers/install.go b/routers/install.go index f3c51d06ac..dc0ff2f2f1 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 7bc5f1aff6..e8f29ebe86 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 d7b4828a91..8d6b4c7d7b 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 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"))) } |