golint fixed for parts of routers root, dev, user and org dirs (#167)
* golint fixed for parts of routers root, dev and org dirs * add user/auth.go golint fixed * rename unnecessary exported to unexported and user dir golint fixed
This commit is contained in:
parent
91953ae9b4
commit
cf045b029c
11 changed files with 225 additions and 132 deletions
|
@ -17,17 +17,22 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
HOME base.TplName = "home"
|
||||
EXPLORE_REPOS base.TplName = "explore/repos"
|
||||
EXPLORE_USERS base.TplName = "explore/users"
|
||||
EXPLORE_ORGANIZATIONS base.TplName = "explore/organizations"
|
||||
// tplHome home page template
|
||||
tplHome base.TplName = "home"
|
||||
// tplExploreRepos explore repositories page template
|
||||
tplExploreRepos base.TplName = "explore/repos"
|
||||
// tplExploreUsers explore users page template
|
||||
tplExploreUsers base.TplName = "explore/users"
|
||||
// tplExploreOrganizations explore organizations page template
|
||||
tplExploreOrganizations base.TplName = "explore/organizations"
|
||||
)
|
||||
|
||||
// Home render home page
|
||||
func Home(ctx *context.Context) {
|
||||
if ctx.IsSigned {
|
||||
if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm {
|
||||
ctx.Data["Title"] = ctx.Tr("auth.active_your_account")
|
||||
ctx.HTML(200, user.ACTIVATE)
|
||||
ctx.HTML(200, user.TplActivate)
|
||||
} else {
|
||||
user.Dashboard(ctx)
|
||||
}
|
||||
|
@ -42,9 +47,10 @@ func Home(ctx *context.Context) {
|
|||
}
|
||||
|
||||
ctx.Data["PageIsHome"] = true
|
||||
ctx.HTML(200, HOME)
|
||||
ctx.HTML(200, tplHome)
|
||||
}
|
||||
|
||||
// RepoSearchOptions when calling search repositories
|
||||
type RepoSearchOptions struct {
|
||||
Counter func(bool) int64
|
||||
Ranger func(int, int) ([]*models.Repository, error)
|
||||
|
@ -54,6 +60,7 @@ type RepoSearchOptions struct {
|
|||
TplName base.TplName
|
||||
}
|
||||
|
||||
// RenderRepoSearch render repositories search page
|
||||
func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
|
||||
page := ctx.QueryInt("page")
|
||||
if page <= 0 {
|
||||
|
@ -102,6 +109,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
|
|||
ctx.HTML(200, opts.TplName)
|
||||
}
|
||||
|
||||
// ExploreRepos render explore repositories page
|
||||
func ExploreRepos(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("explore")
|
||||
ctx.Data["PageIsExplore"] = true
|
||||
|
@ -112,10 +120,11 @@ func ExploreRepos(ctx *context.Context) {
|
|||
Ranger: models.GetRecentUpdatedRepositories,
|
||||
PageSize: setting.UI.ExplorePagingNum,
|
||||
OrderBy: "updated_unix DESC",
|
||||
TplName: EXPLORE_REPOS,
|
||||
TplName: tplExploreRepos,
|
||||
})
|
||||
}
|
||||
|
||||
// UserSearchOptions options when render search user page
|
||||
type UserSearchOptions struct {
|
||||
Type models.UserType
|
||||
Counter func() int64
|
||||
|
@ -125,6 +134,7 @@ type UserSearchOptions struct {
|
|||
TplName base.TplName
|
||||
}
|
||||
|
||||
// RenderUserSearch render user search page
|
||||
func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) {
|
||||
page := ctx.QueryInt("page")
|
||||
if page <= 1 {
|
||||
|
@ -166,6 +176,7 @@ func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) {
|
|||
ctx.HTML(200, opts.TplName)
|
||||
}
|
||||
|
||||
// ExploreUsers render explore users page
|
||||
func ExploreUsers(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("explore")
|
||||
ctx.Data["PageIsExplore"] = true
|
||||
|
@ -177,10 +188,11 @@ func ExploreUsers(ctx *context.Context) {
|
|||
Ranger: models.Users,
|
||||
PageSize: setting.UI.ExplorePagingNum,
|
||||
OrderBy: "name ASC",
|
||||
TplName: EXPLORE_USERS,
|
||||
TplName: tplExploreUsers,
|
||||
})
|
||||
}
|
||||
|
||||
// ExploreOrganizations render explore organizations page
|
||||
func ExploreOrganizations(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("explore")
|
||||
ctx.Data["PageIsExplore"] = true
|
||||
|
@ -192,10 +204,11 @@ func ExploreOrganizations(ctx *context.Context) {
|
|||
Ranger: models.Organizations,
|
||||
PageSize: setting.UI.ExplorePagingNum,
|
||||
OrderBy: "name ASC",
|
||||
TplName: EXPLORE_ORGANIZATIONS,
|
||||
TplName: tplExploreOrganizations,
|
||||
})
|
||||
}
|
||||
|
||||
// NotFound render 404 page
|
||||
func NotFound(ctx *context.Context) {
|
||||
ctx.Data["Title"] = "Page Not Found"
|
||||
ctx.Handle(404, "home.NotFound", nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue