better paging

This commit is contained in:
Unknwon 2015-07-28 03:14:37 +08:00
parent 31f6069dbe
commit 589618c8a5
9 changed files with 37 additions and 18 deletions

View File

@ -6,7 +6,8 @@ github.com/bradfitz/gomemcache = commit:72a68649ba
github.com/Unknwon/cae = commit:2e70a1351b github.com/Unknwon/cae = commit:2e70a1351b
github.com/Unknwon/com = github.com/Unknwon/com =
github.com/Unknwon/i18n = commit:7457d88830 github.com/Unknwon/i18n = commit:7457d88830
github.com/Unknwon/macaron = commit:93de4f3fad github.com/Unknwon/macaron =
github.com/Unknwon/paginater =
github.com/codegangsta/cli = commit:2bcd11f863 github.com/codegangsta/cli = commit:2bcd11f863
github.com/go-sql-driver/mysql = commit:a197e5d405 github.com/go-sql-driver/mysql = commit:a197e5d405
github.com/go-xorm/core = commit:be6e7ac47d github.com/go-xorm/core = commit:be6e7ac47d
@ -14,7 +15,7 @@ github.com/go-xorm/xorm = commit:1f0dd9bef2
github.com/gogits/chardet = commit:2404f77725 github.com/gogits/chardet = commit:2404f77725
github.com/gogits/go-gogs-client = commit:92e76d616a github.com/gogits/go-gogs-client = commit:92e76d616a
github.com/lib/pq = commit:30ed2200d7 github.com/lib/pq = commit:30ed2200d7
github.com/macaron-contrib/binding = commit:548a793679 github.com/macaron-contrib/binding =
github.com/macaron-contrib/cache = commit:928d5c35cd github.com/macaron-contrib/cache = commit:928d5c35cd
github.com/macaron-contrib/captcha = github.com/macaron-contrib/captcha =
github.com/macaron-contrib/csrf = commit:98ddf5a710 github.com/macaron-contrib/csrf = commit:98ddf5a710
@ -30,7 +31,7 @@ github.com/russross/blackfriday = commit:6928e11ecd
github.com/shurcooL/go = commit:bc30a0bd33 github.com/shurcooL/go = commit:bc30a0bd33
golang.org/x/net = commit:7dbad50ab5 golang.org/x/net = commit:7dbad50ab5
golang.org/x/text = commit:5f741289c4 golang.org/x/text = commit:5f741289c4
gopkg.in/ini.v1 = commit:177219109c gopkg.in/ini.v1 =
gopkg.in/redis.v2 = commit:e617904962 gopkg.in/redis.v2 = commit:e617904962
[res] [res]

View File

@ -379,8 +379,8 @@ issues.filter_type.assigned_to_you = Assigned to you
issues.filter_type.created_by_you = Created by you issues.filter_type.created_by_you = Created by you
issues.filter_type.mentioning_you = Mentioning you issues.filter_type.mentioning_you = Mentioning you
issues.opened_by = opened %[1]s by <a href="/%[2]s">%[2]s</a> issues.opened_by = opened %[1]s by <a href="/%[2]s">%[2]s</a>
issues.previous = Previous Page issues.previous = Previous
issues.next = Next Page issues.next = Next
issues.label_title = Label name issues.label_title = Label name
issues.label_color = Label color issues.label_color = Label color
issues.label_count = %d labels issues.label_count = %d labels

View File

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.6.3.0726 Beta" const APP_VER = "0.6.3.0728 Beta"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -102,7 +102,7 @@
list-style: none; list-style: none;
font-size: 13px; font-size: 13px;
padding-top: 15px; padding-top: 15px;
.item { >.item {
padding-top: 15px; padding-top: 15px;
padding-bottom: 10px; padding-bottom: 10px;
border-bottom: 1px dashed #AAA; border-bottom: 1px dashed #AAA;

View File

@ -15,6 +15,7 @@ import (
"time" "time"
"github.com/Unknwon/com" "github.com/Unknwon/com"
"github.com/Unknwon/paginater"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/auth"
@ -100,13 +101,15 @@ func Issues(ctx *middleware.Context) {
page := ctx.QueryInt("page") page := ctx.QueryInt("page")
if page <= 1 { if page <= 1 {
page = 1 page = 1
}
var total int
if !isShowClosed {
total = int(issueStats.OpenCount)
} else { } else {
ctx.Data["PreviousPage"] = page - 1 total = int(issueStats.ClosedCount)
}
if (!isShowClosed && int(issueStats.OpenCount) > setting.IssuePagingNum*page) ||
(isShowClosed && int(issueStats.ClosedCount) > setting.IssuePagingNum*page) {
ctx.Data["NextPage"] = page + 1
} }
ctx.Data["Page"] = paginater.New(total, setting.IssuePagingNum, page, 5)
// Get issues. // Get issues.
issues, err := models.GetIssues(uid, assigneeID, repo.Id, posterID, milestoneID, issues, err := models.GetIssues(uid, assigneeID, repo.Id, posterID, milestoneID,

View File

@ -1 +1 @@
0.6.3.0726 Beta 0.6.3.0728 Beta

View File

@ -86,11 +86,26 @@
</li> </li>
{{end}} {{end}}
{{with .Page}}
<div class="center page buttons"> <div class="center page buttons">
<a class="ui {{if not .PreviousPage}}disabled{{end}} blue button" href="{{.RepoLink}}/issues?type={{$.ViewType}}&state={{$.State}}&labels={{.SelectLabels}}&page={{.PreviousPage}}">{{.i18n.Tr "repo.issues.previous"}}</a> <div class="ui borderless pagination menu">
<a class="ui {{if not .NextPage}}disabled{{end}} blue button" href="{{.RepoLink}}/issues?type={{$.ViewType}}&state={{$.State}}&labels={{.SelectLabels}}&page={{.NextPage}}">{{.i18n.Tr "repo.issues.next"}}</a> <a class="{{if not .HasPrevious}}disabled{{end}} item" {{if .HasPrevious}}href="{{$.RepoLink}}/issues?type={{$.ViewType}}&state={{$.State}}&labels={{$.SelectLabels}}&page={{.Previous}}"{{end}}>
<i class="left arrow icon"></i> {{$.i18n.Tr "repo.issues.previous"}}
</a>
{{range .Pages}}
{{if eq .Num -1}}
<a class="disabled item">...</a>
{{else}}
<a class="{{if .IsCurrent}}active{{end}} item" {{if not .IsCurrent}}href="{{$.RepoLink}}/issues?type={{$.ViewType}}&state={{$.State}}&labels={{$.SelectLabels}}&page={{.Num}}"{{end}}>{{.Num}}</a>
{{end}}
{{end}}
<a class="{{if not .HasNext}}disabled{{end}} item" {{if .HasNext}}href="{{$.RepoLink}}/issues?type={{$.ViewType}}&state={{$.State}}&labels={{$.SelectLabels}}&page={{.Next}}"{{end}}>
{{$.i18n.Tr "repo.issues.next"}} <i class="icon right arrow"></i>
</a>
</div> </div>
</div> </div>
{{end}}
</div>
</div> </div>
</div> </div>
{{template "base/footer" .}} {{template "base/footer" .}}