1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-30 21:40:00 +00:00
Fix pagination logic.

_ is gettext , use __ as dummy variable instead of _

Need more test.

Test on following
http://localhost:8083/opds/new
http://localhost:8083/opds/new?offset=60
http://localhost:8083/opds/new?offset=120
This commit is contained in:
林檎 2017-04-14 21:57:27 +08:00
parent 7a07edaff4
commit b51afe3ead

View File

@ -11,8 +11,9 @@ import mimetypes
import logging
from logging.handlers import RotatingFileHandler
import textwrap
from flask import Flask, render_template, request, Response, redirect, url_for, send_from_directory, \
make_response, g, flash, abort, Markup, stream_with_context
from flask import (Flask, render_template, request, Response, redirect,
url_for, send_from_directory, make_response, g, flash,
abort, Markup, stream_with_context)
from flask import __version__ as flaskVersion
import ub
from ub import config
@ -24,7 +25,8 @@ from sqlalchemy.sql.expression import false
from sqlalchemy.exc import IntegrityError
from sqlalchemy import __version__ as sqlalchemyVersion
from math import ceil
from flask_login import LoginManager, login_user, logout_user, login_required, current_user
from flask_login import (LoginManager, login_user, logout_user,
login_required, current_user)
from flask_principal import Principal
from flask_principal import __version__ as flask_principalVersion
from flask_babel import Babel
@ -338,11 +340,7 @@ class Pagination(object):
def iter_pages(self, left_edge=2, left_current=2,
right_current=5, right_edge=2):
last = 0
if 'xrange' not in globals():#no xrange in Python3
global xrange
xrange = range
for num in xrange(1, self.pages + 1): # ToDo: can be simplified
for num in range(self.pages, (self.pages + 1)): # ToDo: can be simplified
if num <= left_edge or (num > self.page - left_current - 1 and num < self.page + right_current) \
or num > self.pages - right_edge:
if last + 1 != num:
@ -608,7 +606,7 @@ def feed_new():
off = request.args.get("offset")
if not off:
off = 0
entries, _, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
db.Books, True, db.Books.timestamp.desc())
xml = render_title_template('feed.xml', entries=entries, pagination=pagination)
response = make_response(xml)