Kaynağa Gözat

Fixed GoStandards in admin routes

Yoginth 7 yıl önce
ebeveyn
işleme
9c6357b4b8

+ 12 - 12
routes/admin/admin.go

@@ -25,17 +25,17 @@ import (
 )
 
 const (
-	// DASHBOARD page template
-	DASHBOARD = "admin/dashboard"
+	// DashboardTPL page template
+	DashboardTPL = "admin/dashboard"
 
-	// ANALYTICS page template
-	ANALYTICS = "admin/analytics"
+	// AnalyticsTPL page template
+	AnalyticsTPL = "admin/analytics"
 
-	// CONFIG page template
-	CONFIG = "admin/config"
+	// ConfigTPL page template
+	ConfigTPL = "admin/config"
 
-	// MONITOR page template
-	MONITOR = "admin/monitor"
+	// MonitorTPL page template
+	MonitorTPL = "admin/monitor"
 )
 
 var (
@@ -194,7 +194,7 @@ func Dashboard(c *context.Context) {
 	updateSystemStatus()
 	c.Data["SysStatus"] = sysStatus
 	c.Data["GitVersion"] = setting.Git.Version
-	c.HTML(200, DASHBOARD)
+	c.HTML(200, DashboardTPL)
 }
 
 // SendTestMail send mail to verify the email
@@ -269,7 +269,7 @@ func Config(c *context.Context) {
 	}
 	c.Data["Loggers"] = loggers
 
-	c.HTML(200, CONFIG)
+	c.HTML(200, ConfigTPL)
 }
 
 // Monitor shows monitor page
@@ -279,12 +279,12 @@ func Monitor(c *context.Context) {
 	c.Data["PageIsAdminMonitor"] = true
 	c.Data["Processes"] = process.Processes
 	c.Data["Entries"] = cron.ListTasks()
-	c.HTML(200, MONITOR)
+	c.HTML(200, MonitorTPL)
 }
 
 // Analytics shows analytics page
 func Analytics(c *context.Context) {
 	c.Data["Title"] = "Analytics"
 	c.Data["PageIsAdminAnalytics"] = true
-	c.HTML(200, ANALYTICS)
+	c.HTML(200, AnalyticsTPL)
 }

+ 12 - 12
routes/admin/auths.go

@@ -22,14 +22,14 @@ import (
 )
 
 const (
-	// AUTHS list page template
-	AUTHS = "admin/auth/list"
+	// AuthsTPL list page template
+	AuthsTPL = "admin/auth/list"
 
-	// AUTH_NEW page template
-	AUTH_NEW = "admin/auth/new"
+	// AuthNewTPL page template
+	AuthNewTPL = "admin/auth/new"
 
-	// AUTH_EDIT page template
-	AUTH_EDIT = "admin/auth/edit"
+	// AuthEditTPL page template
+	AuthEditTPL = "admin/auth/edit"
 )
 
 // Authentications shows authentication page
@@ -46,7 +46,7 @@ func Authentications(c *context.Context) {
 	}
 
 	c.Data["Total"] = models.CountLoginSources()
