Sfoglia il codice sorgente

Merge branch 'Add-Routes-documentation' of dimensi0n/gitote into master

Yoginth 7 anni fa
parent
commit
348a416513
3 ha cambiato i file con 43 aggiunte e 0 eliminazioni
  1. 21 0
      routes/home.go
  2. 6 0
      routes/install.go
  3. 16 0
      routes/user/auth.go

+ 21 - 0
routes/home.go

@@ -10,14 +10,26 @@ import (
 )
 
 const (
+  	// HOME page template
 	HOME                  = "home"
+  
+  	// EXPLORE_HOME page template
 	EXPLORE_HOME          = "explore/home"
+  
+  	// EXPLORE_REPOS page template
 	EXPLORE_REPOS         = "explore/repos"
+  
+  	// EXPLORE_USERS page template
 	EXPLORE_USERS         = "explore/users"
+  
+  	// EXPLORE_TRENDING page template
 	EXPLORE_TRENDING      = "explore/trending"
+  
+  	// EXPLORE_ORGANIZATIONS page template
 	EXPLORE_ORGANIZATIONS = "explore/organizations"
 )
 
+// Home shows the home page
 func Home(c *context.Context) {
 	if c.IsLogged {
 		if !c.User.IsActive && setting.Service.RegisterEmailConfirm {
@@ -40,6 +52,7 @@ func Home(c *context.Context) {
 	c.Success(HOME)
 }
 
+// ExploreHome shows explore page
 func ExploreHome(c *context.Context) {
 	c.Data["Title"] = c.Tr("explore")
 	c.Data["PageIsExplore"] = true
@@ -75,6 +88,7 @@ func ExploreHome(c *context.Context) {
 	c.Success(EXPLORE_HOME)
 }
 
+// ExploreRepos shows explore repositories page
 func ExploreRepos(c *context.Context) {
 	c.Data["Title"] = c.Tr("explore")
 	c.Data["PageIsExplore"] = true
@@ -86,6 +100,7 @@ func ExploreRepos(c *context.Context) {
 	}
 
 	keyword := c.Query("q")
+  	// Search a repository
 	repos, count, err := models.SearchRepositoryByName(&models.SearchRepoOptions{
 		Keyword:  keyword,
 		UserID:   c.UserID(),
@@ -110,6 +125,7 @@ func ExploreRepos(c *context.Context) {
 	c.Success(EXPLORE_REPOS)
 }
 
+// ExploreTrending shows trending repositories page
 func ExploreTrending(c *context.Context) {
 	c.Data["Title"] = c.Tr("explore.trending")
 	c.Data["PageIsTrending"] = true
@@ -134,6 +150,7 @@ func ExploreTrending(c *context.Context) {
 	c.Success(EXPLORE_TRENDING)
 }
 
+// UserSearchOptions is the structure of the options choosed by the user
 type UserSearchOptions struct {
 	Type     models.UserType
 	Counter  func() int64
@@ -143,6 +160,7 @@ type UserSearchOptions struct {
 	TplName  string
 }
 
+// RenderUserSearch renders user search
 func RenderUserSearch(c *context.Context, opts *UserSearchOptions) {
 	page := c.QueryInt("page")
 	if page <= 1 {
@@ -184,6 +202,7 @@ func RenderUserSearch(c *context.Context, opts *UserSearchOptions) {
 	c.Success(opts.TplName)
 }
 
+// ExploreUsers shows explore users page
 func ExploreUsers(c *context.Context) {
 	c.Data["Title"] = c.Tr("explore")
 	c.Data["PageIsExplore"] = true
@@ -199,6 +218,7 @@ func ExploreUsers(c *context.Context) {
 	})
 }
 
+//ExploreOrganizations shows explore organizations page
 func ExploreOrganizations(c *context.Context) {
 	c.Data["Title"] = c.Tr("explore")
 	c.Data["PageIsExplore"] = true
@@ -214,6 +234,7 @@ func ExploreOrganizations(c *context.Context) {
 	})
 }
 
+// NotFound renders 404 page if page not found
 func NotFound(c *context.Context) {
 	c.Data["Title"] = "Page Not Found"
 	c.NotFound()

+ 6 - 0
routes/install.go

@@ -28,9 +28,11 @@ import (
 )
 
 const (
+  	// INSTALL page template
 	INSTALL = "install"
 )
 
+// checkRunMode check if it is runned or not in production
 func checkRunMode() {
 	if setting.ProdMode {
 		macaron.Env = macaron.PROD
@@ -41,6 +43,7 @@ func checkRunMode() {
 	log.Info("Run Mode: %s", strings.Title(macaron.Env))
 }
 
+// NewServices initializes new services
 func NewServices() {
 	setting.NewServices()
 	mailer.NewContext()
@@ -98,6 +101,7 @@ func GlobalInit() {
 	}
 }
 
+// InstallInit initialize the install
 func InstallInit(c *context.Context) {
 	if setting.InstallLock {
 		c.NotFound()
@@ -114,6 +118,7 @@ func InstallInit(c *context.Context) {
 	c.Data["DbOptions"] = dbOpts
 }
 
+// Install shows install page
 func Install(c *context.Context) {
 	f := form.Install{}
 
@@ -174,6 +179,7 @@ func Install(c *context.Context) {
 	c.Success(INSTALL)
 }
 
+// InstallPost install gitote
 func InstallPost(c *context.Context, f form.Install) {
 	c.Data["CurDbOption"] = f.DbType
 

+ 16 - 0
routes/user/auth.go

@@ -69,6 +69,7 @@ func AutoLogin(c *context.Context) (bool, error) {
 	return true, nil
 }
 
+//Login is the handler for "/login"
 func Login(c *context.Context) {
 	c.Title("sign_in")
 
@@ -117,6 +118,7 @@ func Login(c *context.Context) {
 	c.Success(LOGIN)
 }
 
+//afterLogin set sessions cookies and redirect to "/"
 func afterLogin(c *context.Context, u *models.User, remember bool) {
 	if remember {
 		days := 86400 * setting.LoginRememberDays
@@ -145,6 +147,7 @@ func afterLogin(c *context.Context, u *models.User, remember bool) {
 	c.SubURLRedirect("/")
 }
 
+//LoginPost is the POST handler for "/login"
 func LoginPost(c *context.Context, f form.SignIn) {
 	c.Title("sign_in")
 
@@ -197,6 +200,7 @@ func LoginPost(c *context.Context, f form.SignIn) {
 	c.SubURLRedirect("/login/two_factor")
 }
 
+//LoginTwoFactor is the handler for "/login" with two factors authentication
 func LoginTwoFactor(c *context.Context) {
 	_, ok := c.Session.Get("twoFactorUserID").(int64)
 	if !ok {
@@ -207,6 +211,7 @@ func LoginTwoFactor(c *context.Context) {
 	c.Success(TWO_FACTOR)
 }
 
+//LoginTwoFactorPost is the POST handler for "/login" with two factors authentication
 func LoginTwoFactorPost(c *context.Context) {
 	userID, ok := c.Session.Get("twoFactorUserID").(int64)
 	if !ok {
@@ -251,6 +256,7 @@ func LoginTwoFactorPost(c *context.Context) {
 	afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
 }
 
+//LoginTwoFactorRecoveryCode is the handler to recover Two Factor Code
 func LoginTwoFactorRecoveryCode(c *context.Context) {
 	_, ok := c.Session.Get("twoFactorUserID").(int64)
 	if !ok {
@@ -261,6 +267,7 @@ func LoginTwoFactorRecoveryCode(c *context.Context) {
 	c.Success(TWO_FACTOR_RECOVERY_CODE)
 }
 
+//LoginTwoFactorRecoveryCodePost is the POST handler to recover Two Factor Code
 func LoginTwoFactorRecoveryCodePost(c *context.Context) {
 	userID, ok := c.Session.Get("twoFactorUserID").(int64)
 	if !ok {
@@ -286,6 +293,7 @@ func LoginTwoFactorRecoveryCodePost(c *context.Context) {
 	afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
 }
 
+//SignOut is the handler for "/user/logout"
 func SignOut(c *context.Context) {
 	c.Session.Delete("uid")
 	c.Session.Delete("uname")
@@ -295,6 +303,7 @@ func SignOut(c *context.Context) {
 	c.SubURLRedirect("/")
 }
 
+//SignUp is the handler for "/signup"
 func SignUp(c *context.Context) {
 	c.Title("sign_up")
 
@@ -309,6 +318,7 @@ func SignUp(c *context.Context) {
 	c.Success(SIGNUP)
 }
 
+//SignUpPost is the POST handler for "/join"
 func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
 	c.Title("sign_up")
 
@@ -396,6 +406,7 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
 	c.SubURLRedirect("/login")
 }
 
+//Activate activates the code
 func Activate(c *context.Context) {
 	code := c.Query("code")
 	if len(code) == 0 {
@@ -449,6 +460,7 @@ func Activate(c *context.Context) {
 	c.Success(ACTIVATE)
 }
 
+//ActivateEmail is the handler to activate the user email
 func ActivateEmail(c *context.Context) {
 	code := c.Query("code")
 	email_string := c.Query("email")
@@ -467,6 +479,7 @@ func ActivateEmail(c *context.Context) {
 	return
 }
 
+//ForgotPasswd is the handler for "/user/forget_password"
 func ForgotPasswd(c *context.Context) {
 	c.Title("auth.forgot_password")
 
@@ -480,6 +493,7 @@ func ForgotPasswd(c *context.Context) {
 	c.Success(FORGOT_PASSWORD)
 }
 
+//ForgotPasswdPost is the POST handler for "/user/forget_password"
 func ForgotPasswdPost(c *context.Context) {
 	c.Title("auth.forgot_password")
 
@@ -528,6 +542,7 @@ func ForgotPasswdPost(c *context.Context) {
 	c.Success(FORGOT_PASSWORD)
 }
 
+//ResetPasswd is the handler to reset your password
 func ResetPasswd(c *context.Context) {
 	c.Title("auth.reset_password")
 
@@ -541,6 +556,7 @@ func ResetPasswd(c *context.Context) {
 	c.Success(RESET_PASSWORD)
 }
 
+//ResetPasswdPost is the POST handler to reset your password
 func ResetPasswdPost(c *context.Context) {
 	c.Title("auth.reset_password")