mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Use constants to name template file
This commit is contained in:
@@ -17,6 +17,14 @@ import (
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
const (
|
||||
DASHBOARD base.TplName = "user/dashboard"
|
||||
PROFILE base.TplName = "user/profile"
|
||||
ISSUES base.TplName = "user/issue"
|
||||
PULLS base.TplName = "user/pulls"
|
||||
STARS base.TplName = "user/stars"
|
||||
)
|
||||
|
||||
func Dashboard(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Dashboard"
|
||||
ctx.Data["PageIsUserDashboard"] = true
|
||||
@@ -52,7 +60,7 @@ func Dashboard(ctx *middleware.Context) {
|
||||
feeds = append(feeds, act)
|
||||
}
|
||||
ctx.Data["Feeds"] = feeds
|
||||
ctx.HTML(200, "user/dashboard")
|
||||
ctx.HTML(200, DASHBOARD)
|
||||
}
|
||||
|
||||
func Profile(ctx *middleware.Context, params martini.Params) {
|
||||
@@ -87,7 +95,7 @@ func Profile(ctx *middleware.Context, params martini.Params) {
|
||||
}
|
||||
}
|
||||
|
||||
ctx.HTML(200, "user/profile")
|
||||
ctx.HTML(200, PROFILE)
|
||||
}
|
||||
|
||||
func Email2User(ctx *middleware.Context) {
|
||||
@@ -254,13 +262,13 @@ func Issues(ctx *middleware.Context) {
|
||||
} else {
|
||||
ctx.Data["ShowCount"] = issueStats.OpenCount
|
||||
}
|
||||
ctx.HTML(200, "user/issue")
|
||||
ctx.HTML(200, ISSUES)
|
||||
}
|
||||
|
||||
func Pulls(ctx *middleware.Context) {
|
||||
ctx.HTML(200, "user/pulls")
|
||||
ctx.HTML(200, PULLS)
|
||||
}
|
||||
|
||||
func Stars(ctx *middleware.Context) {
|
||||
ctx.HTML(200, "user/stars")
|
||||
ctx.HTML(200, STARS)
|
||||
}
|
||||
|
@@ -14,12 +14,21 @@ import (
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
const (
|
||||
SETTING base.TplName = "user/setting"
|
||||
SOCIAL base.TplName = "user/social"
|
||||
PASSWORD base.TplName = "user/password"
|
||||
PUBLICKEY base.TplName = "user/publickey"
|
||||
NOTIFICATION base.TplName = "user/notification"
|
||||
SECURITY base.TplName = "user/security"
|
||||
)
|
||||
|
||||
func Setting(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Setting"
|
||||
ctx.Data["PageIsUserSetting"] = true
|
||||
ctx.Data["IsUserPageSetting"] = true
|
||||
ctx.Data["Owner"] = ctx.User
|
||||
ctx.HTML(200, "user/setting")
|
||||
ctx.HTML(200, SETTING)
|
||||
}
|
||||
|
||||
func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||
@@ -28,7 +37,7 @@ func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||
ctx.Data["IsUserPageSetting"] = true
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, "user/setting")
|
||||
ctx.HTML(200, SETTING)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,14 +99,14 @@ func SettingSocial(ctx *middleware.Context) {
|
||||
ctx.Handle(500, "user.SettingSocial(GetOauthByUserId)", err)
|
||||
return
|
||||
}
|
||||
ctx.HTML(200, "user/social")
|
||||
ctx.HTML(200, SOCIAL)
|
||||
}
|
||||
|
||||
func SettingPassword(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Password"
|
||||
ctx.Data["PageIsUserSetting"] = true
|
||||
ctx.Data["IsUserPageSettingPasswd"] = true
|
||||
ctx.HTML(200, "user/password")
|
||||
ctx.HTML(200, PASSWORD)
|
||||
}
|
||||
|
||||
func SettingPasswordPost(ctx *middleware.Context, form auth.UpdatePasswdForm) {
|
||||
@@ -106,7 +115,7 @@ func SettingPasswordPost(ctx *middleware.Context, form auth.UpdatePasswdForm) {
|
||||
ctx.Data["IsUserPageSettingPasswd"] = true
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, "user/password")
|
||||
ctx.HTML(200, PASSWORD)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -207,7 +216,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
||||
}
|
||||
}
|
||||
|
||||
ctx.HTML(200, "user/publickey")
|
||||
ctx.HTML(200, PUBLICKEY)
|
||||
}
|
||||
|
||||
func SettingNotification(ctx *middleware.Context) {
|
||||
@@ -215,7 +224,7 @@ func SettingNotification(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Notification"
|
||||
ctx.Data["PageIsUserSetting"] = true
|
||||
ctx.Data["IsUserPageSettingNotify"] = true
|
||||
ctx.HTML(200, "user/notification")
|
||||
ctx.HTML(200, NOTIFICATION)
|
||||
}
|
||||
|
||||
func SettingSecurity(ctx *middleware.Context) {
|
||||
@@ -223,5 +232,5 @@ func SettingSecurity(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Security"
|
||||
ctx.Data["PageIsUserSetting"] = true
|
||||
ctx.Data["IsUserPageSettingSecurity"] = true
|
||||
ctx.HTML(200, "user/security")
|
||||
ctx.HTML(200, SECURITY)
|
||||
}
|
||||
|
@@ -17,12 +17,21 @@ import (
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
SIGNIN base.TplName = "user/signin"
|
||||
SIGNUP base.TplName = "user/signup"
|
||||
DELETE base.TplName = "user/delete"
|
||||
ACTIVATE base.TplName = "user/activate"
|
||||
FORGOT_PASSWORD base.TplName = "user/forgot_passwd"
|
||||
RESET_PASSWORD base.TplName = "user/reset_passwd"
|
||||
)
|
||||
|
||||
func SignIn(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Log In"
|
||||
|
||||
if _, ok := ctx.Session.Get("socialId").(int64); ok {
|
||||
ctx.Data["IsSocialLogin"] = true
|
||||
ctx.HTML(200, "user/signin")
|
||||
ctx.HTML(200, SIGNIN)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -34,7 +43,7 @@ func SignIn(ctx *middleware.Context) {
|
||||
// Check auto-login.
|
||||
uname := ctx.GetCookie(setting.CookieUserName)
|
||||
if len(uname) == 0 {
|
||||
ctx.HTML(200, "user/signin")
|
||||
ctx.HTML(200, SIGNIN)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -57,7 +66,7 @@ func SignIn(ctx *middleware.Context) {
|
||||
secret := base.EncodeMd5(user.Rands + user.Passwd)
|
||||
value, _ := ctx.GetSecureCookie(secret, setting.CookieRememberName)
|
||||
if value != user.Name {
|
||||
ctx.HTML(200, "user/signin")
|
||||
ctx.HTML(200, SIGNIN)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -86,7 +95,7 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) {
|
||||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, "user/signin")
|
||||
ctx.HTML(200, SIGNIN)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,7 +103,7 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) {
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
log.Trace("%s Log in failed: %s", ctx.Req.RequestURI, form.UserName)
|
||||
ctx.RenderWithErr("Username or password is not correct", "user/signin", &form)
|
||||
ctx.RenderWithErr("Username or password is not correct", SIGNIN, &form)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -151,7 +160,7 @@ func SignUp(ctx *middleware.Context) {
|
||||
|
||||
if setting.Service.DisableRegistration {
|
||||
ctx.Data["DisableRegistration"] = true
|
||||
ctx.HTML(200, "user/signup")
|
||||
ctx.HTML(200, SIGNUP)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -160,7 +169,7 @@ func SignUp(ctx *middleware.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.HTML(200, "user/signup")
|
||||
ctx.HTML(200, SIGNUP)
|
||||
}
|
||||
|
||||
func oauthSignUp(ctx *middleware.Context, sid int64) {
|
||||
@@ -180,7 +189,7 @@ func oauthSignUp(ctx *middleware.Context, sid int64) {
|
||||
ctx.Data["username"] = strings.Replace(ctx.Session.Get("socialName").(string), " ", "", -1)
|
||||
ctx.Data["email"] = ctx.Session.Get("socialEmail")
|
||||
log.Trace("user.oauthSignUp(social ID): %v", ctx.Session.Get("socialId"))
|
||||
ctx.HTML(200, "user/signup")
|
||||
ctx.HTML(200, SIGNUP)
|
||||
}
|
||||
|
||||
func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||
@@ -198,14 +207,14 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, "user/signup")
|
||||
ctx.HTML(200, SIGNUP)
|
||||
return
|
||||
}
|
||||
|
||||
if form.Password != form.RetypePasswd {
|
||||
ctx.Data["Err_Password"] = true
|
||||
ctx.Data["Err_RetypePasswd"] = true
|
||||
ctx.RenderWithErr("Password and re-type password are not same.", "user/signup", &form)
|
||||
ctx.RenderWithErr("Password and re-type password are not same.", SIGNUP, &form)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -221,12 +230,12 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
|
||||
switch err {
|
||||
case models.ErrUserAlreadyExist:
|
||||
ctx.Data["Err_UserName"] = true
|
||||
ctx.RenderWithErr("Username has been already taken", "user/signup", &form)
|
||||
ctx.RenderWithErr("Username has been already taken", SIGNUP, &form)
|
||||
case models.ErrEmailAlreadyUsed:
|
||||
ctx.Data["Err_Email"] = true
|
||||
ctx.RenderWithErr("E-mail address has been already used", "user/signup", &form)
|
||||
ctx.RenderWithErr("E-mail address has been already used", SIGNUP, &form)
|
||||
case models.ErrUserNameIllegal:
|
||||
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), "user/signup", &form)
|
||||
ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), SIGNUP, &form)
|
||||
default:
|
||||
ctx.Handle(500, "user.SignUpPost(RegisterUser)", err)
|
||||
}
|
||||
@@ -265,7 +274,7 @@ func Delete(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Delete Account"
|
||||
ctx.Data["PageIsUserSetting"] = true
|
||||
ctx.Data["IsUserPageSettingDelete"] = true
|
||||
ctx.HTML(200, "user/delete")
|
||||
ctx.HTML(200, DELETE)
|
||||
}
|
||||
|
||||
func DeletePost(ctx *middleware.Context) {
|
||||
@@ -321,7 +330,7 @@ func Activate(ctx *middleware.Context) {
|
||||
} else {
|
||||
ctx.Data["ServiceNotEnabled"] = true
|
||||
}
|
||||
ctx.HTML(200, "user/activate")
|
||||
ctx.HTML(200, ACTIVATE)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -343,7 +352,7 @@ func Activate(ctx *middleware.Context) {
|
||||
}
|
||||
|
||||
ctx.Data["IsActivateFailed"] = true
|
||||
ctx.HTML(200, "user/activate")
|
||||
ctx.HTML(200, ACTIVATE)
|
||||
}
|
||||
|
||||
func ForgotPasswd(ctx *middleware.Context) {
|
||||
@@ -351,12 +360,12 @@ func ForgotPasswd(ctx *middleware.Context) {
|
||||
|
||||
if setting.MailService == nil {
|
||||
ctx.Data["IsResetDisable"] = true
|
||||
ctx.HTML(200, "user/forgot_passwd")
|
||||
ctx.HTML(200, FORGOT_PASSWORD)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["IsResetRequest"] = true
|
||||
ctx.HTML(200, "user/forgot_passwd")
|
||||
ctx.HTML(200, FORGOT_PASSWORD)
|
||||
}
|
||||
|
||||
func ForgotPasswdPost(ctx *middleware.Context) {
|
||||
@@ -381,7 +390,7 @@ func ForgotPasswdPost(ctx *middleware.Context) {
|
||||
|
||||
if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) {
|
||||
ctx.Data["ResendLimited"] = true
|
||||
ctx.HTML(200, "user/forgot_passwd")
|
||||
ctx.HTML(200, FORGOT_PASSWORD)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -393,7 +402,7 @@ func ForgotPasswdPost(ctx *middleware.Context) {
|
||||
ctx.Data["Email"] = email
|
||||
ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
|
||||
ctx.Data["IsResetSent"] = true
|
||||
ctx.HTML(200, "user/forgot_passwd")
|
||||
ctx.HTML(200, FORGOT_PASSWORD)
|
||||
}
|
||||
|
||||
func ResetPasswd(ctx *middleware.Context) {
|
||||
@@ -406,7 +415,7 @@ func ResetPasswd(ctx *middleware.Context) {
|
||||
}
|
||||
ctx.Data["Code"] = code
|
||||
ctx.Data["IsResetForm"] = true
|
||||
ctx.HTML(200, "user/reset_passwd")
|
||||
ctx.HTML(200, RESET_PASSWORD)
|
||||
}
|
||||
|
||||
func ResetPasswdPost(ctx *middleware.Context) {
|
||||
@@ -443,5 +452,5 @@ func ResetPasswdPost(ctx *middleware.Context) {
|
||||
}
|
||||
|
||||
ctx.Data["IsResetFailed"] = true
|
||||
ctx.HTML(200, "user/reset_passwd")
|
||||
ctx.HTML(200, RESET_PASSWORD)
|
||||
}
|
||||
|
Reference in New Issue
Block a user