-	c.Success(AUTHS)
+	c.Success(AuthsTPL)
 }
 
 type dropdownItem struct {
@@ -84,7 +84,7 @@ func NewAuthSource(c *context.Context) {
 	c.Data["AuthSources"] = authSources
 	c.Data["SecurityProtocols"] = securityProtocols
 	c.Data["SMTPAuths"] = models.SMTPAuths
-	c.Success(AUTH_NEW)
+	c.Success(AuthNewTPL)
 }
 
 func parseLDAPConfig(f form.Authentication) *models.LDAPConfig {
@@ -161,7 +161,7 @@ func NewAuthSourcePost(c *context.Context, f form.Authentication) {
 	c.Data["HasTLS"] = hasTLS
 
 	if c.HasError() {
-		c.Success(AUTH_NEW)
+		c.Success(AuthNewTPL)
 		return
 	}
 
@@ -174,7 +174,7 @@ func NewAuthSourcePost(c *context.Context, f form.Authentication) {
 	}); err != nil {
 		if models.IsErrLoginSourceAlreadyExist(err) {
 			c.FormErr("Name")
-			c.RenderWithErr(c.Tr("admin.auths.login_source_exist", err.(models.ErrLoginSourceAlreadyExist).Name), AUTH_NEW, f)
+			c.RenderWithErr(c.Tr("admin.auths.login_source_exist", err.(models.ErrLoginSourceAlreadyExist).Name), AuthNewTPL, f)
 		} else {
 			c.ServerError("CreateSource", err)
 		}
@@ -204,7 +204,7 @@ func EditAuthSource(c *context.Context) {
 	c.Data["Source"] = source
 	c.Data["HasTLS"] = source.HasTLS()
 
-	c.Success(AUTH_EDIT)
+	c.Success(AuthEditTPL)
 }
 
 // EditAuthSourcePost edits an auth source
@@ -224,7 +224,7 @@ func EditAuthSourcePost(c *context.Context, f form.Authentication) {
 	c.Data["HasTLS"] = source.HasTLS()
 
 	if c.HasError() {
-		c.Success(AUTH_EDIT)
+		c.Success(AuthEditTPL)
 		return
 	}
 

+ 0 - 23
routes/admin/inbox.go

@@ -1,23 +0,0 @@
-// Copyright 2015 The Gogs Authors. All rights reserved.
-// Copyright 2018 Gitote. All rights reserved.
-//
-// This source code is licensed under the MIT license found in the
-// LICENSE file in the root directory of this source tree.
-
-package admin
-
-import (
-	"gitote/gitote/pkg/context"
-)
-
-const (
-	// INBOX page template
-	INBOX = "admin/inbox"
-)
-
-// Inbox shows admin inbox page
-func Inbox(c *context.Context) {
-	c.Data["Title"] = "Inbox"
-	c.Data["PageIsAdminInbox"] = true
-	c.HTML(200, INBOX)
-}

+ 9 - 9
routes/admin/news.go

@@ -11,33 +11,33 @@ import (
 )
 
 const (
-	// NEWS list page template
-	NEWS = "admin/news/list"
+	// NewsTPL list page template
+	NewsTPL = "admin/news/list"
 
-	// NEWS_NEW page template
-	NEWS_NEW = "admin/news/new"
+	// NewsNewTPL page template
+	NewsNewTPL = "admin/news/new"
 
-	// NEWS_EDIT page template
-	NEWS_EDIT = "admin/news/edit"
+	// NewsEditTPL page template
+	NewsEditTPL = "admin/news/edit"
 )
 
 // News shows news page
 func News(c *context.Context) {
 	c.Data["Title"] = "News"
 	c.Data["PageIsAdminNews"] = true
-	c.HTML(200, NEWS)
+	c.HTML(200, NewsTPL)
 }
 
 // News shows news page
 func NewsNew(c *context.Context) {
 	c.Data["Title"] = "News"
 	c.Data["PageIsAdminNews"] = true
-	c.HTML(200, NEWS_NEW)
+	c.HTML(200, NewsNewTPL)
 }
 
 // News shows news page
 func NewsEdit(c *context.Context) {
 	c.Data["Title"] = "News"
 	c.Data["PageIsAdminNews"] = true
-	c.HTML(200, NEWS_EDIT)
+	c.HTML(200, NewsEditTPL)
 }

+ 3 - 3
routes/admin/notice.go

@@ -17,8 +17,8 @@ import (
 )
 
 const (
-	// NOTICES page template
-	NOTICES = "admin/notice"
+	// NoticesTPL page template
+	NoticesTPL = "admin/notice"
 )
 
 // Notices shows admin notices page
@@ -42,7 +42,7 @@ func Notices(c *context.Context) {
 	c.Data["Notices"] = notices
 
 	c.Data["Total"] = total
-	c.HTML(200, NOTICES)
+	c.HTML(200, NoticesTPL)
 }
 
 // DeleteNotices deletes notices

+ 3 - 3
routes/admin/orgs.go

@@ -14,8 +14,8 @@ import (
 )
 
 const (
-	// ORGS list page template
-	ORGS = "admin/org/list"
+	// OrgsTPL list page template
+	OrgsTPL = "admin/org/list"
 )
 
 // Organizations shows organizations page
@@ -30,6 +30,6 @@ func Organizations(c *context.Context) {
 		Ranger:   models.Organizations,
 		PageSize: setting.UI.Admin.OrgPagingNum,
 		OrderBy:  "id ASC",
-		TplName:  ORGS,
+		TplName:  OrgsTPL,
 	})
 }

+ 3 - 3
routes/admin/repos.go

@@ -16,8 +16,8 @@ import (
 )
 
 const (
-	// REPOS list page template
-	REPOS = "admin/repo/list"
+	// ReposTPL list page template
+	ReposTPL = "admin/repo/list"
 )
 
 // Repos shows repositories page
@@ -68,7 +68,7 @@ func Repos(c *context.Context) {
 	}
 	c.Data["Repos"] = repos
 
-	c.HTML(200, REPOS)
+	c.HTML(200, ReposTPL)
 }
 
 // DeleteRepo deletes a repository

+ 16 - 16
routes/admin/users.go

@@ -20,14 +20,14 @@ import (
 )
 
 const (
-	// USERS list page template
-	USERS = "admin/user/list"
+	// UsersTPL list page template
+	UsersTPL = "admin/user/list"
 
-	// USER_NEW page template
-	USER_NEW = "admin/user/new"
+	// UserNewTPL page template
+	UserNewTPL = "admin/user/new"
 
-	// USER_EDIT page template
-	USER_EDIT = "admin/user/edit"
+	// UserEditTPL page template
+	UserEditTPL = "admin/user/edit"
 )
 
 // Users shows users page
@@ -42,7 +42,7 @@ func Users(c *context.Context) {
 		Ranger:   models.Users,
 		PageSize: setting.UI.Admin.UserPagingNum,
 		OrderBy:  "id ASC",
-		TplName:  USERS,
+		TplName:  UsersTPL,
 	})
 }
 
