From 108302ff9b2ed4fd0ec12fff325b4714e5314a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Wed, 8 Mar 2017 11:48:12 +0800 Subject: [PATCH 1/3] remove dependency on future function no need six or future if there is only one function. --- cps/web.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cps/web.py b/cps/web.py index 07d7fb63..137b945b 100755 --- a/cps/web.py +++ b/cps/web.py @@ -50,13 +50,12 @@ from tornado import version as tornadoVersion try: from urllib.parse import quote from imp import reload - from past.builtins import xrange except ImportError as e: from urllib import quote try: from flask_login import __version__ as flask_loginVersion -except ImportError, e: +except ImportError as e: from flask_login.__about__ import __version__ as flask_loginVersion try: @@ -260,6 +259,10 @@ 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 if num <= left_edge or (num > self.page - left_current - 1 and num < self.page + right_current) \ or num > self.pages - right_edge: From d7afbdc34996d986bc42e2186e1e1478a3aff3cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Wed, 8 Mar 2017 13:26:52 +0800 Subject: [PATCH 2/3] use quote instead of urllib.quote --- cps/web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index 137b945b..7bd34c5c 100755 --- a/cps/web.py +++ b/cps/web.py @@ -704,7 +704,7 @@ def get_opds_download_link(book_id, format): file_name = book.authors[0].name + '-' + file_name file_name = helper.get_valid_filename(file_name) response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format)) - response.headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (urllib.quote(file_name.encode('utf8')), format) + response.headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (quote(file_name.encode('utf8')), format) return response From a87fab8774329b08c6e513f07f8e6ba8c9385ab4 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Tue, 14 Mar 2017 19:48:17 +0100 Subject: [PATCH 3/3] - Smaller cover picturees on small devices - filename for download with underscore --- cps/templates/detail.html | 2 +- cps/web.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cps/templates/detail.html b/cps/templates/detail.html index ce7e179a..4a3ae2b1 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -2,7 +2,7 @@ {% block body %}
-
+
{% if entry.has_cover %} diff --git a/cps/web.py b/cps/web.py index 539d9984..6cb53981 100755 --- a/cps/web.py +++ b/cps/web.py @@ -700,7 +700,7 @@ def get_opds_download_link(book_id, format): helper.update_download(book_id, int(current_user.id)) file_name = book.title if len(book.authors) > 0: - file_name = book.authors[0].name + '-' + file_name + file_name = book.authors[0].name + '_' + file_name file_name = helper.get_valid_filename(file_name) response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format)) response.headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (quote(file_name.encode('utf8')), format) @@ -1324,7 +1324,7 @@ def get_download_link(book_id, format): helper.update_download(book_id, int(current_user.id)) file_name = book.title if len(book.authors) > 0: - file_name = book.authors[0].name + '-' + file_name + file_name = book.authors[0].name + '_' + file_name file_name = helper.get_valid_filename(file_name) response = make_response( send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format))