mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 10:48:37 +00:00
new watchers, stars and forks UI
This commit is contained in:
@@ -11,6 +11,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/Unknwon/paginater"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/git"
|
||||
@@ -20,7 +22,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
HOME base.TplName = "repo/home"
|
||||
HOME base.TplName = "repo/home"
|
||||
WATCHERS base.TplName = "repo/watchers"
|
||||
)
|
||||
|
||||
func Home(ctx *middleware.Context) {
|
||||
@@ -245,3 +248,33 @@ func Home(ctx *middleware.Context) {
|
||||
ctx.Data["BranchLink"] = branchLink
|
||||
ctx.HTML(200, HOME)
|
||||
}
|
||||
|
||||
func renderItems(ctx *middleware.Context, total int, getter func(page int) ([]*models.User, error)) {
|
||||
page := ctx.QueryInt("page")
|
||||
if page <= 0 {
|
||||
page = 1
|
||||
}
|
||||
pager := paginater.New(total, models.ItemsPerPage, page, 5)
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
items, err := getter(pager.Current())
|
||||
if err != nil {
|
||||
ctx.Handle(500, "getter", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Watchers"] = items
|
||||
|
||||
ctx.HTML(200, WATCHERS)
|
||||
}
|
||||
|
||||
func Watchers(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.watchers")
|
||||
ctx.Data["PageIsWatchers"] = true
|
||||
renderItems(ctx, ctx.Repo.Repository.NumWatches, ctx.Repo.Repository.GetWatchers)
|
||||
}
|
||||
|
||||
func Stars(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.stargazers")
|
||||
ctx.Data["PageIsStargazers"] = true
|
||||
renderItems(ctx, ctx.Repo.Repository.NumStars, ctx.Repo.Repository.GetStargazers)
|
||||
}
|
||||
|
Reference in New Issue
Block a user