@@ -1102,15 +1102,17 @@ func checkOutdatedBranch(ctx *context.Context) {
11021102}
11031103
11041104// RenderUserCards render a page show users according the input template
1105- func RenderUserCards (ctx * context.Context , total int , getter func (opts db.ListOptions ) ([]* user_model.User , error ), tpl base.TplName ) {
1105+ func RenderUserCards (ctx * context.Context , pageType string , total int , getter func (goctx gocontext.Context , repoID int64 , opts db.ListOptions ) ([]* user_model.User , error ), tpl base.TplName ) {
1106+ ctx .Data ["Title" ] = ctx .Tr (pageType )
1107+ ctx .Data ["CardsTitle" ] = ctx .Tr (pageType )
11061108 page := ctx .FormInt ("page" )
11071109 if page <= 0 {
11081110 page = 1
11091111 }
11101112 pager := context .NewPagination (total , setting .ItemsPerPage , page , 5 )
11111113 ctx .Data ["Page" ] = pager
11121114
1113- items , err := getter (db.ListOptions {
1115+ items , err := getter (ctx , ctx . Repo . Repository . ID , db.ListOptions {
11141116 Page : pager .Paginater .Current (),
11151117 PageSize : setting .ItemsPerPage ,
11161118 })
@@ -1123,42 +1125,24 @@ func RenderUserCards(ctx *context.Context, total int, getter func(opts db.ListOp
11231125 ctx .HTML (http .StatusOK , tpl )
11241126}
11251127
1126- func renderUserList (ctx * context.Context , pageType string , total int , getter func (opts db.ListOptions ) ([]* user_model.User , error ), tpl base.TplName ) {
1127- ctx .Data ["Title" ] = ctx .Tr (pageType )
1128- ctx .Data ["CardsTitle" ] = ctx .Tr (pageType )
1129- RenderUserCards (ctx , total , getter , tpl )
1130- }
1131-
11321128// Watchers render repository's watch users
11331129func Watchers (ctx * context.Context ) {
1134- renderUserList (ctx , "repo.watchers" , ctx .Repo .Repository .NumWatches ,
1135- func (opts db.ListOptions ) ([]* user_model.User , error ) {
1136- return repo_model .GetRepoWatchers (ctx , ctx .Repo .Repository .ID , opts )
1137- }, tplWatchers )
1130+ RenderUserCards (ctx , "repo.watchers" , ctx .Repo .Repository .NumWatches , repo_model .GetRepoWatchers , tplWatchers )
11381131}
11391132
11401133// WatchersCards renders a repository's watchers user cards
11411134func WatchersCards (ctx * context.Context ) {
1142- renderUserList (ctx , "repo.watchers" , ctx .Repo .Repository .NumWatches ,
1143- func (opts db.ListOptions ) ([]* user_model.User , error ) {
1144- return repo_model .GetRepoWatchers (ctx , ctx .Repo .Repository .ID , opts )
1145- }, tplCards )
1135+ RenderUserCards (ctx , "repo.watchers" , ctx .Repo .Repository .NumWatches , repo_model .GetRepoWatchers , tplCards )
11461136}
11471137
11481138// Stars render repository's starred users
11491139func Stars (ctx * context.Context ) {
1150- renderUserList (ctx , "repo.stargazers" , ctx .Repo .Repository .NumStars ,
1151- func (opts db.ListOptions ) ([]* user_model.User , error ) {
1152- return repo_model .GetStargazers (ctx , ctx .Repo .Repository , opts )
1153- }, tplWatchers )
1140+ RenderUserCards (ctx , "repo.stargazers" , ctx .Repo .Repository .NumStars , repo_model .GetStargazers , tplWatchers )
11541141}
11551142
11561143// StarsCards renders a repository's stargazers user cards
11571144func StarsCards (ctx * context.Context ) {
1158- renderUserList (ctx , "repo.stargazers" , ctx .Repo .Repository .NumStars ,
1159- func (opts db.ListOptions ) ([]* user_model.User , error ) {
1160- return repo_model .GetStargazers (ctx , ctx .Repo .Repository , opts )
1161- }, tplCards )
1145+ RenderUserCards (ctx , "repo.stargazers" , ctx .Repo .Repository .NumStars , repo_model .GetStargazers , tplCards )
11621146}
11631147
11641148// Forks render repository's forked users
0 commit comments