You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
991 B

  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "github.com/Unknwon/paginater"
  7. "github.com/gogits/gogs/models"
  8. "github.com/gogits/gogs/modules/base"
  9. "github.com/gogits/gogs/modules/middleware"
  10. )
  11. const (
  12. WATCHERS base.TplName = "repo/watchers"
  13. )
  14. func Watchers(ctx *middleware.Context) {
  15. ctx.Data["Title"] = ctx.Tr("repos.watches")
  16. page := ctx.QueryInt("page")
  17. if page <= 0 {
  18. page = 1
  19. }
  20. ctx.Data["Page"] = paginater.New(ctx.Repo.Repository.NumWatches, models.ItemsPerPage, page, 5)
  21. watchers, err := ctx.Repo.Repository.GetWatchers(ctx.QueryInt("page"))
  22. if err != nil {
  23. ctx.Handle(500, "GetWatchers", err)
  24. return
  25. }
  26. if (ctx.QueryInt("page")-1)*models.ItemsPerPage > ctx.Repo.Repository.NumWatches {
  27. ctx.Handle(404, "ctx.Repo.Repository.NumWatches", nil)
  28. return
  29. }
  30. ctx.Data["Watchers"] = watchers
  31. ctx.HTML(200, WATCHERS)
  32. }