|
@@ -0,0 +1,96 @@
|
|
|
|
|
+// 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/models"
|
|
|
|
|
+ "gitote/gitote/pkg/context"
|
|
|
|
|
+ "gitote/gitote/pkg/setting"
|
|
|
|
|
+ "gitote/gitote/routes"
|
|
|
|
|
+
|
|
|
|
|
+ "gitlab.com/yoginth/paginater"
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+const (
|
|
|
|
|
+ // UserSitemapTPL page template
|
|
|
|
|
+ UserSitemapTPL = "user/sitemap"
|
|
|
|
|
+
|
|
|
|
|
+ // OrgSitemapTPL page template
|
|
|
|
|
+ OrgSitemapTPL = "org/sitemap"
|
|
|
|
|
+
|
|
|
|
|
+ // RepoSitemapTPL page template
|
|
|
|
|
+ RepoSitemapTPL = "repo/sitemap"
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+// UserSitemap shows about page
|
|
|
|
|
+func UserSitemap(c *context.Context) {
|
|
|
|
|
+ routes.RenderUserSearch(c, &routes.UserSearchOptions{
|
|
|
|
|
+ Type: models.UserTypeIndividual,
|
|
|
|
|
+ Counter: models.CountUsers,
|
|
|
|
|
+ Ranger: models.Users,
|
|
|
|
|
+ OrderBy: "id ASC",
|
|
|
|
|
+ TplName: UserSitemapTPL,
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// OrgSitemap shows about page
|
|
|
|
|
+func OrgSitemap(c *context.Context) {
|
|
|
|
|
+ routes.RenderUserSearch(c, &routes.UserSearchOptions{
|
|
|
|
|
+ Type: models.UserTypeOrganization,
|
|
|
|
|
+ Counter: models.CountOrganizations,
|
|
|
|
|
+ Ranger: models.Organizations,
|
|
|
|
|
+ OrderBy: "id ASC",
|
|
|
|
|
+ TplName: OrgSitemapTPL,
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// RepoSitemap shows about page
|
|
|
|
|
+func RepoSitemap(c *context.Context) {
|
|
|
|
|
+ page := c.QueryInt("page")
|
|
|
|
|
+ if page <= 0 {
|
|
|
|
|
+ page = 1
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var (
|
|
|
|
|
+ repos []*models.Repository
|
|
|
|
|
+ count int64
|
|
|
|
|
+ err error
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ keyword := c.Query("q")
|
|
|
|
|
+ if len(keyword) == 0 {
|
|
|
|
|
+ repos, err = models.Repositories(page, setting.UI.Admin.RepoPagingNum)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ c.Handle(500, "Repositories", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ count = models.CountRepositories(true)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
|
|
|
|
|
+ Keyword: keyword,
|
|
|
|
|
+ OrderBy: "id ASC",
|
|
|
|
|
+ Private: true,
|
|
|
|
|
+ Page: page,
|
|
|
|
|
+ PageSize: setting.UI.Admin.RepoPagingNum,
|
|
|
|
|
+ })
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ c.Handle(500, "SearchRepositoryByName", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ c.Data["Keyword"] = keyword
|
|
|
|
|
+ c.Data["Total"] = count
|
|
|
|
|
+ c.Data["Page"] = paginater.New(int(count), setting.UI.Admin.RepoPagingNum, page, 5)
|
|
|
|
|
+
|
|
|
|
|
+ if err = models.RepositoryList(repos).LoadAttributes(); err != nil {
|
|
|
|
|
+ c.Handle(500, "LoadAttributes", err)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ c.Data["Repos"] = repos
|
|
|
|
|
+
|
|
|
|
|
+ c.HTML(200, RepoSitemapTPL)
|
|
|
|
|
+}
|