Parcourir la source

Updated GoReport #100

Yoginth il y a 7 ans
Parent
commit
175a4233a4

+ 2 - 2
routes/user/auth.go

@@ -482,10 +482,10 @@ func Activate(c *context.Context) {
 //ActivateEmail is the handler to activate the user email
 func ActivateEmail(c *context.Context) {
 	code := c.Query("code")
-	email_string := c.Query("email")
+	emailString := c.Query("email")
 
 	// Verify code.
-	if email := models.VerifyActiveEmailCode(code, email_string); email != nil {
+	if email := models.VerifyActiveEmailCode(code, emailString); email != nil {
 		if err := email.Activate(); err != nil {
 			c.ServerError("ActivateEmail", err)
 		}

+ 1 - 0
routes/user/certificate.go

@@ -16,6 +16,7 @@ const (
 	InterCertificateTPL = "misc/internscert"
 )
 
+// InternCertificate returns user details for the certificate
 func InternCertificate(c *context.Context) {
 	ctxUser := GetUserByName(c, strings.TrimSuffix(c.Params(":username"), ""))
 	c.Data["Owner"] = ctxUser

+ 1 - 0
routes/user/embed.go

@@ -16,6 +16,7 @@ const (
 	EmbedTPL = "embed/user"
 )
 
+// Embed returns user details for the embed
 func Embed(c *context.Context) {
 	ctxUser := GetUserByName(c, strings.TrimSuffix(c.Params(":username"), ""))
 	c.Data["Owner"] = ctxUser

+ 4 - 0
routes/user/home.go

@@ -98,6 +98,7 @@ func retrieveFeeds(c *context.Context, ctxUser *models.User, userID int64, isPro
 	}
 }
 
+// Dashboard shows dashboard page
 func Dashboard(c *context.Context) {
 	ctxUser := getDashboardContextUser(c)
 	if c.Written() {
@@ -175,6 +176,7 @@ func Dashboard(c *context.Context) {
 	c.HTML(200, DashboardTPL)
 }
 
+// Issues shows issues page
 func Issues(c *context.Context) {
 	isPullList := c.Params(":type") == "pulls"
 	if isPullList {
@@ -355,6 +357,7 @@ func Issues(c *context.Context) {
 	c.HTML(200, IssuesTPL)
 }
 
+// ShowSSHKeys shows user ssh keys in plain text
 func ShowSSHKeys(c *context.Context, uid int64) {
 	keys, err := models.ListPublicKeys(uid)
 	if err != nil {
@@ -425,6 +428,7 @@ func showOrgProfile(c *context.Context) {
 	c.HTML(200, OrgHomeTPL)
 }
 
+// Email2User redirects to email user page
 func Email2User(c *context.Context) {
 	u, err := models.GetUserByEmail(c.Query("email"))
 	if err != nil {

+ 6 - 0
routes/user/profile.go

@@ -27,6 +27,7 @@ const (
 	StarsTPL = "user/meta/stars"
 )
 
+// GetUserByName get user name as parameter from URL
 func GetUserByName(c *context.Context, name string) *models.User {
 	user, err := models.GetUserByName(name)
 	if err != nil {
@@ -36,6 +37,7 @@ func GetUserByName(c *context.Context, name string) *models.User {
 	return user
 }
 
+// Profile shows profile page
 func Profile(c *context.Context, puser *context.ParamsUser) {
 	isShowKeys := false
 	if strings.HasSuffix(c.Params(":username"), ".keys") {
@@ -101,6 +103,7 @@ func Profile(c *context.Context, puser *context.ParamsUser) {
 	}
 }
 
+// Followers shows followers page
 func Followers(c *context.Context, puser *context.ParamsUser) {
 	c.Title(puser.DisplayName())
 	c.PageIs("Followers")
@@ -109,6 +112,7 @@ func Followers(c *context.Context, puser *context.ParamsUser) {
 	repo.RenderUserCards(c, puser.NumFollowers, puser.GetFollowers, FollowersTPL)
 }
 
+// Following shows following page
 func Following(c *context.Context, puser *context.ParamsUser) {
 	c.Title(puser.DisplayName())
 	c.PageIs("Following")
@@ -117,10 +121,12 @@ func Following(c *context.Context, puser *context.ParamsUser) {
 	repo.RenderUserCards(c, puser.NumFollowing, puser.GetFollowing, FollowersTPL)
 }
 
+// Stars shows stars page
 func Stars(c *context.Context) {
 
 }
 
+// Action shows user action page
 func Action(c *context.Context, puser *context.ParamsUser) {
 	var err error
 	switch c.Params(":action") {

+ 31 - 1
routes/user/setting.go

@@ -76,6 +76,7 @@ const (
 	NotificationTPL = "user/notification"
 )
 
+// Settings shows settings page
 func Settings(c *context.Context) {
 	c.Title("settings.profile")
 	c.PageIs("SettingsProfile")
@@ -97,6 +98,7 @@ func Settings(c *context.Context) {
 	c.Success(SettingsProfileTPL)
 }
 
+// SettingsPost updates user settings
 func SettingsPost(c *context.Context, f form.UpdateProfile) {
 	c.Title("settings.profile")
 	c.PageIs("SettingsProfile")
@@ -172,6 +174,7 @@ func SettingsPost(c *context.Context, f form.UpdateProfile) {
 	c.SubURLRedirect("/user/settings")
 }
 
+// SettingsSocial shows user social settings page
 func SettingsSocial(c *context.Context) {
 	c.Title("settings.social")
 	c.PageIs("SettingsSocial")
@@ -188,6 +191,7 @@ func SettingsSocial(c *context.Context) {
 	c.Success(SettingsSocialTPL)
 }
 
+// SettingsSocialPost updates user social settings
 func SettingsSocialPost(c *context.Context, f form.UpdateSocial) {
 	c.Title("settings.profile")
 	c.PageIs("SettingsProfile")
@@ -216,7 +220,7 @@ func SettingsSocialPost(c *context.Context, f form.UpdateSocial) {
 	c.SubURLRedirect("/user/settings/social")
 }
 
-// FIXME: limit upload size
+// UpdateAvatarSetting FIXME: limit upload size
 func UpdateAvatarSetting(c *context.Context, f form.Avatar, ctxUser *models.User) error {
 	ctxUser.UseCustomAvatar = f.Source == form.AVATAR_LOCAL
 	if len(f.Gravatar) > 0 {
@@ -259,12 +263,14 @@ func UpdateAvatarSetting(c *context.Context, f form.Avatar, ctxUser *models.User
 	return nil
 }
 
+// SettingsAvatar shows user avatar settings page
 func SettingsAvatar(c *context.Context) {
 	c.Title("settings.avatar")
 	c.PageIs("SettingsAvatar")
 	c.Success(SettingsAvatarTPL)
 }
 
+// SettingsAvatarPost updates user avatar settings
 func SettingsAvatarPost(c *context.Context, f form.Avatar) {
 	if err := UpdateAvatarSetting(c, f, c.User); err != nil {
 		c.Flash.Error(err.Error())
@@ -275,6 +281,7 @@ func SettingsAvatarPost(c *context.Context, f form.Avatar) {
 	c.SubURLRedirect("/user/settings/avatar")
 }
 
+// SettingsDeleteAvatar shows user delete avatar settings page
 func SettingsDeleteAvatar(c *context.Context) {
 	if err := c.User.DeleteAvatar(); err != nil {
 		c.Flash.Error(fmt.Sprintf("Failed to delete avatar: %v", err))
@@ -283,12 +290,14 @@ func SettingsDeleteAvatar(c *context.Context) {
 	c.SubURLRedirect("/user/settings/avatar")
 }
 
+// SettingsPassword shows user password settings page
 func SettingsPassword(c *context.Context) {
 	c.Title("settings.password")
 	c.PageIs("SettingsPassword")
 	c.Success(SettingsPasswordTPL)
 }
 
+// SettingsPasswordPost updates user password settings
 func SettingsPasswordPost(c *context.Context, f form.ChangePassword) {
 	c.Title("settings.password")
 	c.PageIs("SettingsPassword")
@@ -320,6 +329,7 @@ func SettingsPasswordPost(c *context.Context, f form.ChangePassword) {
 	c.SubURLRedirect("/user/settings/password")
 }
 
+// SettingsEmails shows user email settings page
 func SettingsEmails(c *context.Context) {
 	c.Title("settings.emails")
 	c.PageIs("SettingsEmails")
@@ -334,6 +344,7 @@ func SettingsEmails(c *context.Context) {
 	c.Success(SettingsEmailsTPL)
 }
 
+// SettingsEmailPost updates user email settings
 func SettingsEmailPost(c *context.Context, f form.AddEmail) {
 	c.Title("settings.emails")
 	c.PageIs("SettingsEmails")
@@ -392,6 +403,7 @@ func SettingsEmailPost(c *context.Context, f form.AddEmail) {
 	c.SubURLRedirect("/user/settings/email")
 }
 
+// DeleteEmail shows user delete email settings page
 func DeleteEmail(c *context.Context) {
 	if err := models.DeleteEmailAddress(&models.EmailAddress{
 		ID:  c.QueryInt64("id"),
@@ -407,6 +419,7 @@ func DeleteEmail(c *context.Context) {
 	})
 }
 
+// SettingsSSHKeys shows user SSH settings page
 func SettingsSSHKeys(c *context.Context) {
 	c.Title("settings.ssh_keys")
 	c.PageIs("SettingsSSHKeys")
@@ -421,6 +434,7 @@ func SettingsSSHKeys(c *context.Context) {
 	c.Success(SettingsSSHKeysTPL)
 }
 
+// SettingsSSHKeysPost updates user SSH settings
 func SettingsSSHKeysPost(c *context.Context, f form.AddSSHKey) {
 	c.Title("settings.ssh_keys")
 	c.PageIs("SettingsSSHKeys")
@@ -467,6 +481,7 @@ func SettingsSSHKeysPost(c *context.Context, f form.AddSSHKey) {
 	c.SubURLRedirect("/user/settings/ssh")
 }
 
+// DeleteSSHKey shows user SSH delete settings page
 func DeleteSSHKey(c *context.Context) {
 	if err := models.DeletePublicKey(c.User, c.QueryInt64("id")); err != nil {
 		c.Flash.Error("DeletePublicKey: " + err.Error())
@@ -479,6 +494,7 @@ func DeleteSSHKey(c *context.Context) {
 	})
 }
 
+// SettingsSecurity shows user security settings page
 func SettingsSecurity(c *context.Context) {
 	c.Title("settings.security")
 	c.PageIs("SettingsSecurity")
@@ -493,6 +509,7 @@ func SettingsSecurity(c *context.Context) {
 	c.Success(SettingsSecurityTPL)
 }
 
+// SettingsTwoFactorEnable shows user 2FA settings page
 func SettingsTwoFactorEnable(c *context.Context) {
 	if c.User.IsEnabledTwoFactor() {
 		c.NotFound()
@@ -538,6 +555,7 @@ func SettingsTwoFactorEnable(c *context.Context) {
 	c.Success(SettingsTwoFactorEnableTPL)
 }
 
+// SettingsTwoFactorEnablePost updates user 2FA settings
 func SettingsTwoFactorEnablePost(c *context.Context) {
 	secret, ok := c.Session.Get("twoFactorSecret").(string)
 	if !ok {
@@ -563,6 +581,7 @@ func SettingsTwoFactorEnablePost(c *context.Context) {
 	c.SubURLRedirect("/user/settings/security/two_factor_recovery_codes")
 }
 
+// SettingsTwoFactorRecoveryCodes shows user 2FA recovery settings page
 func SettingsTwoFactorRecoveryCodes(c *context.Context) {
 	if !c.User.IsEnabledTwoFactor() {
 		c.NotFound()
@@ -582,6 +601,7 @@ func SettingsTwoFactorRecoveryCodes(c *context.Context) {
 	c.Success(SettingsTwoFactorRecoveryCodesTPL)
 }
 
+// SettingsTwoFactorRecoveryCodesPost updates user 2FA recovery settings
 func SettingsTwoFactorRecoveryCodesPost(c *context.Context) {
 	if !c.User.IsEnabledTwoFactor() {
 		c.NotFound()
@@ -597,6 +617,7 @@ func SettingsTwoFactorRecoveryCodesPost(c *context.Context) {
 	c.SubURLRedirect("/user/settings/security/two_factor_recovery_codes")
 }
 
+// SettingsTwoFactorDisable shows user disable 2FA settings page
 func SettingsTwoFactorDisable(c *context.Context) {
 	if !c.User.IsEnabledTwoFactor() {
 		c.NotFound()
@@ -614,6 +635,7 @@ func SettingsTwoFactorDisable(c *context.Context) {
 	})
 }
 
+// SettingsRepos shows user repo settings page
 func SettingsRepos(c *context.Context) {
 	c.Title("settings.repos")
 	c.PageIs("SettingsRepositories")
@@ -632,6 +654,7 @@ func SettingsRepos(c *context.Context) {
 	c.Success(SettingsRepositoriesTPL)
 }
 
+// SettingsLeaveRepo shows user leave repo settings page
 func SettingsLeaveRepo(c *context.Context) {
 	repo, err := models.GetRepositoryByID(c.QueryInt64("id"))
 	if err != nil {
@@ -650,6 +673,7 @@ func SettingsLeaveRepo(c *context.Context) {
 	})
 }
 
+// SettingsOrganizations shows org settings page
 func SettingsOrganizations(c *context.Context) {
 	c.Title("settings.orgs")
 	c.PageIs("SettingsOrganizations")
@@ -664,6 +688,7 @@ func SettingsOrganizations(c *context.Context) {
 	c.Success(SettingsOrganizationsTPL)
 }
 
+// SettingsLeaveOrganization shows user leave org settings page
 func SettingsLeaveOrganization(c *context.Context) {
 	if err := models.RemoveOrgUser(c.QueryInt64("id"), c.User.ID); err != nil {
 		if models.IsErrLastOrgOwner(err) {
@@ -679,6 +704,7 @@ func SettingsLeaveOrganization(c *context.Context) {
 	})
 }
 
+// SettingsApplications shows application settings page
 func SettingsApplications(c *context.Context) {
 	c.Title("settings.applications")
 	c.PageIs("SettingsApplications")
@@ -693,6 +719,7 @@ func SettingsApplications(c *context.Context) {
 	c.Success(SettingsApplicationsTPL)
 }
 
+// SettingsApplicationsPost updates application settings
 func SettingsApplicationsPost(c *context.Context, f form.NewAccessToken) {
 	c.Title("settings.applications")
 	c.PageIs("SettingsApplications")
@@ -723,6 +750,7 @@ func SettingsApplicationsPost(c *context.Context, f form.NewAccessToken) {
 	c.SubURLRedirect("/user/settings/applications")
 }
 
+// SettingsDeleteApplication shows delete application settings page
 func SettingsDeleteApplication(c *context.Context) {
 	if err := models.DeleteAccessTokenOfUserByID(c.User.ID, c.QueryInt64("id")); err != nil {
 		c.Flash.Error("DeleteAccessTokenByID: " + err.Error())
@@ -735,6 +763,7 @@ func SettingsDeleteApplication(c *context.Context) {
 	})
 }
 
+// SettingsEmbeds shows user embed settings page
 func SettingsEmbeds(c *context.Context) {
 	c.Title("settings.embeds")
 	c.PageIs("SettingsEmbeds")
@@ -742,6 +771,7 @@ func SettingsEmbeds(c *context.Context) {
 	c.Success(SettingsEmbedsTPL)
 }
 
+// SettingsDelete shows user delete settings page
 func SettingsDelete(c *context.Context) {
 	c.Title("settings.delete")
 	c.PageIs("SettingsDelete")

+ 2 - 0
routes/user/sitemap.go

@@ -11,12 +11,14 @@ import (
 	"net/http"
 )
 
+// Urlset stores sitemap tags
 type Urlset struct {
 	Loc        string `xml:"url>loc"`
 	Changefreq string `xml:"url>changefreq"`
 	Priority   string `xml:"url>priority"`
 }
 
+// Sitemap shows users sitemap
 func Sitemap(w http.ResponseWriter, r *http.Request) {
 	profile := Urlset{"https://gitote.in/", "Daily", "1.0"}
 

+ 1 - 1
templates/admin/auth/edit.tmpl

@@ -172,7 +172,7 @@
 							{{ $cfg:=.Source.GitHub }}
 							<div class="required field">
 								<label for="github_api_endpoint">{{.i18n.Tr "admin.auths.github_api_endpoint"}}</label>
-								<input id="github_api_endpoint" name="github_api_endpoint" value="{{$cfg.APIEndpoint}}" placeholder="e.g. https://api.github.com" required>
+								<input id="github_api_endpoint" name="github_api_endpoint" value="{{$cfg.APIEndpoint}}" placeholder="e.g. https://api.github.com/" required>
 							</div>
 						{{end}}
 						<div class="inline field {{if not .Source.IsSMTP}}hide{{end}}">