From 54079b36ae9525d48514e9242a26633a9ca58498 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 1 Dec 2019 12:21:21 +0100 Subject: [PATCH] Fix #1095 (epub viewer not working if only viewer rule wa sapplied) --- cps/templates/read.html | 2 +- cps/web.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cps/templates/read.html b/cps/templates/read.html index 88eaba0d..b3caec49 100644 --- a/cps/templates/read.html +++ b/cps/templates/read.html @@ -86,7 +86,7 @@ filePath: "{{ url_for('static', filename='js/libs/') }}", cssPath: "{{ url_for('static', filename='css/') }}", bookmarkUrl: "{{ url_for('web.bookmark', book_id=bookid, book_format='EPUB') }}", - bookUrl: "{{ url_for('web.download_link', book_id=bookid, book_format='epub', anyname='file.epub') }}", + bookUrl: "{{ url_for('web.serve_book', book_id=bookid, book_format='epub', anyname='file.epub') }}", bookmark: "{{ bookmark.bookmark_key if bookmark != None }}", useBookmarks: "{{ g.user.is_authenticated | tojson }}" }; diff --git a/cps/web.py b/cps/web.py index 00db18b9..7aa921e4 100644 --- a/cps/web.py +++ b/cps/web.py @@ -992,10 +992,11 @@ def get_cover(book_id): return get_book_cover(book_id) -@web.route("/show//") +@web.route("/show//", defaults={'anyname': 'None'}) +@web.route("/show///") @login_required_if_no_ano @viewer_required -def serve_book(book_id, book_format): +def serve_book(book_id, book_format, anyname): book_format = book_format.split(".")[0] book = db.session.query(db.Books).filter(db.Books.id == book_id).first() data = db.session.query(db.Data).filter(db.Data.book == book.id).filter(db.Data.format == book_format.upper())\ @@ -1010,11 +1011,11 @@ def serve_book(book_id, book_format): return send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + book_format) -@web.route("/download//", defaults={'anyname': 'None'}) -@web.route("/download///") +# @web.route("/download//", defaults={'anyname': 'None'}) +@web.route("/download//") @login_required_if_no_ano @download_required -def download_link(book_id, book_format, anyname): +def download_link(book_id, book_format): return get_download_link(book_id, book_format)