From 18dc4f1023c4f343ad992d3cedab39a244d4178d Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 21 Nov 2016 18:03:29 +0800 Subject: [PATCH] golint fixed for routers/repo/view.go (#205) --- routers/repo/view.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/routers/repo/view.go b/routers/repo/view.go index 8f49a12c3..7303e4412 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -25,9 +25,9 @@ import ( ) const ( - HOME base.TplName = "repo/home" - WATCHERS base.TplName = "repo/watchers" - FORKS base.TplName = "repo/forks" + tplRepoHome base.TplName = "repo/home" + tplWatchers base.TplName = "repo/watchers" + tplForks base.TplName = "repo/forks" ) func renderDirectory(ctx *context.Context, treeLink string) { @@ -212,6 +212,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st } } +// Home render repository home page func Home(ctx *context.Context) { title := ctx.Repo.Repository.Owner.Name + "/" + ctx.Repo.Repository.Name if len(ctx.Repo.Repository.Description) > 0 { @@ -263,9 +264,10 @@ func Home(ctx *context.Context) { ctx.Data["TreeLink"] = treeLink ctx.Data["TreeNames"] = treeNames ctx.Data["BranchLink"] = branchLink - ctx.HTML(200, HOME) + ctx.HTML(200, tplRepoHome) } +// RenderUserCards render a page show users accroding the input templaet func RenderUserCards(ctx *context.Context, total int, getter func(page int) ([]*models.User, error), tpl base.TplName) { page := ctx.QueryInt("page") if page <= 0 { @@ -284,20 +286,23 @@ func RenderUserCards(ctx *context.Context, total int, getter func(page int) ([]* ctx.HTML(200, tpl) } +// Watchers render repository's watch users func Watchers(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.watchers") ctx.Data["CardsTitle"] = ctx.Tr("repo.watchers") ctx.Data["PageIsWatchers"] = true - RenderUserCards(ctx, ctx.Repo.Repository.NumWatches, ctx.Repo.Repository.GetWatchers, WATCHERS) + RenderUserCards(ctx, ctx.Repo.Repository.NumWatches, ctx.Repo.Repository.GetWatchers, tplWatchers) } +// Stars render repository's starred users func Stars(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.stargazers") ctx.Data["CardsTitle"] = ctx.Tr("repo.stargazers") ctx.Data["PageIsStargazers"] = true - RenderUserCards(ctx, ctx.Repo.Repository.NumStars, ctx.Repo.Repository.GetStargazers, WATCHERS) + RenderUserCards(ctx, ctx.Repo.Repository.NumStars, ctx.Repo.Repository.GetStargazers, tplWatchers) } +// Forks render repository's forked users func Forks(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repos.forks") @@ -315,5 +320,5 @@ func Forks(ctx *context.Context) { } ctx.Data["Forks"] = forks - ctx.HTML(200, FORKS) + ctx.HTML(200, tplForks) }