@@ -25,9 +25,9 @@ import (
25
25
)
26
26
27
27
const (
28
- HOME base.TplName = "repo/home"
29
- WATCHERS base.TplName = "repo/watchers"
30
- FORKS base.TplName = "repo/forks"
28
+ tplRepoHome base.TplName = "repo/home"
29
+ tplWatchers base.TplName = "repo/watchers"
30
+ tplForks base.TplName = "repo/forks"
31
31
)
32
32
33
33
func renderDirectory (ctx * context.Context , treeLink string ) {
@@ -212,6 +212,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
212
212
}
213
213
}
214
214
215
+ // Home render repository home page
215
216
func Home (ctx * context.Context ) {
216
217
title := ctx .Repo .Repository .Owner .Name + "/" + ctx .Repo .Repository .Name
217
218
if len (ctx .Repo .Repository .Description ) > 0 {
@@ -263,9 +264,10 @@ func Home(ctx *context.Context) {
263
264
ctx .Data ["TreeLink" ] = treeLink
264
265
ctx .Data ["TreeNames" ] = treeNames
265
266
ctx .Data ["BranchLink" ] = branchLink
266
- ctx .HTML (200 , HOME )
267
+ ctx .HTML (200 , tplRepoHome )
267
268
}
268
269
270
+ // RenderUserCards render a page show users accroding the input templaet
269
271
func RenderUserCards (ctx * context.Context , total int , getter func (page int ) ([]* models.User , error ), tpl base.TplName ) {
270
272
page := ctx .QueryInt ("page" )
271
273
if page <= 0 {
@@ -284,20 +286,23 @@ func RenderUserCards(ctx *context.Context, total int, getter func(page int) ([]*
284
286
ctx .HTML (200 , tpl )
285
287
}
286
288
289
+ // Watchers render repository's watch users
287
290
func Watchers (ctx * context.Context ) {
288
291
ctx .Data ["Title" ] = ctx .Tr ("repo.watchers" )
289
292
ctx .Data ["CardsTitle" ] = ctx .Tr ("repo.watchers" )
290
293
ctx .Data ["PageIsWatchers" ] = true
291
- RenderUserCards (ctx , ctx .Repo .Repository .NumWatches , ctx .Repo .Repository .GetWatchers , WATCHERS )
294
+ RenderUserCards (ctx , ctx .Repo .Repository .NumWatches , ctx .Repo .Repository .GetWatchers , tplWatchers )
292
295
}
293
296
297
+ // Stars render repository's starred users
294
298
func Stars (ctx * context.Context ) {
295
299
ctx .Data ["Title" ] = ctx .Tr ("repo.stargazers" )
296
300
ctx .Data ["CardsTitle" ] = ctx .Tr ("repo.stargazers" )
297
301
ctx .Data ["PageIsStargazers" ] = true
298
- RenderUserCards (ctx , ctx .Repo .Repository .NumStars , ctx .Repo .Repository .GetStargazers , WATCHERS )
302
+ RenderUserCards (ctx , ctx .Repo .Repository .NumStars , ctx .Repo .Repository .GetStargazers , tplWatchers )
299
303
}
300
304
305
+ // Forks render repository's forked users
301
306
func Forks (ctx * context.Context ) {
302
307
ctx .Data ["Title" ] = ctx .Tr ("repos.forks" )
303
308
@@ -315,5 +320,5 @@ func Forks(ctx *context.Context) {
315
320
}
316
321
ctx .Data ["Forks" ] = forks
317
322
318
- ctx .HTML (200 , FORKS )
323
+ ctx .HTML (200 , tplForks )
319
324
}
0 commit comments