0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-16 08:44:02 +01:00

golint fixed for routers/repo/view.go (#205)

This commit is contained in:
Lunny Xiao 2016-11-21 18:03:29 +08:00 committed by GitHub
parent 1d9576d5ea
commit 18dc4f1023

View file

@ -25,9 +25,9 @@ import (
) )
const ( const (
HOME base.TplName = "repo/home" tplRepoHome base.TplName = "repo/home"
WATCHERS base.TplName = "repo/watchers" tplWatchers base.TplName = "repo/watchers"
FORKS base.TplName = "repo/forks" tplForks base.TplName = "repo/forks"
) )
func renderDirectory(ctx *context.Context, treeLink string) { 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) { func Home(ctx *context.Context) {
title := ctx.Repo.Repository.Owner.Name + "/" + ctx.Repo.Repository.Name title := ctx.Repo.Repository.Owner.Name + "/" + ctx.Repo.Repository.Name
if len(ctx.Repo.Repository.Description) > 0 { if len(ctx.Repo.Repository.Description) > 0 {
@ -263,9 +264,10 @@ func Home(ctx *context.Context) {
ctx.Data["TreeLink"] = treeLink ctx.Data["TreeLink"] = treeLink
ctx.Data["TreeNames"] = treeNames ctx.Data["TreeNames"] = treeNames
ctx.Data["BranchLink"] = branchLink 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) { func RenderUserCards(ctx *context.Context, total int, getter func(page int) ([]*models.User, error), tpl base.TplName) {
page := ctx.QueryInt("page") page := ctx.QueryInt("page")
if page <= 0 { if page <= 0 {
@ -284,20 +286,23 @@ func RenderUserCards(ctx *context.Context, total int, getter func(page int) ([]*
ctx.HTML(200, tpl) ctx.HTML(200, tpl)
} }
// Watchers render repository's watch users
func Watchers(ctx *context.Context) { func Watchers(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.watchers") ctx.Data["Title"] = ctx.Tr("repo.watchers")
ctx.Data["CardsTitle"] = ctx.Tr("repo.watchers") ctx.Data["CardsTitle"] = ctx.Tr("repo.watchers")
ctx.Data["PageIsWatchers"] = true 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) { func Stars(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.stargazers") ctx.Data["Title"] = ctx.Tr("repo.stargazers")
ctx.Data["CardsTitle"] = ctx.Tr("repo.stargazers") ctx.Data["CardsTitle"] = ctx.Tr("repo.stargazers")
ctx.Data["PageIsStargazers"] = true 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) { func Forks(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repos.forks") ctx.Data["Title"] = ctx.Tr("repos.forks")
@ -315,5 +320,5 @@ func Forks(ctx *context.Context) {
} }
ctx.Data["Forks"] = forks ctx.Data["Forks"] = forks
ctx.HTML(200, FORKS) ctx.HTML(200, tplForks)
} }