mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-01 05:49:58 +00:00
Code Fix
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:
parent
7a07edaff4
commit
b51afe3ead
16
cps/web.py
16
cps/web.py
@ -11,8 +11,9 @@ import mimetypes
|
|||||||
import logging
|
import logging
|
||||||
from logging.handlers import RotatingFileHandler
|
from logging.handlers import RotatingFileHandler
|
||||||
import textwrap
|
import textwrap
|
||||||
from flask import Flask, render_template, request, Response, redirect, url_for, send_from_directory, \
|
from flask import (Flask, render_template, request, Response, redirect,
|
||||||
make_response, g, flash, abort, Markup, stream_with_context
|
url_for, send_from_directory, make_response, g, flash,
|
||||||
|
abort, Markup, stream_with_context)
|
||||||
from flask import __version__ as flaskVersion
|
from flask import __version__ as flaskVersion
|
||||||
import ub
|
import ub
|
||||||
from ub import config
|
from ub import config
|
||||||
@ -24,7 +25,8 @@ from sqlalchemy.sql.expression import false
|
|||||||
from sqlalchemy.exc import IntegrityError
|
from sqlalchemy.exc import IntegrityError
|
||||||
from sqlalchemy import __version__ as sqlalchemyVersion
|
from sqlalchemy import __version__ as sqlalchemyVersion
|
||||||
from math import ceil
|
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 Principal
|
||||||
from flask_principal import __version__ as flask_principalVersion
|
from flask_principal import __version__ as flask_principalVersion
|
||||||
from flask_babel import Babel
|
from flask_babel import Babel
|
||||||
@ -338,11 +340,7 @@ class Pagination(object):
|
|||||||
def iter_pages(self, left_edge=2, left_current=2,
|
def iter_pages(self, left_edge=2, left_current=2,
|
||||||
right_current=5, right_edge=2):
|
right_current=5, right_edge=2):
|
||||||
last = 0
|
last = 0
|
||||||
if 'xrange' not in globals():#no xrange in Python3
|
for num in range(self.pages, (self.pages + 1)): # ToDo: can be simplified
|
||||||
global xrange
|
|
||||||
xrange = range
|
|
||||||
|
|
||||||
for num in xrange(1, self.pages + 1): # ToDo: can be simplified
|
|
||||||
if num <= left_edge or (num > self.page - left_current - 1 and num < self.page + right_current) \
|
if num <= left_edge or (num > self.page - left_current - 1 and num < self.page + right_current) \
|
||||||
or num > self.pages - right_edge:
|
or num > self.pages - right_edge:
|
||||||
if last + 1 != num:
|
if last + 1 != num:
|
||||||
@ -608,7 +606,7 @@ def feed_new():
|
|||||||
off = request.args.get("offset")
|
off = request.args.get("offset")
|
||||||
if not off:
|
if not off:
|
||||||
off = 0
|
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())
|
db.Books, True, db.Books.timestamp.desc())
|
||||||
xml = render_title_template('feed.xml', entries=entries, pagination=pagination)
|
xml = render_title_template('feed.xml', entries=entries, pagination=pagination)
|
||||||
response = make_response(xml)
|
response = make_response(xml)
|
||||||
|
Loading…
Reference in New Issue
Block a user