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/") {
// board handler
parts := strings.Split(path[3:], "/")
page := 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" {
var err error
page, err = strconv.Atoi(parts[1])
@ -116,8 +120,6 @@ func (self *nullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if banned {
goto notfound
}
pages := self.database.GetGroupPageCount(group)
if page >= int(pages) {
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}
if invertPagination {
obj["prev"] = map[string]interface{}{"no": page - 1}
} else if page > 0 {
if page > 0 {
obj["prev"] = map[string]interface{}{"no": page - 1}
}
if invertPagination {
obj["next"] = map[string]interface{}{"no": page + 1}
} else {
if page < 10 {
obj["next"] = map[string]interface{}{"no": page + 1}
}
} else if page < 10 {
obj["next"] = map[string]interface{}{"no": page + 1}
}
if json {
self.renderJSON(wr, obj)