diff --git a/cps/admin.py b/cps/admin.py index 5286cf8e..424a12b4 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -132,6 +132,7 @@ def admin(): allUser = ub.session.query(ub.User).all() email_settings = config.get_mail_settings() return render_title_template("admin.html", allUser=allUser, email=email_settings, config=config, commit=commit, + feature_support=feature_support, title=_(u"Admin page"), page="admin") @@ -637,6 +638,7 @@ def _configuration_update_helper(): _config_checkbox_int(to_save, "config_public_reg") _config_checkbox_int(to_save, "config_register_email") reboot_required |= _config_checkbox_int(to_save, "config_kobo_sync") + _config_int(to_save, "config_external_port") _config_checkbox_int(to_save, "config_kobo_proxy") _config_string(to_save, "config_upload_formats") diff --git a/cps/config_sql.py b/cps/config_sql.py index 3885bb01..3573abe7 100644 --- a/cps/config_sql.py +++ b/cps/config_sql.py @@ -57,6 +57,7 @@ class _Settings(_Base): config_calibre_dir = Column(String) config_port = Column(Integer, default=constants.DEFAULT_PORT) + config_external_port = Column(Integer, default=constants.DEFAULT_PORT) config_certfile = Column(String) config_keyfile = Column(String) diff --git a/cps/kobo.py b/cps/kobo.py index 70c4b45a..a6dfc3f6 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -129,7 +129,7 @@ def HandleSyncRequest(): sync_token = SyncToken.SyncToken.from_headers(request.headers) log.info("Kobo library sync request received.") if not current_app.wsgi_app.is_proxied: - log.debug('Kobo: Received unproxied request, changed request port to server port') + log.debug('Kobo: Received unproxied request, changed request port to external server port') # TODO: Limit the number of books return per sync call, and rely on the sync-continuatation header # instead so that the device triggers another sync. @@ -252,7 +252,7 @@ def generate_sync_response(sync_token, sync_results): @download_required def HandleMetadataRequest(book_uuid): if not current_app.wsgi_app.is_proxied: - log.debug('Kobo: Received unproxied request, changed request port to server port') + log.debug('Kobo: Received unproxied request, changed request port to external server port') log.info("Kobo library metadata request received for book %s" % book_uuid) book = calibre_db.get_book_by_uuid(book_uuid) if not book or not book.data: @@ -269,10 +269,11 @@ def get_download_url_for_book(book, book_format): host = "".join(request.host.split(':')[:-1]) else: host = request.host + return "{url_scheme}://{url_base}:{url_port}/download/{book_id}/{book_format}".format( url_scheme=request.scheme, url_base=host, - url_port=config.config_port, + url_port=config.config_external_port, book_id=book.id, book_format=book_format.lower() ) @@ -924,7 +925,7 @@ def HandleInitRequest(): kobo_resources = NATIVE_KOBO_RESOURCES() if not current_app.wsgi_app.is_proxied: - log.debug('Kobo: Received unproxied request, changed request port to server port') + log.debug('Kobo: Received unproxied request, changed request port to external server port') if ':' in request.host and not request.host.endswith(']'): host = "".join(request.host.split(':')[:-1]) else: @@ -932,8 +933,9 @@ def HandleInitRequest(): calibre_web_url = "{url_scheme}://{url_base}:{url_port}".format( url_scheme=request.scheme, url_base=host, - url_port=config.config_port + url_port=config.config_external_port ) + log.debug('Kobo: Received unproxied request, changed request url to %s', calibre_web_url) kobo_resources["image_host"] = calibre_web_url kobo_resources["image_url_quality_template"] = unquote(calibre_web_url + url_for("kobo.HandleCoverImageRequest", @@ -942,16 +944,14 @@ def HandleInitRequest(): width="{width}", height="{height}", Quality='{Quality}', - isGreyscale='isGreyscale' - )) + isGreyscale='isGreyscale')) kobo_resources["image_url_template"] = unquote(calibre_web_url + url_for("kobo.HandleCoverImageRequest", auth_token=kobo_auth.get_auth_token(), book_uuid="{ImageId}", width="{width}", height="{height}", - isGreyscale='false' - )) + isGreyscale='false')) else: kobo_resources["image_host"] = url_for("web.index", _external=True).strip("/") kobo_resources["image_url_quality_template"] = unquote(url_for("kobo.HandleCoverImageRequest", @@ -970,7 +970,6 @@ def HandleInitRequest(): isGreyscale='false', _external=True)) - response = make_response(jsonify({"Resources": kobo_resources})) response.headers["x-kobo-apitoken"] = "e30=" diff --git a/cps/templates/admin.html b/cps/templates/admin.html index 4d66a47a..b19dc235 100644 --- a/cps/templates/admin.html +++ b/cps/templates/admin.html @@ -88,6 +88,12 @@
{{_('Port')}}
{{config.config_port}}
+ {% if feature_support['kobo'] and config.config_port != config.config_external_port %} +
+
{{_('External Port')}}
+
{{config.config_external_port}}
+
+ {% endif %}
diff --git a/cps/templates/config_edit.html b/cps/templates/config_edit.html index 2d1ae560..132db5cf 100644 --- a/cps/templates/config_edit.html +++ b/cps/templates/config_edit.html @@ -194,10 +194,14 @@
-
+
+
+ + +
{% endif %} {% if feature_support['goodreads'] %} diff --git a/test/Calibre-Web TestSummary.html b/test/Calibre-Web TestSummary.html index 70269acb..9185d2ee 100755 --- a/test/Calibre-Web TestSummary.html +++ b/test/Calibre-Web TestSummary.html @@ -36,17 +36,17 @@
-

