1
0
Fork 0
forked from forgejo/forgejo

#1384 add pagination for repositories

This commit is contained in:
Unknwon 2016-07-24 14:32:46 +08:00
parent 1f2e173a74
commit e74630ae3b
21 changed files with 360 additions and 192 deletions

View file

@ -45,7 +45,7 @@ func Home(ctx *context.Context) {
}
type RepoSearchOptions struct {
Counter func() int64
Counter func(bool) int64
Ranger func(int, int) ([]*models.Repository, error)
Private bool
PageSize int
@ -55,7 +55,7 @@ type RepoSearchOptions struct {
func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
page := ctx.QueryInt("page")
if page <= 1 {
if page <= 0 {
page = 1
}
@ -72,7 +72,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
ctx.Handle(500, "opts.Ranger", err)
return
}
count = opts.Counter()
count = opts.Counter(opts.Private)
} else {
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
Keyword: keyword,
@ -107,7 +107,7 @@ func ExploreRepos(ctx *context.Context) {
ctx.Data["PageIsExploreRepositories"] = true
RenderRepoSearch(ctx, &RepoSearchOptions{
Counter: models.CountPublicRepositories,
Counter: models.CountRepositories,
Ranger: models.GetRecentUpdatedRepositories,
PageSize: setting.UI.ExplorePagingNum,
OrderBy: "updated_unix DESC",