Archived
1
0
This commit is contained in:
Jeff Becker 2018-03-09 09:58:56 -05:00
parent e2de5edd43
commit b61c22898e
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
4 changed files with 9 additions and 7 deletions

View File

@ -341,7 +341,7 @@ type Database interface {
FindHeaders(group, headername string, lo, hi int64) (ArticleHeaders, error)
// count ukko pages
GetUkkoPageCount() (int64, error)
GetUkkoPageCount(perpage int) (int64, error)
}
func NewDatabase(db_type, schema, host, port, user, password string) Database {

View File

@ -137,10 +137,12 @@ func (self *nullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
if page == 0 {
template.genUkko(self.prefix, self.name, w, self.database, isjson, i18n, self.invertPagination)
} else {
template.genUkkoPaginated(self.prefix, self.name, w, self.database, page, isjson, i18n, self.invertPagination)
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)
return
}

View File

@ -2001,8 +2001,9 @@ func (self *PostgresDatabase) FindCitesInText(text string) (msgids []string, err
return
}
func (self *PostgresDatabase) GetUkkoPageCount() (count int64, err error) {
func (self *PostgresDatabase) GetUkkoPageCount(perpage int) (count int64, err error) {
err = self.conn.QueryRow(self.stmt[CountUkko]).Scan(&count)
count /= int64(perpage)
return
}

View File

@ -263,8 +263,7 @@ func (self *templateEngine) genUkko(prefix, frontend string, wr io.Writer, datab
var page int64
var err error
if invertPagination {
page, err = database.GetUkkoPageCount()
page /= 10
page, err = database.GetUkkoPageCount(10)
}
if err == nil {
self.genUkkoPaginated(prefix, frontend, wr, database, int(page), json, i18n, invertPagination)