aboutsummaryrefslogtreecommitdiff
path: root/cmd/web.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/web.go')
-rw-r--r--cmd/web.go77
1 files changed, 44 insertions, 33 deletions
diff --git a/cmd/web.go b/cmd/web.go
index 30fd4b79..cb14b7c9 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -7,7 +7,7 @@ package cmd
import (
"crypto/tls"
"fmt"
- "html/template"
+ gotmpl "html/template"
"io/ioutil"
"net/http"
"net/http/fcgi"
@@ -15,18 +15,19 @@ import (
"path"
"strings"
- "github.com/Unknwon/macaron"
"github.com/codegangsta/cli"
+ "github.com/go-macaron/binding"
+ "github.com/go-macaron/cache"
+ "github.com/go-macaron/captcha"
+ "github.com/go-macaron/csrf"
+ "github.com/go-macaron/gzip"
+ "github.com/go-macaron/i18n"
+ "github.com/go-macaron/session"
+ "github.com/go-macaron/toolbox"
"github.com/go-xorm/xorm"
- "github.com/macaron-contrib/binding"
- "github.com/macaron-contrib/cache"
- "github.com/macaron-contrib/captcha"
- "github.com/macaron-contrib/csrf"
- "github.com/macaron-contrib/i18n"
- "github.com/macaron-contrib/session"
- "github.com/macaron-contrib/toolbox"
"github.com/mcuadros/go-version"
"gopkg.in/ini.v1"
+ "gopkg.in/macaron.v1"
api "github.com/gogits/go-gogs-client"
@@ -34,11 +35,11 @@ import (
"github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/auth/apiv1"
"github.com/gogits/gogs/modules/avatar"
- "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/bindata"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/setting"
+ "github.com/gogits/gogs/modules/template"
"github.com/gogits/gogs/routers"
"github.com/gogits/gogs/routers/admin"
"github.com/gogits/gogs/routers/api/v1"
@@ -55,8 +56,8 @@ var CmdWeb = cli.Command{
and it takes care of all the other things for you`,
Action: runWeb,
Flags: []cli.Flag{
- cli.StringFlag{"port, p", "3000", "Temporary port number to prevent conflict", ""},
- cli.StringFlag{"config, c", "custom/conf/app.ini", "Custom configuration file path", ""},
+ stringFlag("port, p", "3000", "Temporary port number to prevent conflict"),
+ stringFlag("config, c", "custom/conf/app.ini", "Custom configuration file path"),
},
}
@@ -79,13 +80,14 @@ func checkVersion() {
// Check dependency version.
checkers := []VerChecker{
- {"github.com/go-xorm/xorm", func() string { return xorm.Version }, "0.4.3.0806"},
+ {"github.com/go-xorm/xorm", func() string { return xorm.Version }, "0.4.4.1029"},
{"github.com/Unknwon/macaron", macaron.Version, "0.5.4"},
- {"github.com/macaron-contrib/binding", binding.Version, "0.1.0"},
- {"github.com/macaron-contrib/cache", cache.Version, "0.1.2"},
- {"github.com/macaron-contrib/csrf", csrf.Version, "0.0.3"},
- {"github.com/macaron-contrib/i18n", i18n.Version, "0.0.7"},
- {"github.com/macaron-contrib/session", session.Version, "0.1.6"},
+ {"github.com/go-macaron/binding", binding.Version, "0.1.0"},
+ {"github.com/go-macaron/cache", cache.Version, "0.1.2"},
+ {"github.com/go-macaron/csrf", csrf.Version, "0.0.3"},
+ {"github.com/go-macaron/i18n", i18n.Version, "0.0.7"},
+ {"github.com/go-macaron/session", session.Version, "0.1.6"},
+ {"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
{"gopkg.in/ini.v1", ini.Version, "1.3.4"},
}
for _, c := range checkers {
@@ -103,7 +105,7 @@ func newMacaron() *macaron.Macaron {
}
m.Use(macaron.Recovery())
if setting.EnableGzip {
- m.Use(macaron.Gziper())
+ m.Use(gzip.Gziper())
}
if setting.Protocol == setting.FCGI {
m.SetURLPrefix(setting.AppSubUrl)
@@ -123,7 +125,7 @@ func newMacaron() *macaron.Macaron {
))
m.Use(macaron.Renderer(macaron.RenderOptions{
Directory: path.Join(setting.StaticRootPath, "templates"),
- Funcs: []template.FuncMap{base.TemplateFuncs},
+ Funcs: []gotmpl.FuncMap{template.Funcs},
IndentJSON: macaron.Env != macaron.PROD,
}))
@@ -223,11 +225,12 @@ func runWeb(ctx *cli.Context) {
m.Group("/repos", func() {
m.Get("/search", v1.SearchRepos)
+ })
- m.Group("", func() {
- m.Post("/migrate", bindIgnErr(auth.MigrateRepoForm{}), v1.MigrateRepo)
- m.Delete("/:username/:reponame", v1.DeleteRepo)
- }, middleware.ApiReqToken())
+ m.Group("/repos", func() {
+ m.Post("/migrate", bindIgnErr(auth.MigrateRepoForm{}), v1.MigrateRepo)
+ m.Combo("/:username/:reponame").Get(v1.GetRepo).
+ Delete(v1.DeleteRepo)
m.Group("/:username/:reponame", func() {
m.Combo("/hooks").Get(v1.ListRepoHooks).
@@ -235,8 +238,8 @@ func runWeb(ctx *cli.Context) {
m.Patch("/hooks/:id:int", bind(api.EditHookOption{}), v1.EditRepoHook)
m.Get("/raw/*", middleware.RepoRef(), v1.GetRepoRawFile)
m.Get("/archive/*", v1.GetRepoArchive)
- }, middleware.ApiRepoAssignment(), middleware.ApiReqToken())
- })
+ }, middleware.ApiRepoAssignment())
+ }, middleware.ApiReqToken())
m.Any("/*", func(ctx *middleware.Context) {
ctx.Error(404)
@@ -460,8 +463,10 @@ func runWeb(ctx *cli.Context) {
m.Post("/delete", repo.DeleteDeployKey)
})
+ }, func(ctx *middleware.Context) {
+ ctx.Data["PageIsSettings"] = true
})
- }, reqSignIn, middleware.RepoAssignment(true), reqRepoAdmin)
+ }, reqSignIn, middleware.RepoAssignment(true), reqRepoAdmin, middleware.RepoRef())
m.Group("/:username/:reponame", func() {
m.Get("/action/:action", repo.Action)
@@ -509,11 +514,17 @@ func runWeb(ctx *cli.Context) {
}, reqSignIn, middleware.RepoAssignment(true))
m.Group("/:username/:reponame", func() {
- m.Get("/releases", middleware.RepoRef(), repo.Releases)
- m.Get("/^:type(issues|pulls)$", repo.RetrieveLabels, repo.Issues)
+ m.Group("", func() {
+ m.Get("/releases", repo.Releases)
+ m.Get("/^:type(issues|pulls)$", repo.RetrieveLabels, repo.Issues)
+ m.Get("/labels/", repo.RetrieveLabels, repo.Labels)
+ m.Get("/milestones", repo.Milestones)
+ }, middleware.RepoRef(),
+ func(ctx *middleware.Context) {
+ ctx.Data["PageIsList"] = true
+ })
m.Get("/^:type(issues|pulls)$/:index", repo.ViewIssue)
- m.Get("/labels/", repo.RetrieveLabels, repo.Labels)
- m.Get("/milestones", repo.Milestones)
+
m.Get("/branches", repo.Branches)
m.Get("/archive/*", repo.Download)
@@ -543,8 +554,8 @@ func runWeb(ctx *cli.Context) {
}, ignSignIn, middleware.RepoAssignment(true, true), middleware.RepoRef())
m.Group("/:reponame", func() {
- m.Any("/*", ignSignInAndCsrf, repo.Http)
- m.Head("/hooks/trigger", repo.TriggerHook)
+ m.Any("/*", ignSignInAndCsrf, repo.HTTP)
+ m.Head("/tasks/trigger", repo.TriggerTask)
})
})
// ***** END: Repository *****