Browse Source

Fixed GoStandards in routes

Yoginth 7 years ago
parent
commit
f7c0da9d7e
3 changed files with 37 additions and 37 deletions
  1. 15 15
      routes/explore.go
  2. 3 3
      routes/home.go
  3. 19 19
      routes/install.go

+ 15 - 15
routes/explore.go

@@ -15,20 +15,20 @@ import (
 )
 
 const (
-	// EXPLORE_HOME page template
-	EXPLORE = "explore/home"
+	// ExploreTPL page template
+	ExploreTPL = "explore/home"
 
-	// EXPLORE_REPOS page template
-	EXPLORE_REPOS = "explore/repos"
+	// ExploreReposTPL page template
+	ExploreReposTPL = "explore/repos"
 
-	// EXPLORE_USERS page template
-	EXPLORE_USERS = "explore/users"
+	// ExploreUsersTPL page template
+	ExploreUsersTPL = "explore/users"
 
-	// EXPLORE_TRENDING page template
-	EXPLORE_TRENDING = "explore/trending"
+	// ExploreTrendingTPL page template
+	ExploreTrendingTPL = "explore/trending"
 
-	// EXPLORE_ORGANIZATIONS page template
-	EXPLORE_ORGANIZATIONS = "explore/organizations"
+	// ExploreOrganizationsTPL page template
+	ExploreOrganizationsTPL = "explore/organizations"
 )
 
 // ExploreHome shows explore page
@@ -54,7 +54,7 @@ func Explore(c *context.Context) {
 	}
 	c.Data["Repos"] = repos
 
-	c.Success(EXPLORE)
+	c.Success(ExploreTPL)
 }
 
 // ExploreRepos shows explore repositories page
@@ -91,7 +91,7 @@ func ExploreRepos(c *context.Context) {
 	}
 	c.Data["Repos"] = repos
 
-	c.Success(EXPLORE_REPOS)
+	c.Success(ExploreReposTPL)
 }
 
 // ExploreTrending shows trending repositories page
@@ -116,7 +116,7 @@ func ExploreTrending(c *context.Context) {
 	}
 	c.Data["Repos"] = repos
 
-	c.Success(EXPLORE_TRENDING)
+	c.Success(ExploreTrendingTPL)
 }
 
 // UserSearchOptions is the structure of the options choosed by the user
@@ -183,7 +183,7 @@ func ExploreUsers(c *context.Context) {
 		Ranger:   models.Users,
 		PageSize: setting.UI.ExplorePagingNum,
 		OrderBy:  "updated_unix DESC",
-		TplName:  EXPLORE_USERS,
+		TplName:  ExploreUsersTPL,
 	})
 }
 
@@ -199,6 +199,6 @@ func ExploreOrganizations(c *context.Context) {
 		Ranger:   models.Organizations,
 		PageSize: setting.UI.ExplorePagingNum,
 		OrderBy:  "updated_unix DESC",
-		TplName:  EXPLORE_ORGANIZATIONS,
+		TplName:  ExploreOrganizationsTPL,
 	})
 }

+ 3 - 3
routes/home.go

@@ -13,8 +13,8 @@ import (
 )
 
 const (
-	// HOME page template
-	HOME = "home"
+	// HomeTPL page template
+	HomeTPL = "home"
 )
 
 // Home shows the home page
@@ -37,7 +37,7 @@ func Home(c *context.Context) {
 	}
 
 	c.Data["PageIsHome"] = true
-	c.Success(HOME)
+	c.Success(HomeTPL)
 }
 
 // NotFound renders 404 page if page not found

+ 19 - 19
routes/install.go

@@ -34,8 +34,8 @@ import (
 )
 
 const (
-	// INSTALL page template
-	INSTALL = "install"
+	// InstallTPL page template
+	InstallTPL = "install"
 )
 
 // checkRunMode check if it is runned or not in production
@@ -182,7 +182,7 @@ func Install(c *context.Context) {
 	f.RequireSignInView = setting.Service.RequireSignInView
 
 	form.Assign(f, c.Data)
-	c.Success(INSTALL)
+	c.Success(InstallTPL)
 }
 
 // InstallPost install gitote
@@ -199,12 +199,12 @@ func InstallPost(c *context.Context, f form.Install) {
 			c.FormErr("Admin")
 		}
 
-		c.Success(INSTALL)
+		c.Success(InstallTPL)
 		return
 	}
 
 	if _, err := exec.LookPath("git"); err != nil {
-		c.RenderWithErr(c.Tr("install.test_git_failed", err), INSTALL, &f)
+		c.RenderWithErr(c.Tr("install.test_git_failed", err), InstallTPL, &f)
 		return
 	}
 
