summaryrefslogtreecommitdiffstats
path: root/routers/repo/commit.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-20 20:18:49 +0800
committerUnknwon <u@gogs.io>2015-08-20 20:18:49 +0800
commitaa65761d81d3f33bdfee578c14bb2b0c7a6ca639 (patch)
tree8c86e0e58758bc10a737b503f8d92e62406adf06 /routers/repo/commit.go
parentd7c3c79c00425e89a71e6178076bc5828421244d (diff)
downloadgitea-aa65761d81d3f33bdfee578c14bb2b0c7a6ca639.tar.gz
gitea-aa65761d81d3f33bdfee578c14bb2b0c7a6ca639.zip
new commits table
Diffstat (limited to 'routers/repo/commit.go')
-rw-r--r--routers/repo/commit.go24
1 files changed, 7 insertions, 17 deletions
diff --git a/routers/repo/commit.go b/routers/repo/commit.go
index 5d354c4b56..5dbc4bbf8e 100644
--- a/routers/repo/commit.go
+++ b/routers/repo/commit.go
@@ -9,6 +9,7 @@ import (
"path"
"github.com/Unknwon/com"
+ "github.com/Unknwon/paginater"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
@@ -44,7 +45,7 @@ func RenderIssueLinks(oldCommits *list.List, repoLink string) *list.List {
}
func Commits(ctx *middleware.Context) {
- ctx.Data["IsRepoToolbarCommits"] = true
+ ctx.Data["PageIsCommits"] = true
userName := ctx.Repo.Owner.Name
repoName := ctx.Repo.Repository.Name
@@ -64,19 +65,11 @@ func Commits(ctx *middleware.Context) {
return
}
- // Calculate and validate page number.
- page, _ := com.StrTo(ctx.Query("p")).Int()
- if page < 1 {
+ page := ctx.QueryInt("page")
+ if page <= 1 {
page = 1
}
- lastPage := page - 1
- if lastPage < 0 {
- lastPage = 0
- }
- nextPage := page + 1
- if page*50 > commitsCount {
- nextPage = 0
- }
+ ctx.Data["Page"] = paginater.New(commitsCount, git.CommitsRangeSize, page, 5)
// Both `git log branchName` and `git log commitId` work.
commits, err := ctx.Repo.Commit.CommitsByRange(page)
@@ -91,14 +84,11 @@ func Commits(ctx *middleware.Context) {
ctx.Data["Username"] = userName
ctx.Data["Reponame"] = repoName
ctx.Data["CommitCount"] = commitsCount
- ctx.Data["LastPageNum"] = lastPage
- ctx.Data["NextPageNum"] = nextPage
ctx.HTML(200, COMMITS)
}
func SearchCommits(ctx *middleware.Context) {
- ctx.Data["IsSearchPage"] = true
- ctx.Data["IsRepoToolbarCommits"] = true
+ ctx.Data["PageIsCommits"] = true
keyword := ctx.Query("q")
if len(keyword) == 0 {
@@ -253,7 +243,7 @@ func Diff(ctx *middleware.Context) {
ctx.Data["Parents"] = parents
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", commitId)
- if (commit.ParentCount() > 0) {
+ if commit.ParentCount() > 0 {
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", parents[0])
}
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitId)