Archived
1
0
This commit is contained in:
Jeff Becker 2018-03-09 10:23:09 -05:00
parent 7c5546c0c0
commit fcd5a97225
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
2 changed files with 8 additions and 10 deletions

View File

@ -95,8 +95,12 @@ func (self *nullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(path, "/b/") { if strings.HasPrefix(path, "/b/") {
// board handler // board handler
parts := strings.Split(path[3:], "/") parts := strings.Split(path[3:], "/")
page := 0
group := parts[0] group := parts[0]
page := 0
pages := self.database.GetGroupPageCount(group)
if self.invertPagination {
page = int(pages) - 1
}
if len(parts) > 1 && parts[1] != "" && parts[1] != "json" { if len(parts) > 1 && parts[1] != "" && parts[1] != "json" {
var err error var err error
page, err = strconv.Atoi(parts[1]) page, err = strconv.Atoi(parts[1])
@ -116,8 +120,6 @@ func (self *nullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if banned { if banned {
goto notfound goto notfound
} }
pages := self.database.GetGroupPageCount(group)
if page >= int(pages) { if page >= int(pages) {
goto notfound goto notfound
} }

View File

@ -283,17 +283,13 @@ func (self *templateEngine) genUkkoPaginated(prefix, frontend string, wr io.Writ
} }
} }
obj := map[string]interface{}{"prefix": prefix, "threads": threads, "page": page} obj := map[string]interface{}{"prefix": prefix, "threads": threads, "page": page}
if invertPagination { if page > 0 {
obj["prev"] = map[string]interface{}{"no": page - 1}
} else if page > 0 {
obj["prev"] = map[string]interface{}{"no": page - 1} obj["prev"] = map[string]interface{}{"no": page - 1}
} }
if invertPagination { if invertPagination {
obj["next"] = map[string]interface{}{"no": page + 1} obj["next"] = map[string]interface{}{"no": page + 1}
} else { } else if page < 10 {
if page < 10 { obj["next"] = map[string]interface{}{"no": page + 1}
obj["next"] = map[string]interface{}{"no": page + 1}
}
} }
if json { if json {
self.renderJSON(wr, obj) self.renderJSON(wr, obj)