@@ -62,7 +62,7 @@ func NewUser(c *context.Context) {
 	c.Data["Sources"] = sources
 
 	c.Data["CanSendEmail"] = setting.MailService != nil
-	c.HTML(200, USER_NEW)
+	c.HTML(200, UserNewTPL)
 }
 
 // NewUserPost creates a new user
@@ -81,7 +81,7 @@ func NewUserPost(c *context.Context, f form.AdminCrateUser) {
 	c.Data["CanSendEmail"] = setting.MailService != nil
 
 	if c.HasError() {
-		c.HTML(200, USER_NEW)
+		c.HTML(200, UserNewTPL)
 		return
 	}
 
@@ -108,16 +108,16 @@ func NewUserPost(c *context.Context, f form.AdminCrateUser) {
 		switch {
 		case models.IsErrUserAlreadyExist(err):
 			c.Data["Err_UserName"] = true
-			c.RenderWithErr(c.Tr("form.username_been_taken"), USER_NEW, &f)
+			c.RenderWithErr(c.Tr("form.username_been_taken"), UserNewTPL, &f)
 		case models.IsErrEmailAlreadyUsed(err):
 			c.Data["Err_Email"] = true
-			c.RenderWithErr(c.Tr("form.email_been_used"), USER_NEW, &f)
+			c.RenderWithErr(c.Tr("form.email_been_used"), UserNewTPL, &f)
 		case models.IsErrNameReserved(err):
 			c.Data["Err_UserName"] = true
-			c.RenderWithErr(c.Tr("user.form.name_reserved", err.(models.ErrNameReserved).Name), USER_NEW, &f)
+			c.RenderWithErr(c.Tr("user.form.name_reserved", err.(models.ErrNameReserved).Name), UserNewTPL, &f)
 		case models.IsErrNamePatternNotAllowed(err):
 			c.Data["Err_UserName"] = true
-			c.RenderWithErr(c.Tr("user.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), USER_NEW, &f)
+			c.RenderWithErr(c.Tr("user.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), UserNewTPL, &f)
 		default:
 			c.Handle(500, "CreateUser", err)
 		}
@@ -174,7 +174,7 @@ func EditUser(c *context.Context) {
 		return
 	}
 
-	c.HTML(200, USER_EDIT)
+	c.HTML(200, UserEditTPL)
 }
 
 // EditUserPost edits an user
@@ -190,7 +190,7 @@ func EditUserPost(c *context.Context, f form.AdminEditUser) {
 	}
 
 	if c.HasError() {
-		c.HTML(200, USER_EDIT)
+		c.HTML(200, UserEditTPL)
 		return
 	}
 
@@ -252,7 +252,7 @@ func EditUserPost(c *context.Context, f form.AdminEditUser) {
 	if err := models.UpdateUser(u); err != nil {
 		if models.IsErrEmailAlreadyUsed(err) {
 			c.Data["Err_Email"] = true
-			c.RenderWithErr(c.Tr("form.email_been_used"), USER_EDIT, &f)
+			c.RenderWithErr(c.Tr("form.email_been_used"), UserEditTPL, &f)
 		} else {
 			c.Handle(500, "UpdateUser", err)
 		}

+ 9 - 4
routes/repo/branch.go

@@ -19,8 +19,11 @@ import (
 )
 
 const (
-	BRANCHES_OVERVIEW = "repo/branches/overview"
-	BRANCHES_ALL      = "repo/branches/all"
+	// BranchesOverview page template
+	BranchesOverview = "repo/branches/overview"
+
+	// BranchesAll page template
+	BranchesAll = "repo/branches/all"
 )
 
 type Branch struct {
@@ -67,6 +70,7 @@ func loadBranches(c *context.Context) []*Branch {
 	return branches
 }
 
+// Branches shows branches page
 func Branches(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.git_branches")
 	c.Data["PageIsBranchesOverview"] = true
@@ -92,9 +96,10 @@ func Branches(c *context.Context) {
 
 	c.Data["ActiveBranches"] = activeBranches
 	c.Data["StaleBranches"] = staleBranches
-	c.HTML(200, BRANCHES_OVERVIEW)
+	c.HTML(200, BranchesOverview)
 }
 
+// AllBranches shows all branches page
 func AllBranches(c *context.Context) {
 	c.Data["Title"] = c.Tr("repo.git_branches")
 	c.Data["PageIsBranchesAll"] = true
@@ -105,7 +110,7 @@ func AllBranches(c *context.Context) {
 	}
 	c.Data["Branches"] = branches
 
-	c.HTML(200, BRANCHES_ALL)
+	c.HTML(200, BranchesAll)
 }
 
 func DeleteBranchPost(c *context.Context) {

+ 4 - 1
routes/repo/commit.go

@@ -18,8 +18,11 @@ import (
 )
 
 const (
+	// COMMITS page template
 	COMMITS = "repo/commits"
-	DIFF    = "repo/diff/page"
+
+	// DIFF page template
+	DIFF = "repo/diff/page"
 )
 
 func RefCommits(c *context.Context) {

+ 10 - 3
routes/repo/editor.go

@@ -25,10 +25,17 @@ import (
 )
 
 const (
-	EDIT_FILE         = "repo/editor/edit"
+	// EDIT_FILE page template
+	EDIT_FILE = "repo/editor/edit"
+
+	// EDIT_DIFF_PREVIEW page template
 	EDIT_DIFF_PREVIEW = "repo/editor/diff_preview"
-	DELETE_FILE       = "repo/editor/delete"
-	UPLOAD_FILE       = "repo/editor/upload"
+
+	// DELETE_FILE page template
+	DELETE_FILE = "repo/editor/delete"
+
+	// UPLOAD_FILE page template
+	UPLOAD_FILE = "repo/editor/upload"
 )
 
 // getParentTreeFields returns list of parent tree names and corresponding tree paths

+ 16 - 4
routes/repo/issue.go

@@ -30,16 +30,28 @@ import (
 )
 
 const (
-	ISSUES     = "repo/issue/list"
-	ISSUE_NEW  = "repo/issue/new"
+	// ISSUES page template
+	ISSUES = "repo/issue/list"
+
+	// ISSUE_NEW page template
+	ISSUE_NEW = "repo/issue/new"
+
+	// ISSUE_VIEW page template
 	ISSUE_VIEW = "repo/issue/view"
 
+	// LABELS page template
 	LABELS = "repo/issue/labels"
 
-	MILESTONE      = "repo/issue/milestones"
-	MILESTONE_NEW  = "repo/issue/milestone_new"
+	// MILESTONE page template
+	MILESTONE = "repo/issue/milestones"
+
+	// MILESTONE_NEW page template
+	MILESTONE_NEW = "repo/issue/milestone_new"
+
+	// MILESTONE_EDIT page template
 	MILESTONE_EDIT = "repo/issue/milestone_edit"
 
+	// ISSUE_TEMPLATE_KEY page template
 	ISSUE_TEMPLATE_KEY = "IssueTemplate"
 )
 

+ 10 - 2
routes/repo/pull.go

@@ -23,11 +23,19 @@ import (
 )
 
 const (
-	FORK         = "repo/pulls/fork"
+	// FORK page template
+	FORK = "repo/pulls/fork"
+
+	// COMPARE_PULL page template
 	COMPARE_PULL = "repo/pulls/compare"
+
+	// PULL_COMMITS page template
 	PULL_COMMITS = "repo/pulls/commits"
-	PULL_FILES   = "repo/pulls/files"
 
+	// PULL_FILES page template
+	PULL_FILES = "repo/pulls/files"
+
+	// PULL_REQUEST_TEMPLATE_KEY page template
 	PULL_REQUEST_TEMPLATE_KEY = "PullRequestTemplate"
 )
 

+ 4 - 1
routes/repo/release.go

@@ -19,7 +19,10 @@ import (
 )
 
 const (
-	RELEASES    = "repo/release/list"
+	// RELEASES page template
+	RELEASES = "repo/release/list"
+
+	// RELEASE_NEW page template
 	RELEASE_NEW = "repo/release/new"
 )
 

+ 4 - 1
routes/repo/repo.go

@@ -25,7 +25,10 @@ import (
 )
 
 const (
-	CREATE  = "repo/create"
+	// CREATE page template
+	CREATE = "repo/create"
+
+	// MIGRATE page template
 	MIGRATE = "repo/migrate"
 )
 

+ 22 - 7
routes/repo/setting.go

@@ -26,14 +26,29 @@ import (
 )
 
 const (
-	SETTINGS_OPTIONS          = "repo/settings/options"
-	SETTINGS_REPO_AVATAR      = "repo/settings/avatar"
-	SETTINGS_COLLABORATION    = "repo/settings/collaboration"
-	SETTINGS_BRANCHES         = "repo/settings/branches"
+	// SETTINGS_OPTIONS page template
+	SETTINGS_OPTIONS = "repo/settings/options"
+
+	// SETTINGS_REPO_AVATAR page template
+	SETTINGS_REPO_AVATAR = "repo/settings/avatar"
+
+	// SETTINGS_COLLABORATION page template
+	SETTINGS_COLLABORATION = "repo/settings/collaboration"
+
+	// SETTINGS_BRANCHES page template
+	SETTINGS_BRANCHES = "repo/settings/branches"
+
+	// SETTINGS_PROTECTED_BRANCH page template
 	SETTINGS_PROTECTED_BRANCH = "repo/settings/protected_branch"
-	SETTINGS_GITHOOKS         = "repo/settings/githooks"
-	SETTINGS_GITHOOK_EDIT     = "repo/settings/githook_edit"
-	SETTINGS_DEPLOY_KEYS      = "repo/settings/deploy_keys"
+
+	// SETTINGS_GITHOOKS page template
+	SETTINGS_GITHOOKS = "repo/settings/githooks"
+
+	// SETTINGS_GITHOOK_EDIT page template
+	SETTINGS_GITHOOK_EDIT = "repo/settings/githook_edit"
+
+	// SETTINGS_DEPLOY_KEYS page template
+	SETTINGS_DEPLOY_KEYS = "repo/settings/deploy_keys"
 )
 
 func Settings(c *context.Context) {

+ 10 - 3
routes/repo/view.go

@@ -28,10 +28,17 @@ import (
 )
 
 const (
-	BARE     = "repo/bare"
-	HOME     = "repo/home"
+	// BARE page template
+	BARE = "repo/bare"
+
+	// HOME page template
+	HOME = "repo/home"
+
+	// WATCHERS page template
 	WATCHERS = "repo/watchers"
-	FORKS    = "repo/forks"
+
+	// FORKS page template
+	FORKS = "repo/forks"
 )
 
 func renderDirectory(c *context.Context, treeLink string) {

+ 7 - 2
routes/repo/webhook.go

@@ -22,8 +22,13 @@ import (
 )
 
 const (
-	WEBHOOKS        = "repo/settings/webhook/base"
-	WEBHOOK_NEW     = "repo/settings/webhook/new"
+	// WEBHOOKS page template
+	WEBHOOKS = "repo/settings/webhook/base"
+
+	// WEBHOOK_NEW page template
+	WEBHOOK_NEW = "repo/settings/webhook/new"
+
+	// ORG_WEBHOOK_NEW page template
 	ORG_WEBHOOK_NEW = "org/settings/webhook_new"
 )
 

+ 9 - 2
routes/repo/wiki.go

@@ -19,9 +19,16 @@ import (
 )
 
 const (
+	// WIKI_START page template
 	WIKI_START = "repo/wiki/start"
-	WIKI_VIEW  = "repo/wiki/view"
-	WIKI_NEW   = "repo/wiki/new"
+
+	// WIKI_VIEW page template
+	WIKI_VIEW = "repo/wiki/view"
+
+	// WIKI_NEW page template
+	WIKI_NEW = "repo/wiki/new"
+
+	// WIKI_PAGES page template
 	WIKI_PAGES = "repo/wiki/pages"
 )