From 6caf132fef05ab66ab2cd85964d230d0438eb430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Thu, 2 Mar 2017 18:31:21 +0800 Subject: [PATCH 01/14] init travis --- .travis.yml | 22 ++++++++++++++++++++++ build.sh | 11 +++++++++++ readme.md | 1 + 3 files changed, 34 insertions(+) create mode 100644 .travis.yml create mode 100755 build.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..c8115603 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: python + +python: +# - "2.6" + - "2.7" +# - "3.2" +# - "3.3" +# - "3.4" +# - "3.5" +# - "3.5-dev" # 3.5 development branch + - "3.6" +# - "3.6-dev" # 3.6 development branch +# - "3.7-dev" # 3.7 development branch +# - "nightly" # currently points to 3.7-dev + +install: false + +branches: + only: + - travis + +script: ./build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..1b051883 --- /dev/null +++ b/build.sh @@ -0,0 +1,11 @@ +#!/bin/sh +python -m py_compile cps.py +python -m py_compile cps/book_formats.py +python -m py_compile cps/db.py +python -m py_compile cps/epub.py +python -m py_compile cps/fb2.py +python -m py_compile cps/helper.py +python -m py_compile cps/ub.py +python -m py_compile cps/uploader.py +python -m py_compile cps/web.py +python -m py_compile cps.py diff --git a/readme.md b/readme.md index 102d4b2e..8b36e132 100755 --- a/readme.md +++ b/readme.md @@ -1,3 +1,4 @@ +##Forked from [janeczku/calibre-web](https://github.com/janeczku/calibre-web) [![Build Status](https://travis-ci.org/Kennyl/calibre-web.svg?branch=master)](https://travis-ci.org/Kennyl/calibre-web) ##About Calibre Web is a web app providing a clean interface for browsing, reading and downloading eBooks using an existing [Calibre](https://calibre-ebook.com) database. From 9ca88840eb30a7a51d4fd12a38582efeb1c88655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Sun, 5 Mar 2017 15:30:35 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E2=80=9C-=E2=80=9C=20is=20removed=20at?= =?UTF-8?q?=20helper=20,=20so=20use=20=E2=80=9C=5F=E2=80=9D=20instead?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cps/web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index 5687d604..ff61c022 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1275,7 +1275,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)) From 3a9a327957c6966766c13e4b79b20a515fb0cfd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Sun, 5 Mar 2017 15:43:56 +0800 Subject: [PATCH 03/14] Fix build script --- .travis.yml | 7 +++++++ build.sh | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c8115603..7fa2b4c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,13 @@ python: # - "3.7-dev" # 3.7 development branch # - "nightly" # currently points to 3.7-dev +matrix: + include: + - python: "2.7" + env: PVERSION=2 + - python: "3.6" + env: PVERSION=3 + install: false branches: diff --git a/build.sh b/build.sh index 1b051883..bd0ff5b0 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,5 @@ #!/bin/sh +if [[$PVERSION=2]]; then python -m py_compile cps.py python -m py_compile cps/book_formats.py python -m py_compile cps/db.py @@ -8,4 +9,18 @@ python -m py_compile cps/helper.py python -m py_compile cps/ub.py python -m py_compile cps/uploader.py python -m py_compile cps/web.py -python -m py_compile cps.py +python -m py_compile cps.py +fi +f [[$PVERSION=3]]; then +python3.6 -m py_compile cps.py +python3.6 -m py_compile cps/book_formats.py +python3.6 -m py_compile cps/db.py +python3.6 -m py_compile cps/epub.py +python3.6 -m py_compile cps/fb2.py +python3.6 -m py_compile cps/helper.py +python3.6 -m py_compile cps/ub.py +python3.6 -m py_compile cps/uploader.py +python3.6 -m py_compile cps/web.py +python3.6 -m py_compile cps.py +fi + From 5bd93186c2dd94dfa2f4c6387fc1abc7af05bbe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Sun, 5 Mar 2017 15:51:20 +0800 Subject: [PATCH 04/14] Fix shell script bug --- .travis.yml | 6 +++--- build.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7fa2b4c6..49024a22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,14 @@ language: python -python: +#python: # - "2.6" - - "2.7" +# - "2.7" # - "3.2" # - "3.3" # - "3.4" # - "3.5" # - "3.5-dev" # 3.5 development branch - - "3.6" +# - "3.6" # - "3.6-dev" # 3.6 development branch # - "3.7-dev" # 3.7 development branch # - "nightly" # currently points to 3.7-dev diff --git a/build.sh b/build.sh index bd0ff5b0..0e799931 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,5 @@ #!/bin/sh -if [[$PVERSION=2]]; then +if [[ $PVERSION = 2 ]]; then python -m py_compile cps.py python -m py_compile cps/book_formats.py python -m py_compile cps/db.py @@ -11,7 +11,7 @@ python -m py_compile cps/uploader.py python -m py_compile cps/web.py python -m py_compile cps.py fi -f [[$PVERSION=3]]; then +if [[ $PVERSION = 3 ]]; then python3.6 -m py_compile cps.py python3.6 -m py_compile cps/book_formats.py python3.6 -m py_compile cps/db.py From d56d67ce43893c2a5cacae1c53765f7950bb7013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Sun, 5 Mar 2017 15:55:10 +0800 Subject: [PATCH 05/14] Fix bash --- .travis.yml | 16 ++++++++-------- build.sh | 17 ++--------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 49024a22..d863179d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,23 +2,23 @@ language: python #python: # - "2.6" -# - "2.7" + - "2.7" # - "3.2" # - "3.3" # - "3.4" # - "3.5" # - "3.5-dev" # 3.5 development branch -# - "3.6" + - "3.6" # - "3.6-dev" # 3.6 development branch # - "3.7-dev" # 3.7 development branch # - "nightly" # currently points to 3.7-dev -matrix: - include: - - python: "2.7" - env: PVERSION=2 - - python: "3.6" - env: PVERSION=3 +#matrix: +# include: +# - python: "2.7" +# env: PVERSION=2 +# - python: "3.6" +# env: PVERSION=3 install: false diff --git a/build.sh b/build.sh index 0e799931..fc04dc21 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,6 @@ #!/bin/sh -if [[ $PVERSION = 2 ]]; then +set -x + python -m py_compile cps.py python -m py_compile cps/book_formats.py python -m py_compile cps/db.py @@ -10,17 +11,3 @@ python -m py_compile cps/ub.py python -m py_compile cps/uploader.py python -m py_compile cps/web.py python -m py_compile cps.py -fi -if [[ $PVERSION = 3 ]]; then -python3.6 -m py_compile cps.py -python3.6 -m py_compile cps/book_formats.py -python3.6 -m py_compile cps/db.py -python3.6 -m py_compile cps/epub.py -python3.6 -m py_compile cps/fb2.py -python3.6 -m py_compile cps/helper.py -python3.6 -m py_compile cps/ub.py -python3.6 -m py_compile cps/uploader.py -python3.6 -m py_compile cps/web.py -python3.6 -m py_compile cps.py -fi - From f315d54c879a436e990beba01e00fe4ed95642c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Sun, 5 Mar 2017 15:56:27 +0800 Subject: [PATCH 06/14] fix yams --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d863179d..c174aedd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python -#python: +python: # - "2.6" - "2.7" # - "3.2" From fca1fc23da167cf56c156f0d83e981f01263067a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Mon, 6 Mar 2017 14:30:45 +0800 Subject: [PATCH 07/14] double requirement fix --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 51056ce0..1eb4cb70 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ future -sqlalchemy +#sqlalchemy PyPDF2 babel From 376eb8752ec7a051808c58e3a27fbe6e201b3c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Mon, 6 Mar 2017 14:46:44 +0800 Subject: [PATCH 08/14] wrong conflict merge --- cps/epub.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cps/epub.py b/cps/epub.py index 563faa1c..455b1ab8 100644 --- a/cps/epub.py +++ b/cps/epub.py @@ -71,9 +71,7 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension): epub_metadata['language'] = isoLanguages.get(part3=lang).name else: epub_metadata['language'] = "" - except IndexError as e: - epub_metadata['language'] = "" - + coversection = tree.xpath("/pkg:package/pkg:manifest/pkg:item[@id='cover-image']/@href", namespaces=ns) coverfile = None if len(coversection) > 0: From dc985e76df12f3a0f9651054baaa49c294af2b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Mon, 6 Mar 2017 18:23:33 +0800 Subject: [PATCH 09/14] python3 fix --- cps/web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index 3387f150..82cee89d 100755 --- a/cps/web.py +++ b/cps/web.py @@ -683,7 +683,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=\"%s.%s\"" % (urllib.quote(file_name.encode('utf8')), format) + response.headers["Content-Disposition"] = "attachment; filename=\"%s.%s\"" % (quote(file_name.encode('utf8')), format) return response From 8c625dfb938f6f570456c64a05ff46921d733b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Wed, 8 Mar 2017 13:56:13 +0800 Subject: [PATCH 10/14] Fix #146 For WebUI only OPDS remains previous behaviour --- cps/templates/detail.html | 2 +- cps/web.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cps/templates/detail.html b/cps/templates/detail.html index 9639e954..510cfb68 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -126,7 +126,7 @@ diff --git a/cps/web.py b/cps/web.py index 07d7fb63..eed95f11 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1309,7 +1309,6 @@ def read_book(book_id, format): flash(_(u"Error opening eBook. File does not exist or file is not accessible:"), category="error") return redirect(url_for("index")) - @app.route("/download//") @login_required_if_no_ano @download_required @@ -1336,6 +1335,11 @@ def get_download_link(book_id, format): else: abort(404) +@app.route("/download///") +@login_required_if_no_ano +@download_required +def get_download_link_ext(book_id, format, anyname): + return get_download_link(book_id, format) @app.route('/register', methods=['GET', 'POST']) def register(): From a7d361a0ffa6f73ca4fe4c707e8b7a14db091be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Wed, 8 Mar 2017 23:52:41 +0800 Subject: [PATCH 11/14] merge conflict --- cps/web.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cps/web.py b/cps/web.py index 06e0b037..809cedc8 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1331,11 +1331,7 @@ def get_download_link(book_id, format): response.headers["Content-Type"] = mimetypes.types_map['.' + format] except Exception as e: pass -<<<<<<< HEAD - response.headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (urllib.quote(file_name.encode('utf-8')), format) -======= response.headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (quote(file_name.encode('utf-8')), format) ->>>>>>> master return response else: abort(404) From 7bae79d82621684141fece5f2b0428d198a74413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Wed, 8 Mar 2017 23:56:20 +0800 Subject: [PATCH 12/14] fix conflict --- cps/epub.py | 12 ------------ cps/templates/book_edit.html | 2 -- 2 files changed, 14 deletions(-) diff --git a/cps/epub.py b/cps/epub.py index 368eadf5..446efe9b 100644 --- a/cps/epub.py +++ b/cps/epub.py @@ -41,14 +41,6 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension): p = tree.xpath('/pkg:package/pkg:metadata', namespaces=ns)[0] epub_metadata = {} -<<<<<<< HEAD - try:#maybe description isn't present - comments = tree.xpath("//*[local-name() = 'description']/text()")[0] - epub_metadata['comments'] = comments - except IndexError as e: - epub_metadata['comments'] = "" -======= ->>>>>>> master for s in ['title', 'description', 'creator', 'language']: tmp = p.xpath('dc:%s/text()' % s, namespaces=ns) @@ -74,11 +66,7 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension): epub_metadata['language'] = isoLanguages.get(part3=lang).name else: epub_metadata['language'] = "" -<<<<<<< HEAD - -======= ->>>>>>> master coversection = tree.xpath("/pkg:package/pkg:manifest/pkg:item[@id='cover-image']/@href", namespaces=ns) coverfile = None if len(coversection) > 0: diff --git a/cps/templates/book_edit.html b/cps/templates/book_edit.html index 86b7281e..f3425995 100644 --- a/cps/templates/book_edit.html +++ b/cps/templates/book_edit.html @@ -150,9 +150,7 @@ -<<<<<<< HEAD -======= {% endblock %} {% block header %} From d7d29827f440bc52d89988fde9f0dca6e34ba8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Wed, 8 Mar 2017 23:59:56 +0800 Subject: [PATCH 13/14] fix behind --- cps/web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index 809cedc8..930a1093 100755 --- a/cps/web.py +++ b/cps/web.py @@ -56,7 +56,7 @@ except ImportError as e: 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: From 045419e880f64ea8d11d0a3bf3fcdb7641862b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Thu, 9 Mar 2017 12:32:10 +0800 Subject: [PATCH 14/14] Fix #146 For WebUI only OPDS remains previous behaviour --- cps/templates/detail.html | 2 +- cps/web.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cps/templates/detail.html b/cps/templates/detail.html index 9639e954..ce7e179a 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -126,7 +126,7 @@ diff --git a/cps/web.py b/cps/web.py index 07d7fb63..eed95f11 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1309,7 +1309,6 @@ def read_book(book_id, format): flash(_(u"Error opening eBook. File does not exist or file is not accessible:"), category="error") return redirect(url_for("index")) - @app.route("/download//") @login_required_if_no_ano @download_required @@ -1336,6 +1335,11 @@ def get_download_link(book_id, format): else: abort(404) +@app.route("/download///") +@login_required_if_no_ano +@download_required +def get_download_link_ext(book_id, format, anyname): + return get_download_link(book_id, format) @app.route('/register', methods=['GET', 'POST']) def register():