diff --git a/modules/context/context.go b/modules/context/context.go index f543e766d..04f4ba3ee 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -79,12 +79,17 @@ func (ctx *Context) HasValue(name string) bool { return ok } -// HTML calls Context.HTML and converts template name to string. +// HTML responses template with given status. func (ctx *Context) HTML(status int, name base.TplName) { log.Trace("Template: %s", name) ctx.Context.HTML(status, string(name)) } +// Success responses template with status 200. +func (c *Context) Success(name base.TplName) { + c.HTML(200, name) +} + // RenderWithErr used for page has form validation but need to prompt error to users. func (ctx *Context) RenderWithErr(msg string, tpl base.TplName, f interface{}) { if f != nil { diff --git a/routers/user/setting.go b/routers/user/setting.go index 9138ba04b..e1fabb48b 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -36,10 +36,16 @@ const ( SECURITY base.TplName = "user/security" ) -func Settings(ctx *context.Context) { - ctx.Data["Title"] = ctx.Tr("settings") - ctx.Data["PageIsSettingsProfile"] = true - ctx.HTML(200, SETTINGS_PROFILE) +func Settings(c *context.Context) { + c.Data["Title"] = c.Tr("settings") + c.Data["PageIsSettingsProfile"] = true + c.Data["origin_name"] = c.User.Name + c.Data["name"] = c.User.Name + c.Data["full_name"] = c.User.FullName + c.Data["email"] = c.User.Email + c.Data["website"] = c.User.Website + c.Data["location"] = c.User.Location + c.Success(SETTINGS_PROFILE) } func handleUsernameChange(ctx *context.Context, newName string) { @@ -80,6 +86,7 @@ func handleUsernameChange(ctx *context.Context, newName string) { func SettingsPost(ctx *context.Context, f form.UpdateProfile) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsProfile"] = true + ctx.Data["origin_name"] = ctx.User.Name if ctx.HasError() { ctx.HTML(200, SETTINGS_PROFILE) diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index 731853c3d..aab54a826 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -13,27 +13,27 @@