Переглянути джерело

Add pages routes documentations

Gitote 7 роки тому
батько
коміт
fb17e206ec
5 змінених файлів з 96 додано та 24 видалено
  1. 2 2
      routes/org/members.go
  2. 1 1
      routes/org/org.go
  3. 3 3
      routes/org/setting.go
  4. 29 3
      routes/org/teams.go
  5. 61 15
      routes/pages/pages.go

+ 2 - 2
routes/org/members.go

@@ -11,10 +11,10 @@ import (
 )
 
 const (
-	// MEMBERS url
+	// MEMBERS page template
 	MEMBERS = "org/member/members"
 
-	//MEMBER_INVITE url
+	//MEMBER_INVITE page template
 	MEMBER_INVITE = "org/member/invite"
 )
 

+ 1 - 1
routes/org/org.go

@@ -10,7 +10,7 @@ import (
 )
 
 const (
-	// CREATE organization url
+	// CREATE organization page template
 	CREATE = "org/create"
 )
 

+ 3 - 3
routes/org/setting.go

@@ -13,13 +13,13 @@ import (
 )
 
 const (
-	// SETTINGS_OPTIONS url
+	// SETTINGS_OPTIONS page template
 	SETTINGS_OPTIONS = "org/settings/options"
 
-	// SETTINGS_DELETE url
+	// SETTINGS_DELETE page template
 	SETTINGS_DELETE = "org/settings/delete"
 
-	// SETTINGS_WEBHOOKS url
+	// SETTINGS_WEBHOOKS page template
 	SETTINGS_WEBHOOKS = "org/settings/webhooks"
 )
 

+ 29 - 3
routes/org/teams.go

@@ -12,12 +12,20 @@ import (
 )
 
 const (
-	TEAMS             = "org/team/teams"
-	TEAM_NEW          = "org/team/new"
-	TEAM_MEMBERS      = "org/team/members"
+	// TEAMS page template
+	TEAMS = "org/team/teams"
+
+	// TEAM_NEW page template
+	TEAM_NEW = "org/team/new"
+
+	// TEAM_MEMBERS page template
+	TEAM_MEMBERS = "org/team/members"
+
+	// TEAM_REPOSITORIES page template
 	TEAM_REPOSITORIES = "org/team/repositories"
 )
 
