2015-10-01 16:17:27 +03:00
|
|
|
// Copyright 2014 The Gogs Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package repo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/Unknwon/paginater"
|
|
|
|
|
|
|
|
"github.com/gogits/gogs/models"
|
|
|
|
"github.com/gogits/gogs/modules/base"
|
|
|
|
"github.com/gogits/gogs/modules/middleware"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
WATCHERS base.TplName = "repo/watchers"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Watchers(ctx *middleware.Context) {
|
|
|
|
ctx.Data["Title"] = ctx.Tr("repos.watches")
|
|
|
|
|
2015-10-02 11:04:11 +03:00
|
|
|
page := ctx.QueryInt("page")
|
2015-10-01 16:17:27 +03:00
|
|
|
if page <= 0 {
|
|
|
|
page = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Data["Page"] = paginater.New(ctx.Repo.Repository.NumWatches, models.ItemsPerPage, page, 5)
|
|
|
|
|
2015-10-02 11:04:11 +03:00
|
|
|
watchers, err := ctx.Repo.Repository.GetWatchers(ctx.QueryInt("page"))
|
2015-10-01 16:17:27 +03:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
ctx.Handle(500, "GetWatchers", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-10-02 11:04:11 +03:00
|
|
|
if (ctx.QueryInt("page")-1)*models.ItemsPerPage > ctx.Repo.Repository.NumWatches {
|
2015-10-01 16:17:27 +03:00
|
|
|
ctx.Handle(404, "ctx.Repo.Repository.NumWatches", nil)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Data["Watchers"] = watchers
|
|
|
|
|
|
|
|
ctx.HTML(200, WATCHERS)
|
|
|
|
}
|