aboutsummaryrefslogtreecommitdiffstats
path: root/modules/middleware/context.go
diff options
context:
space:
mode:
authorslene <vslene@gmail.com>2014-03-20 21:02:52 +0800
committerslene <vslene@gmail.com>2014-03-20 21:02:52 +0800
commitc6bd723ce17ae3c0495f84e46a9296b30db5aee1 (patch)
treea2153db027aa03db50f2e7f841bd2545fa65a2bd /modules/middleware/context.go
parent21379e30a18fed473ae2bbeb41332919ff80497d (diff)
parentc7b6fbfd46fe465b5103ecc0b743ea009eb1e586 (diff)
downloadgitea-c6bd723ce17ae3c0495f84e46a9296b30db5aee1.tar.gz
gitea-c6bd723ce17ae3c0495f84e46a9296b30db5aee1.zip
Merge branch 'master' of github.com:gogits/gogs
Conflicts: public/js/app.js
Diffstat (limited to 'modules/middleware/context.go')
-rw-r--r--modules/middleware/context.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/middleware/context.go b/modules/middleware/context.go
index 6ac87de3be..cb3cbabca6 100644
--- a/modules/middleware/context.go
+++ b/modules/middleware/context.go
@@ -61,24 +61,29 @@ func (ctx *Context) HasError() bool {
return hasErr.(bool)
}
+// HTML calls render.HTML underlying but reduce one argument.
+func (ctx *Context) HTML(status int, name string, htmlOpt ...HTMLOptions) {
+ ctx.Render.HTML(status, name, ctx.Data, htmlOpt...)
+}
+
// RenderWithErr used for page has form validation but need to prompt error to users.
func (ctx *Context) RenderWithErr(msg, tpl string, form auth.Form) {
ctx.Data["HasError"] = true
ctx.Data["ErrorMsg"] = msg
auth.AssignForm(form, ctx.Data)
- ctx.HTML(200, tpl, ctx.Data)
+ ctx.HTML(200, tpl)
}
// Handle handles and logs error by given status.
func (ctx *Context) Handle(status int, title string, err error) {
log.Error("%s: %v", title, err)
if martini.Dev == martini.Prod {
- ctx.HTML(500, "status/500", ctx.Data)
+ ctx.HTML(500, "status/500")
return
}
ctx.Data["ErrorMsg"] = err
- ctx.HTML(status, fmt.Sprintf("status/%d", status), ctx.Data)
+ ctx.HTML(status, fmt.Sprintf("status/%d", status))
}
// InitContext initializes a classic context for a request.
@@ -106,6 +111,7 @@ func InitContext() martini.Handler {
ctx.Data["SignedUser"] = user
ctx.Data["SignedUserId"] = user.Id
ctx.Data["SignedUserName"] = user.LowerName
+ ctx.Data["IsAdmin"] = ctx.User.IsAdmin
}
ctx.Data["PageStartTime"] = time.Now()