Archived
1
0
This commit is contained in:
Jeff Becker 2018-03-09 10:05:03 -05:00
parent b61c22898e
commit c5479e2386
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
3 changed files with 12 additions and 11 deletions

View File

@ -285,14 +285,14 @@ func (self *FileCache) regenUkko() {
return
}
defer f.Close()
template.genUkkoPaginated(self.prefix, self.name, f, self.database, i, false, nil, false)
template.genUkkoPaginated(self.prefix, self.name, f, self.database, 10, i, false, nil, false)
j, err := os.Create(jname)
if err != nil {
log.Printf("failed to create json ukko", i, err)
return
}
defer j.Close()
template.genUkkoPaginated(self.prefix, self.name, j, self.database, i, true, nil, false)
template.genUkkoPaginated(self.prefix, self.name, j, self.database, 10, i, true, nil, false)
}
}

View File

@ -136,13 +136,13 @@ func (self *nullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
goto notfound
}
}
if page == 0 {
pages, _ := self.database.GetUkkoPageCount(10)
if path == "/o/" {
if self.invertPagination {
pages, _ := self.database.GetUkkoPageCount(10)
page = int(pages)
}
}
template.genUkkoPaginated(self.prefix, self.name, w, self.database, page, isjson, i18n, self.invertPagination)
template.genUkkoPaginated(self.prefix, self.name, w, self.database, int(pages), page, isjson, i18n, self.invertPagination)
return
}
@ -181,7 +181,8 @@ func (self *nullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(file, "ukko-") {
page := getUkkoPage(file)
template.genUkkoPaginated(self.prefix, self.name, w, self.database, page, isjson, i18n, self.invertPagination)
pages, _ := self.database.GetUkkoPageCount(10)
template.genUkkoPaginated(self.prefix, self.name, w, self.database, int(pages), page, isjson, i18n, self.invertPagination)
return
}
if strings.HasPrefix(file, "thread-") {

View File

@ -261,18 +261,18 @@ func (self *templateEngine) genBoardPage(allowFiles, requireCaptcha bool, prefix
func (self *templateEngine) genUkko(prefix, frontend string, wr io.Writer, database Database, json bool, i18n *I18N, invertPagination bool) {
var page int64
var err error
pages, err := database.GetUkkoPageCount(10)
if invertPagination {
page, err = database.GetUkkoPageCount(10)
page = pages
}
if err == nil {
self.genUkkoPaginated(prefix, frontend, wr, database, int(page), json, i18n, invertPagination)
self.genUkkoPaginated(prefix, frontend, wr, database, int(pages), int(page), json, i18n, invertPagination)
} else {
log.Println("genUkko()", err.Error())
}
}
func (self *templateEngine) genUkkoPaginated(prefix, frontend string, wr io.Writer, database Database, page int, json bool, i18n *I18N, invertPagination bool) {
func (self *templateEngine) genUkkoPaginated(prefix, frontend string, wr io.Writer, database Database, pages, page int, json bool, i18n *I18N, invertPagination bool) {
var threads []ThreadModel
for _, article := range database.GetLastBumpedThreadsPaginated("", 10, page*10) {
root := article[0]
@ -283,7 +283,7 @@ func (self *templateEngine) genUkkoPaginated(prefix, frontend string, wr io.Writ
}
}
obj := map[string]interface{}{"prefix": prefix, "threads": threads, "page": page}
if invertPagination {
if invertPagination && page < pages {
obj["prev"] = map[string]interface{}{"no": page + 1}
} else if page > 0 {
obj["prev"] = map[string]interface{}{"no": page - 1}