+// Teams shows team page
 func Teams(c *context.Context) {
 	org := c.Org.Organization
 	c.Data["Title"] = org.FullName
@@ -34,6 +42,8 @@ func Teams(c *context.Context) {
 	c.HTML(200, TEAMS)
 }
 
+// TeamsAction handle the user action
+// Like : join, leave, add or remove a team
 func TeamsAction(c *context.Context) {
 	uid := com.StrTo(c.Query("uid")).MustInt64()
 	if uid == 0 {
@@ -44,14 +54,17 @@ func TeamsAction(c *context.Context) {
 	page := c.Query("page")
 	var err error
 	switch c.Params(":action") {
+	// Join a team
 	case "join":
 		if !c.Org.IsOwner {
 			c.Error(404)
 			return
 		}
 		err = c.Org.Team.AddMember(c.User.ID)
+	// Leave a team
 	case "leave":
 		err = c.Org.Team.RemoveMember(c.User.ID)
+	// Remove a team
 	case "remove":
 		if !c.Org.IsOwner {
 			c.Error(404)
@@ -59,6 +72,7 @@ func TeamsAction(c *context.Context) {
 		}
 		err = c.Org.Team.RemoveMember(uid)
 		page = "team"
+	// Add a team
 	case "add":
 		if !c.Org.IsOwner {
 			c.Error(404)
@@ -102,6 +116,8 @@ func TeamsAction(c *context.Context) {
 	}
 }
 
+// TeamsRepoAction handle user actions
+// Like: add, remove a repository
 func TeamsRepoAction(c *context.Context) {
 	if !c.Org.IsOwner {
 		c.Error(404)
@@ -136,6 +152,7 @@ func TeamsRepoAction(c *context.Context) {
 	c.Redirect(c.Org.OrgLink + "/teams/" + c.Org.Team.LowerName + "/repositories")
 }
 
+// NewTeam shows the team creation page
 func NewTeam(c *context.Context) {
 	c.Data["Title"] = c.Org.Organization.FullName
 	c.Data["PageIsOrgTeams"] = true
@@ -144,6 +161,7 @@ func NewTeam(c *context.Context) {
 	c.HTML(200, TEAM_NEW)
 }
 
+// NewTeamPost creates an organization with the body fields
 func NewTeamPost(c *context.Context, f form.CreateTeam) {
 	c.Data["Title"] = c.Org.Organization.FullName
 	c.Data["PageIsOrgTeams"] = true
@@ -162,6 +180,7 @@ func NewTeamPost(c *context.Context, f form.CreateTeam) {
 		return
 	}
 
+	// Create a new team
 	if err := models.NewTeam(t); err != nil {
 		c.Data["Err_TeamName"] = true
 		switch {
@@ -178,6 +197,7 @@ func NewTeamPost(c *context.Context, f form.CreateTeam) {
 	c.Redirect(c.Org.OrgLink + "/teams/" + t.LowerName)
 }
 
+// TeamMembers shows team members page
 func TeamMembers(c *context.Context) {
 	c.Data["Title"] = c.Org.Team.Name
 	c.Data["PageIsOrgTeams"] = true
@@ -188,6 +208,7 @@ func TeamMembers(c *context.Context) {
 	c.HTML(200, TEAM_MEMBERS)
 }
 
+// TeamRepositories shows team repositoies page
 func TeamRepositories(c *context.Context) {
 	c.Data["Title"] = c.Org.Team.Name
 	c.Data["PageIsOrgTeams"] = true
@@ -198,6 +219,7 @@ func TeamRepositories(c *context.Context) {
 	c.HTML(200, TEAM_REPOSITORIES)
 }
 
+// EditTeam shows edit team page
 func EditTeam(c *context.Context) {
 	c.Data["Title"] = c.Org.Organization.FullName
 	c.Data["PageIsOrgTeams"] = true
@@ -206,6 +228,7 @@ func EditTeam(c *context.Context) {
 	c.HTML(200, TEAM_NEW)
 }
 
+// EditTeamPost edit team with the body fields
 func EditTeamPost(c *context.Context, f form.CreateTeam) {
 	t := c.Org.Team
 	c.Data["Title"] = c.Org.Organization.FullName
@@ -240,6 +263,7 @@ func EditTeamPost(c *context.Context, f form.CreateTeam) {
 		}
 	}
 	t.Description = f.Description
+	// Edit team
 	if err := models.UpdateTeam(t, isAuthChanged); err != nil {
 		c.Data["Err_TeamName"] = true
 		switch {
@@ -253,7 +277,9 @@ func EditTeamPost(c *context.Context, f form.CreateTeam) {
 	c.Redirect(c.Org.OrgLink + "/teams/" + t.LowerName)
 }
 
+// DeleteTeam deletes a team
 func DeleteTeam(c *context.Context) {
+	// Delete team
 	if err := models.DeleteTeam(c.Org.Team); err != nil {
 		c.Flash.Error("DeleteTeam: " + err.Error())
 	} else {

+ 61 - 15
routes/pages/pages.go

@@ -5,54 +5,91 @@ import (
 )
 
 const (
-	ABOUT          = "pages/about"
-	FAQ            = "pages/faq"
-	PRIVACY        = "pages/privacy"
-	TOS            = "pages/tos"
-	BRAND          = "pages/brand"
-	CONTACT        = "pages/contact"
-	CONTRIBUTE     = "pages/contribute"
-	SECURITY       = "pages/security"
-	VERIFIED       = "pages/verified"
-	MAKERS         = "pages/makers"
-	HELP           = "pages/help"
-	FEATURES       = "pages/features"
+	// ABOUT page template
+	ABOUT = "pages/about"
+
+	// FAQ page template
+	FAQ = "pages/faq"
+
+	// PRIVACY page template
+	PRIVACY = "pages/privacy"
+
+	// TOS page template
+	TOS = "pages/tos"
+
+	// BRAND page template
+	BRAND = "pages/brand"
+
+	// CONTACT page template
+	CONTACT = "pages/contact"
+
+	// CONTRIBUTE page template
+	CONTRIBUTE = "pages/contribute"
+
+	// SECURITY page template
+	SECURITY = "pages/security"
+
+	// VERIFIED page template
+	VERIFIED = "pages/verified"
+
+	// MAKERS page template
+	MAKERS = "pages/makers"
+
+	// HELP page template
+	HELP = "pages/help"
+
+	// FEATURES page template
+	FEATURES = "pages/features"
+
+	// FEATUREREQUEST page template
 	FEATUREREQUEST = "pages/request"
-	SPONSORSHIP    = "pages/sponsorship"
-	SITEMAP        = "pages/sitemap"
-	DONATE         = "pages/donate"
+
+	// SPONSORSHIP page template
+	SPONSORSHIP = "pages/sponsorship"
+
+	// SITEMAP page template
+	SITEMAP = "pages/sitemap"
+
+	// DONATE page template
+	DONATE = "pages/donate"
 )
 
+// About shows about page
 func About(c *context.Context) {
 	c.Data["Title"] = "About"
 
 	c.HTML(200, ABOUT)
 }
 
+// Faq shows faq page
 func Faq(c *context.Context) {
 	c.Data["Title"] = "FAQ"
 
 	c.HTML(200, FAQ)
 }
 
+// Privacy shows privacy page
 func Privacy(c *context.Context) {
 	c.Data["Title"] = "Privacy Policy"
 
 	c.HTML(200, PRIVACY)
 }
 
+// Tos shows tos page
 func Tos(c *context.Context) {
 	c.Data["Title"] = "Terms of Service"
 
 	c.HTML(200, TOS)
 }
 
+// Brand shows brand page
 func Brand(c *context.Context) {
 	c.Data["Title"] = "Gitote Brand"
 
 	c.HTML(200, BRAND)
 }
 
+// Contribute shows contribute page
 func Contribute(c *context.Context) {
 	c.Data["PageIsContribute"] = true
 	c.Data["Title"] = "Contribute"
@@ -60,24 +97,28 @@ func Contribute(c *context.Context) {
 	c.HTML(200, CONTRIBUTE)
 }
 
+// Security shows security page
 func Security(c *context.Context) {
 	c.Data["Title"] = "Security"
 
 	c.HTML(200, SECURITY)
 }
 
+// Verified shows verified page
 func Verified(c *context.Context) {
 	c.Data["Title"] = "Verified"
 
 	c.HTML(200, VERIFIED)
 }
 
+// Makers shows maker page
 func Makers(c *context.Context) {
 	c.Data["Title"] = "Makers"
 
 	c.HTML(200, MAKERS)
 }
 
+// Help shows help page
 func Help(c *context.Context) {
 	c.Data["Title"] = "Help"
 	c.Data["PageIsHelp"] = true
@@ -85,12 +126,14 @@ func Help(c *context.Context) {
 	c.HTML(200, HELP)
 }
 
+// Contact shows contact page
 func Contact(c *context.Context) {
 	c.Data["Title"] = "Contact"
 
 	c.HTML(200, CONTACT)
 }
 
+// Features shows features page
 func Features(c *context.Context) {
 	c.Data["Title"] = "Features"
 	c.Data["PageIsFeatures"] = true
@@ -98,18 +141,21 @@ func Features(c *context.Context) {
 	c.HTML(200, FEATURES)
 }
 
+// FeatureRequest shows feature request page
 func FeatureRequest(c *context.Context) {
 	c.Data["Title"] = "Feature Request"
 
 	c.HTML(200, FEATUREREQUEST)
 }
 
+// Sponsorship shows sponsorship page
 func Sponsorship(c *context.Context) {
 	c.Data["Title"] = "Sponsorship"
 
 	c.HTML(200, SPONSORSHIP)
 }
 
+// Donate shows donate page
 func Donate(c *context.Context) {
 	c.Data["Title"] = "Donate"