mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
new watchers, stars and forks UI
This commit is contained in:
parent
e06558e208
commit
9ab96172fc
12 changed files with 216 additions and 256 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue