Merge branch 'master' of github.com:gogits/gogs
Conflicts: public/js/app.js
This commit is contained in:
commit
c6bd723ce1
25 changed files with 280 additions and 58 deletions
|
@ -57,9 +57,9 @@ func processMailQueue() {
|
|||
info = ", info: " + msg.Info
|
||||
}
|
||||
log.Error(fmt.Sprintf("Async sent email %d succeed, not send emails: %s%s err: %s", num, tos, info, err))
|
||||
return
|
||||
} else {
|
||||
log.Trace(fmt.Sprintf("Async sent email %d succeed, sent emails: %s%s", num, tos, info))
|
||||
}
|
||||
log.Trace(fmt.Sprintf("Async sent email %d succeed, sent emails: %s%s", num, tos, info))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func SignInRequire(redirect bool) martini.Handler {
|
|||
return
|
||||
} else if !ctx.User.IsActive && base.Service.RegisterEmailConfirm {
|
||||
ctx.Data["Title"] = "Activate Your Account"
|
||||
ctx.Render.HTML(200, "user/active", ctx.Data)
|
||||
ctx.HTML(200, "user/active")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,18 @@ func SignOutRequire() martini.Handler {
|
|||
return func(ctx *Context) {
|
||||
if ctx.IsSigned {
|
||||
ctx.Redirect("/")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AdminRequire requires user signed in as administor.
|
||||
func AdminRequire() martini.Handler {
|
||||
return func(ctx *Context) {
|
||||
if !ctx.User.IsAdmin {
|
||||
ctx.Error(403)
|
||||
return
|
||||
}
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -65,9 +65,12 @@ func RepoAssignment(redirect bool) martini.Handler {
|
|||
}
|
||||
|
||||
ctx.Repo.IsValid = true
|
||||
ctx.Repo.IsWatching = models.IsWatching(ctx.User.Id, repo.Id)
|
||||
if ctx.User != nil {
|
||||
ctx.Repo.IsWatching = models.IsWatching(ctx.User.Id, repo.Id)
|
||||
}
|
||||
ctx.Repo.Repository = repo
|
||||
ctx.Repo.CloneLink.SSH = fmt.Sprintf("git@%s:%s/%s.git", base.Domain, ctx.User.LowerName, repo.LowerName)
|
||||
ctx.Repo.CloneLink.SSH = fmt.Sprintf("git@%s:%s/%s.git", base.Domain, user.LowerName, repo.LowerName)
|
||||
ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("https://%s/%s/%s.git", base.Domain, user.LowerName, repo.LowerName)
|
||||
|
||||
ctx.Data["IsRepositoryValid"] = true
|
||||
ctx.Data["Repository"] = repo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue