aboutsummaryrefslogtreecommitdiff
path: root/modules/middleware/context.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/middleware/context.go')
-rw-r--r--modules/middleware/context.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/modules/middleware/context.go b/modules/middleware/context.go
index dc3b5cad..2995d578 100644
--- a/modules/middleware/context.go
+++ b/modules/middleware/context.go
@@ -106,6 +106,12 @@ func (ctx *Context) HasError() bool {
return hasErr.(bool)
}
+// HasValue returns true if value of given name exists.
+func (ctx *Context) HasValue(name string) bool {
+ _, ok := ctx.Data[name]
+ return ok
+}
+
// HTML calls Context.HTML and converts template name to string.
func (ctx *Context) HTML(status int, name base.TplName) {
ctx.Context.HTML(status, string(name))
@@ -139,6 +145,13 @@ func (ctx *Context) Handle(status int, title string, err error) {
ctx.HTML(status, base.TplName(fmt.Sprintf("status/%d", status)))
}
+func (ctx *Context) HandleText(status int, title string) {
+ if (status/100 == 4) || (status/100 == 5) {
+ log.Error(4, "%s", title)
+ }
+ ctx.RenderData(status, []byte(title))
+}
+
func (ctx *Context) HandleAPI(status int, obj interface{}) {
var message string
if err, ok := obj.(error); ok {
@@ -180,12 +193,7 @@ func Contexter() macaron.Handler {
Session: sess,
}
// Compute current URL for real-time change language.
- link := setting.AppSubUrl + ctx.Req.RequestURI
- i := strings.Index(link, "?")
- if i > -1 {
- link = link[:i]
- }
- ctx.Data["Link"] = link
+ ctx.Data["Link"] = setting.AppSubUrl + ctx.Req.URL.Path
ctx.Data["PageStartTime"] = time.Now()
@@ -214,6 +222,7 @@ func Contexter() macaron.Handler {
ctx.Data["CsrfTokenHtml"] = template.HTML(`<input type="hidden" name="_csrf" value="` + x.GetToken() + `">`)
ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton
+ ctx.Data["ShowFooterBranding"] = setting.ShowFooterBranding
c.Map(ctx)
}