|
|
@@ -10,15 +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 is the handler for "/"
|
|
|
+// Home shows the home page
|
|
|
func Home(c *context.Context) {
|
|
|
if c.IsLogged {
|
|
|
if !c.User.IsActive && setting.Service.RegisterEmailConfirm {
|
|
|
@@ -41,8 +52,7 @@ func Home(c *context.Context) {
|
|
|
c.Success(HOME)
|
|
|
}
|
|
|
|
|
|
-//ExploreHome is the handler for "/explore/home"
|
|
|
-// BUG : Return 404
|
|
|
+// ExploreHome shows explore page
|
|
|
func ExploreHome(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("explore")
|
|
|
c.Data["PageIsExplore"] = true
|
|
|
@@ -78,7 +88,7 @@ func ExploreHome(c *context.Context) {
|
|
|
c.Success(EXPLORE_HOME)
|
|
|
}
|
|
|
|
|
|
-//ExploreRepos is the handler for "/explore/repos"
|
|
|
+// ExploreRepos shows explore repositories page
|
|
|
func ExploreRepos(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("explore")
|
|
|
c.Data["PageIsExplore"] = true
|
|
|
@@ -90,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(),
|
|
|
@@ -114,7 +125,7 @@ func ExploreRepos(c *context.Context) {
|
|
|
c.Success(EXPLORE_REPOS)
|
|
|
}
|
|
|
|
|
|
-//ExploreTrending is the handler for "/trending"
|
|
|
+// ExploreTrending shows trending repositories page
|
|
|
func ExploreTrending(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("explore.trending")
|
|
|
c.Data["PageIsTrending"] = true
|
|
|
@@ -139,7 +150,7 @@ func ExploreTrending(c *context.Context) {
|
|
|
c.Success(EXPLORE_TRENDING)
|
|
|
}
|
|
|
|
|
|
-//UserSearchOptions is the structure of the options choosed by the user
|
|
|
+// UserSearchOptions is the structure of the options choosed by the user
|
|
|
type UserSearchOptions struct {
|
|
|
Type models.UserType
|
|
|
Counter func() int64
|
|
|
@@ -149,7 +160,7 @@ type UserSearchOptions struct {
|
|
|
TplName string
|
|
|
}
|
|
|
|
|
|
-//RenderUserSearch renders user search
|
|
|
+// RenderUserSearch renders user search
|
|
|
func RenderUserSearch(c *context.Context, opts *UserSearchOptions) {
|
|
|
page := c.QueryInt("page")
|
|
|
if page <= 1 {
|
|
|
@@ -191,7 +202,7 @@ func RenderUserSearch(c *context.Context, opts *UserSearchOptions) {
|
|
|
c.Success(opts.TplName)
|
|
|
}
|
|
|
|
|
|
-//ExploreUsers is the handler for "/explore/users"
|
|
|
+// ExploreUsers shows explore users page
|
|
|
func ExploreUsers(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("explore")
|
|
|
c.Data["PageIsExplore"] = true
|
|
|
@@ -207,7 +218,7 @@ func ExploreUsers(c *context.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-//ExploreOrganizations is the handler for "/explore/organisations"
|
|
|
+//ExploreOrganizations shows explore organizations page
|
|
|
func ExploreOrganizations(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("explore")
|
|
|
c.Data["PageIsExplore"] = true
|
|
|
@@ -223,7 +234,7 @@ func ExploreOrganizations(c *context.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-//NotFound renders 404 page if page not found
|
|
|
+// NotFound renders 404 page if page not found
|
|
|
func NotFound(c *context.Context) {
|
|
|
c.Data["Title"] = "Page Not Found"
|
|
|
c.NotFound()
|