@@ -221,7 +221,7 @@ func InstallPost(c *context.Context, f form.Install) {
 
 	if models.DbCfg.Type == "sqlite3" && len(models.DbCfg.Path) == 0 {
 		c.FormErr("DbPath")
-		c.RenderWithErr(c.Tr("install.err_empty_db_path"), INSTALL, &f)
+		c.RenderWithErr(c.Tr("install.err_empty_db_path"), InstallTPL, &f)
 		return
 	}
 
@@ -230,10 +230,10 @@ func InstallPost(c *context.Context, f form.Install) {
 	if err := models.NewTestEngine(x); err != nil {
 		if strings.Contains(err.Error(), `Unknown database type: sqlite3`) {
 			c.FormErr("DbType")
-			c.RenderWithErr(c.Tr("install.sqlite3_not_available", "https://gitote/docs/installation/install_from_binary.html"), INSTALL, &f)
+			c.RenderWithErr(c.Tr("install.sqlite3_not_available", "https://docs.gitote.in/docs/installation/install_from_binary.html"), InstallTPL, &f)
 		} else {
 			c.FormErr("DbSetting")
-			c.RenderWithErr(c.Tr("install.invalid_db_setting", err), INSTALL, &f)
+			c.RenderWithErr(c.Tr("install.invalid_db_setting", err), InstallTPL, &f)
 		}
 		return
 	}
@@ -242,7 +242,7 @@ func InstallPost(c *context.Context, f form.Install) {
 	f.RepoRootPath = strings.Replace(f.RepoRootPath, "\\", "/", -1)
 	if err := os.MkdirAll(f.RepoRootPath, os.ModePerm); err != nil {
 		c.FormErr("RepoRootPath")
-		c.RenderWithErr(c.Tr("install.invalid_repo_path", err), INSTALL, &f)
+		c.RenderWithErr(c.Tr("install.invalid_repo_path", err), InstallTPL, &f)
 		return
 	}
 
@@ -250,21 +250,21 @@ func InstallPost(c *context.Context, f form.Install) {
 	f.LogRootPath = strings.Replace(f.LogRootPath, "\\", "/", -1)
 	if err := os.MkdirAll(f.LogRootPath, os.ModePerm); err != nil {
 		c.FormErr("LogRootPath")
-		c.RenderWithErr(c.Tr("install.invalid_log_root_path", err), INSTALL, &f)
+		c.RenderWithErr(c.Tr("install.invalid_log_root_path", err), InstallTPL, &f)
 		return
 	}
 
 	currentUser, match := setting.IsRunUserMatchCurrentUser(f.RunUser)
 	if !match {
 		c.FormErr("RunUser")
-		c.RenderWithErr(c.Tr("install.run_user_not_match", f.RunUser, currentUser), INSTALL, &f)
+		c.RenderWithErr(c.Tr("install.run_user_not_match", f.RunUser, currentUser), InstallTPL, &f)
 		return
 	}
 
 	// Check host address and port
 	if len(f.SMTPHost) > 0 && !strings.Contains(f.SMTPHost, ":") {
 		c.FormErr("SMTP", "SMTPHost")
-		c.RenderWithErr(c.Tr("install.smtp_host_missing_port"), INSTALL, &f)
+		c.RenderWithErr(c.Tr("install.smtp_host_missing_port"), InstallTPL, &f)
 		return
 	}
 
@@ -273,7 +273,7 @@ func InstallPost(c *context.Context, f form.Install) {
 		_, err := mail.ParseAddress(f.SMTPFrom)
 		if err != nil {
 			c.FormErr("SMTP", "SMTPFrom")
-			c.RenderWithErr(c.Tr("install.invalid_smtp_from", err), INSTALL, &f)
+			c.RenderWithErr(c.Tr("install.invalid_smtp_from", err), InstallTPL, &f)
 			return
 		}
 	}
@@ -281,19 +281,19 @@ func InstallPost(c *context.Context, f form.Install) {
 	// Check logic loophole between disable self-registration and no admin account.
 	if f.DisableRegistration && len(f.AdminName) == 0 {
 		c.FormErr("Services", "Admin")
-		c.RenderWithErr(c.Tr("install.no_admin_and_disable_registration"), INSTALL, f)
+		c.RenderWithErr(c.Tr("install.no_admin_and_disable_registration"), InstallTPL, f)
 		return
 	}
 
 	// Check admin password.
 	if len(f.AdminName) > 0 && len(f.AdminPasswd) == 0 {
 		c.FormErr("Admin", "AdminPasswd")
-		c.RenderWithErr(c.Tr("install.err_empty_admin_password"), INSTALL, f)
+		c.RenderWithErr(c.Tr("install.err_empty_admin_password"), InstallTPL, f)
 		return
 	}
 	if f.AdminPasswd != f.AdminConfirmPasswd {
 		c.FormErr("Admin", "AdminPasswd")
-		c.RenderWithErr(c.Tr("form.password_not_match"), INSTALL, f)
+		c.RenderWithErr(c.Tr("form.password_not_match"), InstallTPL, f)
 		return
 	}
 
@@ -366,14 +366,14 @@ func InstallPost(c *context.Context, f form.Install) {
 	cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
 	secretKey, err := tool.RandomString(15)
 	if err != nil {
-		c.RenderWithErr(c.Tr("install.secret_key_failed", err), INSTALL, &f)
+		c.RenderWithErr(c.Tr("install.secret_key_failed", err), InstallTPL, &f)
 		return
 	}
 	cfg.Section("security").Key("SECRET_KEY").SetValue(secretKey)
 
 	os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
 	if err := cfg.SaveTo(setting.CustomConf); err != nil {
-		c.RenderWithErr(c.Tr("install.save_config_failed", err), INSTALL, &f)
+		c.RenderWithErr(c.Tr("install.save_config_failed", err), InstallTPL, &f)
 		return
 	}
 
@@ -392,7 +392,7 @@ func InstallPost(c *context.Context, f form.Install) {
 			if !models.IsErrUserAlreadyExist(err) {
 				setting.InstallLock = false
 				c.FormErr("AdminName", "AdminEmail")
-				c.RenderWithErr(c.Tr("install.invalid_admin_setting", err), INSTALL, &f)
+				c.RenderWithErr(c.Tr("install.invalid_admin_setting", err), InstallTPL, &f)
 				return
 			}
 			log.Info("Admin account already exist")