本文整理汇总了Golang中github.com/Unknwon/paginater.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Explore
func Explore(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("explore")
ctx.Data["PageIsExploreRepositories"] = true
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
ctx.Data["Page"] = paginater.New(int(models.CountRepositories()), setting.ExplorePagingNum, page, 5)
repos, err := models.GetRecentUpdatedRepositories(page)
if err != nil {
ctx.Handle(500, "GetRecentUpdatedRepositories", err)
return
}
for _, repo := range repos {
if err = repo.GetOwner(); err != nil {
ctx.Handle(500, "GetOwner", fmt.Errorf("%d: %v", repo.ID, err))
return
}
}
ctx.Data["Repos"] = repos
ctx.HTML(200, EXPLORE_REPOS)
}
开发者ID:BitSchupser,项目名称:gogs,代码行数:26,代码来源:home.go
示例2: Stars
func Stars(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repos.stars")
page := ctx.QueryInt("page")
if page <= 0 {
page = 1
}
ctx.Data["Page"] = paginater.New(ctx.Repo.Repository.NumStars, models.ItemsPerPage, page, 5)
stars, err := ctx.Repo.Repository.GetStars(ctx.QueryInt("page"))
if err != nil {
ctx.Handle(500, "GetStars", err)
return
}
if (ctx.QueryInt("page")-1)*models.ItemsPerPage > ctx.Repo.Repository.NumStars {
ctx.Handle(404, "ctx.Repo.Repository.NumStars", nil)
return
}
ctx.Data["Stars"] = stars
ctx.HTML(200, STARS)
}
开发者ID:smallnewer,项目名称:gogs,代码行数:26,代码来源:stars.go
示例3: Commits
func Commits(ctx *middleware.Context) {
ctx.Data["PageIsCommits"] = true
commitsCount, err := ctx.Repo.Commit.CommitsCount()
if err != nil {
ctx.Handle(500, "GetCommitsCount", err)
return
}
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
ctx.Data["Page"] = paginater.New(int(commitsCount), git.CommitsRangeSize, page, 5)
// Both `git log branchName` and `git log commitId` work.
commits, err := ctx.Repo.Commit.CommitsByRange(page)
if err != nil {
ctx.Handle(500, "CommitsByRange", err)
return
}
commits = RenderIssueLinks(commits, ctx.Repo.RepoLink)
commits = models.ValidateCommitsWithEmails(commits)
ctx.Data["Commits"] = commits
ctx.Data["Username"] = ctx.Repo.Owner.Name
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
ctx.Data["CommitCount"] = commitsCount
ctx.Data["Branch"] = ctx.Repo.BranchName
ctx.HTML(200, COMMITS)
}
开发者ID:ddelpero,项目名称:gogs,代码行数:31,代码来源:commit.go
示例4: showOrgProfile
func showOrgProfile(ctx *context.Context) {
ctx.SetParams(":org", ctx.Params(":username"))
context.HandleOrgAssignment(ctx)
if ctx.Written() {
return
}
org := ctx.Org.Organization
ctx.Data["Title"] = org.FullName
page := ctx.QueryInt("page")
if page <= 0 {
page = 1
}
var (
repos []*models.Repository
count int64
err error
)
if ctx.IsSigned && !ctx.User.IsAdmin {
repos, count, err = org.GetUserRepositories(ctx.User.ID, page, setting.UI.User.RepoPagingNum)
if err != nil {
ctx.Handle(500, "GetUserRepositories", err)
return
}
ctx.Data["Repos"] = repos
} else {
showPrivate := ctx.IsSigned && ctx.User.IsAdmin
repos, err = models.GetUserRepositories(org.ID, showPrivate, page, setting.UI.User.RepoPagingNum)
if err != nil {
ctx.Handle(500, "GetRepositories", err)
return
}
ctx.Data["Repos"] = repos
count = models.CountUserRepositories(org.ID, showPrivate)
}
ctx.Data["Page"] = paginater.New(int(count), setting.UI.User.RepoPagingNum, page, 5)
if err := org.GetMembers(); err != nil {
ctx.Handle(500, "GetMembers", err)
return
}
ctx.Data["Members"] = org.Members
ctx.Data["Teams"] = org.Teams
ctx.HTML(200, ORG_HOME)
}
开发者ID:yweber,项目名称:gogs,代码行数:49,代码来源:home.go
示例5: RenderRepoSearch
func RenderRepoSearch(ctx *context.Context,
counter func() int64, ranger func(int, int) ([]*models.Repository, error),
pagingNum int, orderBy string, tplName base.TplName) {
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
var (
repos []*models.Repository
count int64
err error
)
keyword := ctx.Query("q")
if len(keyword) == 0 {
repos, err = ranger(page, pagingNum)
if err != nil {
ctx.Handle(500, "ranger", err)
return
}
count = counter()
} else {
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
Keyword: keyword,
OrderBy: orderBy,
Page: page,
PageSize: pagingNum,
})
if err != nil {
ctx.Handle(500, "SearchRepositoryByName", err)
return
}
}
ctx.Data["Keyword"] = keyword
ctx.Data["Total"] = count
ctx.Data["Page"] = paginater.New(int(count), pagingNum, page, 5)
for _, repo := range repos {
if err = repo.GetOwner(); err != nil {
ctx.Handle(500, "GetOwner", fmt.Errorf("%d: %v", repo.ID, err))
return
}
}
ctx.Data["Repos"] = repos
ctx.HTML(200, tplName)
}
开发者ID:mhartkorn,项目名称:gogs,代码行数:48,代码来源:home.go
示例6: RenderRepoSearch
func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
page := ctx.QueryInt("page")
if page <= 0 {
page = 1
}
var (
repos []*models.Repository
count int64
err error
)
keyword := ctx.Query("q")
if len(keyword) == 0 {
repos, err = opts.Ranger(page, opts.PageSize)
if err != nil {
ctx.Handle(500, "opts.Ranger", err)
return
}
count = opts.Counter(opts.Private)
} else {
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
Keyword: keyword,
OrderBy: opts.OrderBy,
Private: opts.Private,
Page: page,
PageSize: opts.PageSize,
})
if err != nil {
ctx.Handle(500, "SearchRepositoryByName", err)
return
}
}
ctx.Data["Keyword"] = keyword
ctx.Data["Total"] = count
ctx.Data["Page"] = paginater.New(int(count), opts.PageSize, page, 5)
for _, repo := range repos {
if err = repo.GetOwner(); err != nil {
ctx.Handle(500, "GetOwner", fmt.Errorf("%d: %v", repo.ID, err))
return
}
}
ctx.Data["Repos"] = repos
ctx.HTML(200, opts.TplName)
}
开发者ID:tanapoln,项目名称:gogs,代码行数:47,代码来源:home.go
示例7: renderItems
func renderItems(ctx *middleware.Context, total int, getter func(page int) ([]*models.User, error)) {
page := ctx.QueryInt("page")
if page <= 0 {
page = 1
}
pager := paginater.New(total, models.ItemsPerPage, page, 5)
ctx.Data["Page"] = pager
items, err := getter(pager.Current())
if err != nil {
ctx.Handle(500, "getter", err)
return
}
ctx.Data["Watchers"] = items
ctx.HTML(200, WATCHERS)
}
开发者ID:kiliit,项目名称:gogs,代码行数:17,代码来源:view.go
示例8: RenderUserCards
func RenderUserCards(ctx *context.Context, total int, getter func(page int) ([]*models.User, error), tpl base.TplName) {
page := ctx.QueryInt("page")
if page <= 0 {
page = 1
}
pager := paginater.New(total, models.ItemsPerPage, page, 5)
ctx.Data["Page"] = pager
items, err := getter(pager.Current())
if err != nil {
ctx.Handle(500, "getter", err)
return
}
ctx.Data["Cards"] = items
ctx.HTML(200, tpl)
}
开发者ID:andreynering,项目名称:gogs,代码行数:17,代码来源:view.go
示例9: Milestones
func Milestones(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.milestones")
ctx.Data["PageIsIssueList"] = true
ctx.Data["PageIsMilestones"] = true
isShowClosed := ctx.Query("state") == "closed"
openCount, closedCount := models.MilestoneStats(ctx.Repo.Repository.ID)
ctx.Data["OpenCount"] = openCount
ctx.Data["ClosedCount"] = closedCount
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
var total int
if !isShowClosed {
total = int(openCount)
} else {
total = int(closedCount)
}
ctx.Data["Page"] = paginater.New(total, setting.IssuePagingNum, page, 5)
miles, err := models.GetMilestones(ctx.Repo.Repository.ID, page, isShowClosed)
if err != nil {
ctx.Handle(500, "GetMilestones", err)
return
}
for _, m := range miles {
m.RenderedContent = string(base.RenderMarkdown([]byte(m.Content), ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas()))
m.CalOpenIssues()
}
ctx.Data["Milestones"] = miles
if isShowClosed {
ctx.Data["State"] = "closed"
} else {
ctx.Data["State"] = "open"
}
ctx.Data["IsShowClosed"] = isShowClosed
ctx.HTML(200, MILESTONE)
}
开发者ID:rothgar,项目名称:gogs,代码行数:43,代码来源:issue.go
示例10: Index
func Index(c *middleware.Context) {
var (
p = c.ParamsInt(":p")
)
sites, e := models.SiteList(p)
if e != nil {
color.Red("%s", e)
}
cnt, e := models.SiteCount()
if e != nil {
color.Red("%s", e)
}
c.Data["sites"] = sites
c.Data["sites_count"] = cnt
c.Data["paginater"] = paginater.New(int(cnt), 10, p, 5)
c.HTML(200, "catalog/index")
}
开发者ID:zhuharev,项目名称:smoljanin.ru,代码行数:19,代码来源:catalog.go
示例11: AllFeed
func AllFeed(c *middleware.Context) {
p := c.ParamsInt(":p")
if p < 1 {
p = 1
}
feed, e := models.GetFeed(p)
if e != nil {
color.Red("%s", e)
}
cnt, e := models.FeedCount()
if e != nil {
color.Red("%s", e)
}
c.Data["feed"] = feed
c.Data["paginater"] = paginater.New(int(cnt), 10, p, 5)
c.HTML(200, "catalog/feed")
}
开发者ID:zhuharev,项目名称:smoljanin.ru,代码行数:19,代码来源:feed.go
示例12: RenderUserSearch
func RenderUserSearch(ctx *context.Context, userType models.UserType,
counter func() int64, ranger func(int, int) ([]*models.User, error),
pagingNum int, orderBy string, tplName base.TplName) {
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
var (
users []*models.User
count int64
err error
)
keyword := ctx.Query("q")
if len(keyword) == 0 {
users, err = ranger(page, pagingNum)
if err != nil {
ctx.Handle(500, "ranger", err)
return
}
count = counter()
} else {
users, count, err = models.SearchUserByName(&models.SearchUserOptions{
Keyword: keyword,
Type: userType,
OrderBy: orderBy,
Page: page,
PageSize: pagingNum,
})
if err != nil {
ctx.Handle(500, "SearchUserByName", err)
return
}
}
ctx.Data["Keyword"] = keyword
ctx.Data["Total"] = count
ctx.Data["Page"] = paginater.New(int(count), pagingNum, page, 5)
ctx.Data["Users"] = users
ctx.HTML(200, tplName)
}
开发者ID:mhartkorn,项目名称:gogs,代码行数:42,代码来源:home.go
示例13: SetLinkHeader
func (ctx *APIContext) SetLinkHeader(total, pageSize int) {
page := paginater.New(total, pageSize, ctx.QueryInt("page"), 0)
links := make([]string, 0, 4)
if page.HasNext() {
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"next\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.Next()))
}
if !page.IsLast() {
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"last\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.TotalPages()))
}
if !page.IsFirst() {
links = append(links, fmt.Sprintf("<%s%s?page=1>; rel=\"first\"", setting.AppUrl, ctx.Req.URL.Path[1:]))
}
if page.HasPrevious() {
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"prev\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.Previous()))
}
if len(links) > 0 {
ctx.Header().Set("Link", strings.Join(links, ","))
}
}
开发者ID:jessezwd,项目名称:gogs,代码行数:20,代码来源:api.go
示例14: FileHistory
func FileHistory(ctx *middleware.Context) {
ctx.Data["IsRepoToolbarCommits"] = true
fileName := ctx.Repo.TreeName
if len(fileName) == 0 {
Commits(ctx)
return
}
branchName := ctx.Repo.BranchName
commitsCount, err := ctx.Repo.GitRepo.FileCommitsCount(branchName, fileName)
if err != nil {
ctx.Handle(500, "FileCommitsCount", err)
return
} else if commitsCount == 0 {
ctx.Handle(404, "FileCommitsCount", nil)
return
}
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
ctx.Data["Page"] = paginater.New(int(commitsCount), git.CommitsRangeSize, page, 5)
commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(branchName, fileName, page)
if err != nil {
ctx.Handle(500, "CommitsByFileAndRange", err)
return
}
commits = RenderIssueLinks(commits, ctx.Repo.RepoLink)
commits = models.ValidateCommitsWithEmails(commits)
ctx.Data["Commits"] = commits
ctx.Data["Username"] = ctx.Repo.Owner.Name
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
ctx.Data["FileName"] = fileName
ctx.Data["CommitCount"] = commitsCount
ctx.Data["Branch"] = branchName
ctx.HTML(200, COMMITS)
}
开发者ID:ddelpero,项目名称:gogs,代码行数:41,代码来源:commit.go
示例15: Feed
func Feed(c *middleware.Context) {
sid := c.ParamsInt64(":id")
p := c.ParamsInt(":p")
if p < 1 {
p = 1
}
feed, e := models.GetSiteFeed(sid, p)
if e != nil {
color.Red("%s", e)
}
cnt, e := models.SiteFeedCount(sid)
if e != nil {
color.Red("%s", e)
}
c.Data["feed"] = feed
c.Data["paginater"] = paginater.New(int(cnt), 10, p, 5)
c.Data["SiteId"] = sid
c.HTML(200, "catalog/feed")
}
开发者ID:zhuharev,项目名称:smoljanin.ru,代码行数:21,代码来源:feed.go
示例16: RenderUserSearch
func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) {
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
var (
users []*models.User
count int64
err error
)
keyword := ctx.Query("q")
if len(keyword) == 0 {
users, err = opts.Ranger(page, opts.PageSize)
if err != nil {
ctx.Handle(500, "opts.Ranger", err)
return
}
count = opts.Counter()
} else {
users, count, err = models.SearchUserByName(&models.SearchUserOptions{
Keyword: keyword,
Type: opts.Type,
OrderBy: opts.OrderBy,
Page: page,
PageSize: opts.PageSize,
})
if err != nil {
ctx.Handle(500, "SearchUserByName", err)
return
}
}
ctx.Data["Keyword"] = keyword
ctx.Data["Total"] = count
ctx.Data["Page"] = paginater.New(int(count), opts.PageSize, page, 5)
ctx.Data["Users"] = users
ctx.HTML(200, opts.TplName)
}
开发者ID:gigforks,项目名称:gogs,代码行数:40,代码来源:home.go
示例17: Users
func Users(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("admin.users")
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminUsers"] = true
total := models.CountUsers()
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
ctx.Data["Page"] = paginater.New(int(total), setting.AdminUserPagingNum, page, 5)
users, err := models.Users(page, setting.AdminUserPagingNum)
if err != nil {
ctx.Handle(500, "Users", err)
return
}
ctx.Data["Users"] = users
ctx.Data["Total"] = total
ctx.HTML(200, USERS)
}
开发者ID:Keleir,项目名称:gogs,代码行数:22,代码来源:users.go
示例18: Repositories
func Repositories(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("admin.repositories")
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminRepositories"] = true
total := models.CountRepositories()
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
ctx.Data["Page"] = paginater.New(int(total), setting.AdminRepoPagingNum, page, 5)
repos, err := models.RepositoriesWithUsers(page, setting.AdminRepoPagingNum)
if err != nil {
ctx.Handle(500, "RepositoriesWithUsers", err)
return
}
ctx.Data["Repos"] = repos
ctx.Data["Total"] = total
ctx.HTML(200, REPOS)
}
开发者ID:smallnewer,项目名称:gogs,代码行数:22,代码来源:repos.go
示例19: Notices
func Notices(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("admin.notices")
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminNotices"] = true
total := models.CountNotices()
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
ctx.Data["Page"] = paginater.New(int(total), setting.AdminNoticePagingNum, page, 5)
notices, err := models.Notices(page, setting.AdminNoticePagingNum)
if err != nil {
ctx.Handle(500, "Notices", err)
return
}
ctx.Data["Notices"] = notices
ctx.Data["Total"] = total
ctx.HTML(200, NOTICES)
}
开发者ID:CarloQ,项目名称:gogs,代码行数:22,代码来源:notice.go
示例20: Organizations
func Organizations(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("admin.organizations")
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminOrganizations"] = true
total := models.CountOrganizations()
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
ctx.Data["Page"] = paginater.New(int(total), setting.AdminOrgPagingNum, page, 5)
orgs, err := models.Organizations(page, setting.AdminOrgPagingNum)
if err != nil {
ctx.Handle(500, "Organizations", err)
return
}
ctx.Data["Orgs"] = orgs
ctx.Data["Total"] = total
ctx.HTML(200, ORGS)
}
开发者ID:smallnewer,项目名称:gogs,代码行数:24,代码来源:orgs.go
注:本文中的github.com/Unknwon/paginater.New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论