Start Time: 2020-08-14 19:46:42

+

Start Time: 2020-08-23 18:29:00

-

Stop Time: 2020-08-14 21:02:08

+

Stop Time: 2020-08-23 19:44:09

-

Duration: 1h 243 min

+

Duration: 1h 212 min

@@ -955,6 +955,58 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye + + test_edit_books_gdrive.test_edit_books_gdrive + 1 + 0 + 0 + 1 + 0 + + Detail + + + + + + + +
test_config_gdrive
+ + +
+ ERROR +
+ + + + + + + + + test_email_STARTTLS.test_STARTTLS 3 @@ -963,13 +1015,13 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye 0 0 - Detail + Detail - +
test_STARTTLS
@@ -978,7 +1030,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_STARTTLS_SSL_setup_error
@@ -987,7 +1039,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_STARTTLS_resend_password
@@ -1005,13 +1057,13 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye 0 0 - Detail + Detail - +
test_SSL_None_setup_error
@@ -1020,7 +1072,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_SSL_STARTTLS_setup_error
@@ -1029,7 +1081,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_SSL_logging_email
@@ -1038,7 +1090,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_SSL_only
@@ -1056,13 +1108,13 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye 0 0 - Detail + Detail - +
test_author_page
@@ -1071,7 +1123,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_author_page_invalid
@@ -1080,7 +1132,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_goodreads_about
@@ -1092,19 +1144,19 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye test_helper.CalibreHelper - 15 - 15 + 16 + 16 0 0 0 - Detail + Detail - +
test_author_sort
@@ -1113,7 +1165,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_author_sort_comma
@@ -1122,7 +1174,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_author_sort_junior
@@ -1131,7 +1183,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_author_sort_oneword
@@ -1140,7 +1192,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_author_sort_roman
@@ -1149,7 +1201,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_check_Limit_Length
@@ -1158,7 +1210,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_check_char_replacement
@@ -1167,7 +1219,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_check_chinese_Characters
@@ -1176,7 +1228,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_check_deg_eur_replacement
@@ -1185,7 +1237,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_check_doubleS
@@ -1194,7 +1246,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_check_finish_Dot
@@ -1203,7 +1255,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_check_high23
@@ -1212,7 +1264,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_check_umlauts
@@ -1221,7 +1273,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_random_password
@@ -1230,7 +1282,16 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - + + +
test_split_authors
+ + PASS + + + + +
test_whitespaces
@@ -1241,87 +1302,67 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - test_kobo_sync.TestKoboSync - 8 - 8 + unittest.loader._FailedTest + 1 0 0 + 1 0 - Detail + Detail - - -
test_kobo_about
- - PASS - - - - - - -
test_shelves_add_remove_books
- - PASS - - - - - - -
test_sync_changed_book
- - PASS - - - - - - -
test_sync_invalid
- - PASS - - - - - - -
test_sync_reading_state
- - PASS - - - - - - -
test_sync_shelf
- - PASS - - - - - + -
test_sync_unchanged
+
unittestloader_FailedTest)
- PASS - - - - - - -
test_sync_upload
+ +
+ ERROR +
+ + + - PASS @@ -1335,13 +1376,13 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye 0 0 - Detail + Detail - +
test_LDAP_SSL
@@ -1350,7 +1391,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_LDAP_STARTTLS
@@ -1359,7 +1400,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_LDAP_fallback_Login
@@ -1368,7 +1409,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_LDAP_import
@@ -1377,7 +1418,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_LDAP_login
@@ -1386,7 +1427,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_invalid_LDAP
@@ -1395,7 +1436,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_ldap_about
@@ -1404,7 +1445,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_ldap_authentication
@@ -1413,7 +1454,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_ldap_kobo_sync
@@ -1422,7 +1463,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_ldap_opds_download_book
@@ -1440,13 +1481,13 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye 0 1 - Detail + Detail - +
test_access_log_recover
@@ -1455,7 +1496,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_debug_log
@@ -1464,7 +1505,7 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_failed_login
@@ -1473,19 +1514,19 @@ AssertionError: False is not true : Browser-Cache Problem: Old Cover is displaye - +
test_failed_register
- SKIP + SKIP
-