sitemap.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright 2015 - Present, The Gogs Authors. All rights reserved.
  2. // Copyright 2018 - Present, Gitote. All rights reserved.
  3. //
  4. // This source code is licensed under the MIT license found in the
  5. // LICENSE file in the root directory of this source tree.
  6. package admin
  7. import (
  8. "gitote/gitote/models"
  9. "gitote/gitote/pkg/context"
  10. "gitote/gitote/routes"
  11. )
  12. const (
  13. // SitemapTPL page template
  14. SitemapTPL = "sitemap"
  15. // UserSitemapTPL page template
  16. UserSitemapTPL = "user/sitemap"
  17. // OrgSitemapTPL page template
  18. OrgSitemapTPL = "org/sitemap"
  19. // RepoSitemapTPL page template
  20. RepoSitemapTPL = "repo/sitemap"
  21. )
  22. // Sitemap shows about page
  23. func Sitemap(c *context.Context) {
  24. c.HTML(200, SitemapTPL)
  25. }
  26. // UserSitemap shows about page
  27. func UserSitemap(c *context.Context) {
  28. routes.RenderUserSearch(c, &routes.UserSearchOptions{
  29. Type: models.UserTypeIndividual,
  30. Counter: models.CountUsers,
  31. Ranger: models.Users,
  32. OrderBy: "id ASC",
  33. TplName: UserSitemapTPL,
  34. })
  35. }
  36. // OrgSitemap shows about page
  37. func OrgSitemap(c *context.Context) {
  38. routes.RenderUserSearch(c, &routes.UserSearchOptions{
  39. Type: models.UserTypeOrganization,
  40. Counter: models.CountOrganizations,
  41. Ranger: models.Organizations,
  42. OrderBy: "id ASC",
  43. TplName: OrgSitemapTPL,
  44. })
  45. }
  46. // RepoSitemap shows about page
  47. func RepoSitemap(c *context.Context) {
  48. page := c.QueryInt("page")
  49. var (
  50. repos []*models.Repository
  51. count int64
  52. err error
  53. )
  54. repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
  55. OrderBy: "id ASC",
  56. Private: false,
  57. Page: page,
  58. })
  59. c.Data["Total"] = count
  60. if err = models.RepositoryList(repos).LoadAttributes(); err != nil {
  61. c.Handle(500, "LoadAttributes", err)
  62. return
  63. }
  64. c.Data["Repos"] = repos
  65. c.HTML(200, RepoSitemapTPL)
  66. }