From a80735d7d389d622639e1026db8991476c8058f2 Mon Sep 17 00:00:00 2001 From: Olivier Date: Tue, 11 Oct 2022 23:37:12 +0900 Subject: [PATCH 01/16] Save the position of the last read page for comics --- cps/static/js/kthoom.js | 35 ++--- cps/templates/readcbr.html | 307 ++++++++++++++++++++----------------- cps/web.py | 2 +- 3 files changed, 187 insertions(+), 157 deletions(-) diff --git a/cps/static/js/kthoom.js b/cps/static/js/kthoom.js index 51dbadba..c587206f 100644 --- a/cps/static/js/kthoom.js +++ b/cps/static/js/kthoom.js @@ -70,8 +70,8 @@ var settings = { fitMode: kthoom.Key.B, theme: "light", direction: 0, // 0 = Left to Right, 1 = Right to Left - nextPage: 0, // 0 = Reset to Top, 1 = Remember Position - scrollbar: 1 // 0 = Hide Scrollbar, 1 = Show Scrollbar + nextPage: 0, // 0 = Reset to Top, 1 = Remember Position + scrollbar: 1 // 0 = Hide Scrollbar, 1 = Show Scrollbar }; kthoom.saveSettings = function() { @@ -130,7 +130,7 @@ var createURLFromArray = function(array, mimeType) { } if ((typeof URL !== "function" && typeof URL !== "object") || - typeof URL.createObjectURL !== "function") { + typeof URL.createObjectURL !== "function") { throw "Browser support for Object URLs is missing"; } @@ -186,8 +186,7 @@ function initProgressClick() { }); } -function loadFromArrayBuffer(ab) { - var lastCompletion = 0; +function loadFromArrayBuffer(ab, lastCompletion = 0) { const collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' }); loadArchiveFormats(['rar', 'zip', 'tar'], function() { // Open the file as an archive @@ -244,7 +243,7 @@ function updatePage() { // Mark the current page in the TOC $("#tocView a[data-page]") - // Remove the currently active thumbnail + // Remove the currently active thumbnail .removeClass("active") // Find the new one .filter("[data-page=" + (currentImage + 1) + "]") @@ -261,7 +260,7 @@ function updatePage() { } $("body").toggleClass("dark-theme", settings.theme === "dark"); - $("#mainContent").toggleClass("disabled-scrollbar", settings.scrollbar === 0); + $("#mainContent").toggleClass("disabled-scrollbar", settings.scrollbar === 0); kthoom.setSettings(); kthoom.saveSettings(); @@ -335,7 +334,7 @@ function setImage(url) { x.font = "50px sans-serif"; x.strokeStyle = "black"; x.fillText("Page #" + (currentImage + 1) + " (" + - imageFiles[currentImage].filename + ")", innerWidth / 2, 100); + imageFiles[currentImage].filename + ")", innerWidth / 2, 100); x.fillStyle = "black"; x.fillText("Is corrupt or not an image", innerWidth / 2, 200); @@ -418,9 +417,9 @@ function showPrevPage() { currentImage++; } else { updatePage(); - if (settings.nextPage === 0) { - $("#mainContent").scrollTop(0); - } + if (settings.nextPage === 0) { + $("#mainContent").scrollTop(0); + } } } @@ -431,9 +430,9 @@ function showNextPage() { currentImage--; } else { updatePage(); - if (settings.nextPage === 0) { - $("#mainContent").scrollTop(0); - } + if (settings.nextPage === 0) { + $("#mainContent").scrollTop(0); + } } } @@ -551,7 +550,7 @@ function init(filename) { request.responseType = "arraybuffer"; request.addEventListener("load", function() { if (request.status >= 200 && request.status < 300) { - loadFromArrayBuffer(request.response); + loadFromArrayBuffer(request.response, currentImage); } else { console.warn(request.statusText, request.responseText); } @@ -609,9 +608,9 @@ function init(filename) { $("#thumbnails").on("click", "a", function() { currentImage = $(this).data("page") - 1; updatePage(); - if (settings.nextPage === 0) { - $("#mainContent").scrollTop(0); - } + if (settings.nextPage === 0) { + $("#mainContent").scrollTop(0); + } }); // Fullscreen mode diff --git a/cps/templates/readcbr.html b/cps/templates/readcbr.html index 411e3fdd..6ab14a94 100644 --- a/cps/templates/readcbr.html +++ b/cps/templates/readcbr.html @@ -1,5 +1,6 @@ + @@ -17,78 +18,61 @@ - - +
-
- -
- +
+ + + + diff --git a/cps/web.py b/cps/web.py index 51ff32b3..9793f01a 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1561,7 +1561,7 @@ def read_book(book_id, book_format): title = title + " #" + '{0:.2f}'.format(book.series_index).rstrip('0').rstrip('.') log.debug("Start comic reader for %d", book_id) return render_title_template('readcbr.html', comicfile=all_name, title=title, - extension=fileExt) + extension=fileExt, bookmark=bookmark) log.debug("Selected book is unavailable. File does not exist or is not accessible") flash(_("Oops! Selected book is unavailable. File does not exist or is not accessible"), category="error") From 52172044e6bdb963c847e212f2d427d30ffd87c2 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 26 Aug 2023 20:12:52 +0200 Subject: [PATCH 15/16] Fix deprecation warnings --- cps/admin.py | 2 +- cps/editbooks.py | 5 ++--- cps/services/SyncToken.py | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cps/admin.py b/cps/admin.py index 93c1a3a9..045a9523 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -33,7 +33,7 @@ from functools import wraps from urllib.parse import urlparse from flask import Blueprint, flash, redirect, url_for, abort, request, make_response, send_from_directory, g, Response -from flask import Markup +from markupsafe import Markup from flask_login import login_required, current_user, logout_user from flask_babel import gettext as _ from flask_babel import get_locale, format_time, format_datetime, format_timedelta diff --git a/cps/editbooks.py b/cps/editbooks.py index 5a15740c..40f62713 100755 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -25,16 +25,15 @@ from datetime import datetime import json from shutil import copyfile from uuid import uuid4 -from markupsafe import escape # dependency of flask +from markupsafe import escape, Markup # dependency of flask from functools import wraps -import re try: from lxml.html.clean import clean_html, Cleaner except ImportError: clean_html = None -from flask import Blueprint, request, flash, redirect, url_for, abort, Markup, Response +from flask import Blueprint, request, flash, redirect, url_for, abort, Response from flask_babel import gettext as _ from flask_babel import lazy_gettext as N_ from flask_babel import get_locale diff --git a/cps/services/SyncToken.py b/cps/services/SyncToken.py index c44841c1..3af0e276 100644 --- a/cps/services/SyncToken.py +++ b/cps/services/SyncToken.py @@ -19,10 +19,9 @@ import sys from base64 import b64decode, b64encode -from jsonschema import validate, exceptions, __version__ -from datetime import datetime, timezone +from jsonschema import validate, exceptions +from datetime import datetime -from urllib.parse import unquote from flask import json from .. import logger From b2a26a421c2c2e7163e5a71b33e2dd50f753f09b Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 26 Aug 2023 20:26:01 +0200 Subject: [PATCH 16/16] Removed deprecation warning for sqlalchemy2.0 --- cps/db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/db.py b/cps/db.py index f0295fe5..ceb692ec 100644 --- a/cps/db.py +++ b/cps/db.py @@ -663,7 +663,7 @@ class CalibreDB: cls.session_factory = scoped_session(sessionmaker(autocommit=False, autoflush=True, - bind=cls.engine)) + bind=cls.engine, future=True)) for inst in cls.instances: inst.init_session()