summaryrefslogtreecommitdiffstats
path: root/modules/middleware
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-05-25 20:11:25 -0400
committerUnknown <joe2010xtmf@163.com>2014-05-25 20:11:25 -0400
commit688ec6ecbdf0e1c450aa93fdc4d760c4ae63a73f (patch)
tree8adb59c369d1fe1bd41ae7be38785dc613a29a91 /modules/middleware
parent87854c95a90cf1bebe1bffb833389471fb35f234 (diff)
downloadgitea-688ec6ecbdf0e1c450aa93fdc4d760c4ae63a73f.tar.gz
gitea-688ec6ecbdf0e1c450aa93fdc4d760c4ae63a73f.zip
Fixed #209
Diffstat (limited to 'modules/middleware')
-rw-r--r--modules/middleware/auth.go6
-rw-r--r--modules/middleware/context.go5
-rw-r--r--modules/middleware/logger.go4
-rw-r--r--modules/middleware/render.go24
-rw-r--r--modules/middleware/repo.go14
5 files changed, 23 insertions, 30 deletions
diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go
index e208fb017e..214dda23b9 100644
--- a/modules/middleware/auth.go
+++ b/modules/middleware/auth.go
@@ -10,7 +10,7 @@ import (
"github.com/go-martini/martini"
- "github.com/gogits/gogs/modules/base"
+ "github.com/gogits/gogs/modules/setting"
)
type ToggleOptions struct {
@@ -23,7 +23,7 @@ type ToggleOptions struct {
func Toggle(options *ToggleOptions) martini.Handler {
return func(ctx *Context) {
// Cannot view any page before installation.
- if !base.InstallLock {
+ if !setting.InstallLock {
ctx.Redirect("/install")
return
}
@@ -48,7 +48,7 @@ func Toggle(options *ToggleOptions) martini.Handler {
ctx.SetCookie("redirect_to", "/"+url.QueryEscape(ctx.Req.RequestURI))
ctx.Redirect("/user/login")
return
- } else if !ctx.User.IsActive && base.Service.RegisterEmailConfirm {
+ } else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm {
ctx.Data["Title"] = "Activate Your Account"
ctx.HTML(200, "user/activate")
return
diff --git a/modules/middleware/context.go b/modules/middleware/context.go
index e9084d330c..8c837d0852 100644
--- a/modules/middleware/context.go
+++ b/modules/middleware/context.go
@@ -28,6 +28,7 @@ import (
"github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/setting"
)
// Context represents context of a request.
@@ -325,14 +326,14 @@ func InitContext() martini.Handler {
// p: p,
Req: r,
Res: res,
- Cache: base.Cache,
+ Cache: setting.Cache,
Render: rd,
}
ctx.Data["PageStartTime"] = time.Now()
// start session
- ctx.Session = base.SessionManager.SessionStart(res, r)
+ ctx.Session = setting.SessionManager.SessionStart(res, r)
// Get flash.
values, err := url.ParseQuery(ctx.GetCookie("gogs_flash"))
diff --git a/modules/middleware/logger.go b/modules/middleware/logger.go
index 1ee030a08d..f918281a04 100644
--- a/modules/middleware/logger.go
+++ b/modules/middleware/logger.go
@@ -13,7 +13,7 @@ import (
"github.com/go-martini/martini"
- "github.com/gogits/gogs/modules/base"
+ "github.com/gogits/gogs/modules/setting"
)
var isWindows bool
@@ -24,7 +24,7 @@ func init() {
func Logger() martini.Handler {
return func(res http.ResponseWriter, req *http.Request, ctx martini.Context, log *log.Logger) {
- if base.DisableRouterLog {
+ if setting.DisableRouterLog {
return
}
diff --git a/modules/middleware/render.go b/modules/middleware/render.go
index 662899883f..b5a0d697ae 100644
--- a/modules/middleware/render.go
+++ b/modules/middleware/render.go
@@ -38,26 +38,18 @@ var helperFuncs = template.FuncMap{
}
type Delims struct {
- Left string
-
+ Left string
Right string
}
type RenderOptions struct {
- Directory string
-
- Layout string
-
- Extensions []string
-
- Funcs []template.FuncMap
-
- Delims Delims
-
- Charset string
-
- IndentJSON bool
-
+ Directory string
+ Layout string
+ Extensions []string
+ Funcs []template.FuncMap
+ Delims Delims
+ Charset string
+ IndentJSON bool
HTMLContentType string
}
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go
index 863860e7eb..c1acc827ee 100644
--- a/modules/middleware/repo.go
+++ b/modules/middleware/repo.go
@@ -15,8 +15,8 @@ import (
"github.com/gogits/git"
"github.com/gogits/gogs/models"
- "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
+ "github.com/gogits/gogs/modules/setting"
)
func RepoAssignment(redirect bool, args ...bool) martini.Handler {
@@ -159,17 +159,17 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner
ctx.Data["BranchName"] = ""
- if base.SshPort != 22 {
- ctx.Repo.CloneLink.SSH = fmt.Sprintf("ssh://%s@%s/%s/%s.git", base.RunUser, base.Domain, user.LowerName, repo.LowerName)
+ if setting.SshPort != 22 {
+ ctx.Repo.CloneLink.SSH = fmt.Sprintf("ssh://%s@%s/%s/%s.git", setting.RunUser, setting.Domain, user.LowerName, repo.LowerName)
} else {
- ctx.Repo.CloneLink.SSH = fmt.Sprintf("%s@%s:%s/%s.git", base.RunUser, base.Domain, user.LowerName, repo.LowerName)
+ ctx.Repo.CloneLink.SSH = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.Domain, user.LowerName, repo.LowerName)
}
- ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("%s%s/%s.git", base.AppUrl, user.LowerName, repo.LowerName)
+ ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("%s%s/%s.git", setting.AppUrl, user.LowerName, repo.LowerName)
ctx.Data["CloneLink"] = ctx.Repo.CloneLink
if ctx.Repo.Repository.IsGoget {
- ctx.Data["GoGetLink"] = fmt.Sprintf("%s%s/%s", base.AppUrl, user.LowerName, repo.LowerName)
- ctx.Data["GoGetImport"] = fmt.Sprintf("%s/%s/%s", base.Domain, user.LowerName, repo.LowerName)
+ ctx.Data["GoGetLink"] = fmt.Sprintf("%s%s/%s", setting.AppUrl, user.LowerName, repo.LowerName)
+ ctx.Data["GoGetImport"] = fmt.Sprintf("%s/%s/%s", setting.Domain, user.LowerName, repo.LowerName)
}
// when repo is bare, not valid branch