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) FindHeaders(group, headername string, lo, hi int64) (ArticleHeaders, error)
// count ukko pages // count ukko pages
GetUkkoPageCount() (int64, error) GetUkkoPageCount(perpage int) (int64, error)
} }
func NewDatabase(db_type, schema, host, port, user, password string) Database { 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 { if page == 0 {
template.genUkko(self.prefix, self.name, w, self.database, isjson, i18n, self.invertPagination) if self.invertPagination {
} else { pages, _ := self.database.GetUkkoPageCount(10)
template.genUkkoPaginated(self.prefix, self.name, w, self.database, page, isjson, i18n, self.invertPagination) page = int(pages)
}
} }
template.genUkkoPaginated(self.prefix, self.name, w, self.database, page, isjson, i18n, self.invertPagination)
return return
} }

View File

@ -2001,8 +2001,9 @@ func (self *PostgresDatabase) FindCitesInText(text string) (msgids []string, err
return 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) err = self.conn.QueryRow(self.stmt[CountUkko]).Scan(&count)
count /= int64(perpage)
return return
} }

View File

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