From 097ac879eabb57b7dcf310dbe0bae956e2512013 Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Mon, 12 Oct 2020 09:31:58 +0200 Subject: [PATCH 1/5] render read --- cps/static/css/style.css | 23 +++++++++++++++++++---- cps/templates/grid.html | 6 ++++-- cps/templates/index.html | 3 +++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/cps/static/css/style.css b/cps/static/css/style.css index 2294d326..6b3cba15 100644 --- a/cps/static/css/style.css +++ b/cps/static/css/style.css @@ -123,12 +123,19 @@ a, .danger,.book-remove, .editable-empty, .editable-empty:hover { color: #45b29d position: relative; } -.container-fluid .book .cover img { +.container-fluid .book .cover span.img { + bottom: 0; + height: 100%; + position: absolute; +} + +.container-fluid .book .cover span img { + position: relative; + top: 0; + left: 0; + height: 100%; border: 1px solid #fff; box-sizing: border-box; - height: 100%; - bottom: 0; - position: absolute; -webkit-box-shadow: 0 5px 8px -6px #777; -moz-box-shadow: 0 5px 8px -6px #777; box-shadow: 0 5px 8px -6px #777; @@ -203,6 +210,14 @@ span.glyphicon.glyphicon-tags { left: 2px; background-color: #777; } +.cover .read{ + left: auto; + right: 2px; + width: 17px; + height: 17px; + display: inline-block; + padding: 2px; +} .cover-height { max-height: 100px;} .col-sm-2 a .cover-small { diff --git a/cps/templates/grid.html b/cps/templates/grid.html index 4aa0b7df..c44af387 100644 --- a/cps/templates/grid.html +++ b/cps/templates/grid.html @@ -28,8 +28,10 @@
- {{ entry[0].name }} - {{entry.count}} + + {{ entry[0].name }} + {{entry.count}} +
diff --git a/cps/templates/index.html b/cps/templates/index.html index e60f92fe..319fd60f 100644 --- a/cps/templates/index.html +++ b/cps/templates/index.html @@ -79,7 +79,10 @@
From 754b9832e95081b22e22e91dd57b65cf595adf37 Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Sat, 17 Oct 2020 13:30:19 +0200 Subject: [PATCH 2/5] fix height container --- cps/static/css/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/cps/static/css/style.css b/cps/static/css/style.css index 6b3cba15..abe0ca48 100644 --- a/cps/static/css/style.css +++ b/cps/static/css/style.css @@ -111,6 +111,7 @@ a, .danger,.book-remove, .editable-empty, .editable-empty:hover { color: #45b29d display: block; max-width: 100%; height: auto; + max-height: 100%; } .container-fluid .discover{ margin-bottom: 50px; } From b2594468b41b3ce99f732543bd79ee13a4463258 Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Sat, 17 Oct 2020 16:49:06 +0200 Subject: [PATCH 3/5] add helper to get all read books --- cps/helper.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cps/helper.py b/cps/helper.py index 82d0b232..71dd2cc4 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -819,3 +819,18 @@ def get_download_link(book_id, book_format, client): return do_download_file(book, book_format, client, data1, headers) else: abort(404) + + +def get_readbooks_ids(): + if not config.config_read_column: + readBooks = ub.session.query(ub.ReadBook).filter(ub.ReadBook.user_id == int(current_user.id))\ + .filter(ub.ReadBook.is_read == True).all() + return frozenset([x.book_id for x in readBooks]) + else: + try: + readBooks = calibre_db.session.query(db.cc_classes[config.config_read_column])\ + .filter(db.cc_classes[config.config_read_column].value == True).all() + return frozenset([x.book for x in readBooks]) + except KeyError: + log.error("Custom Column No.%d is not existing in calibre database", config.config_read_column) + return [] \ No newline at end of file From 7d28963a32769f9749d2478241281422e3809bee Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Sat, 17 Oct 2020 16:49:38 +0200 Subject: [PATCH 4/5] connect read books to all render --- cps/web.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cps/web.py b/cps/web.py index aa1cac1a..a3eb37d5 100644 --- a/cps/web.py +++ b/cps/web.py @@ -59,7 +59,8 @@ from . import calibre_db from .gdriveutils import getFileFromEbooksFolder, do_gdrive_download from .helper import check_valid_domain, render_task_status, \ get_cc_columns, get_book_cover, get_download_link, send_mail, generate_random_password, \ - send_registration_mail, check_send_to_kindle, check_read_formats, tags_filters, reset_password + send_registration_mail, check_send_to_kindle, check_read_formats, tags_filters, reset_password, \ + get_readbooks_ids from .pagination import Pagination from .redirect import redirect_back @@ -602,7 +603,7 @@ def get_matching_tags(): def render_title_template(*args, **kwargs): sidebar = ub.get_sidebar_config(kwargs) return render_template(instance=config.config_calibre_web_title, sidebar=sidebar, - accept=constants.EXTENSIONS_UPLOAD, + accept=constants.EXTENSIONS_UPLOAD, read_book_ids=get_readbooks_ids(), *args, **kwargs) From 4d81d3613ca7baa9416c82193186efc4f31b8e99 Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Sat, 17 Oct 2020 16:49:57 +0200 Subject: [PATCH 5/5] display the check when books are read --- cps/templates/author.html | 5 ++++- cps/templates/discover.html | 5 ++++- cps/templates/index.html | 7 +++++-- cps/templates/search.html | 5 ++++- cps/templates/shelf.html | 5 ++++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/cps/templates/author.html b/cps/templates/author.html index 0015d6e2..fadc9a04 100644 --- a/cps/templates/author.html +++ b/cps/templates/author.html @@ -40,7 +40,10 @@
diff --git a/cps/templates/discover.html b/cps/templates/discover.html index 9abe3666..ed95bc03 100644 --- a/cps/templates/discover.html +++ b/cps/templates/discover.html @@ -8,7 +8,10 @@
{% if entry.has_cover is defined %} - {{ entry.title }} + + {{ entry.title }} + {% if entry.id in read_book_ids %}{% endif %} + {% endif %}
diff --git a/cps/templates/index.html b/cps/templates/index.html index 319fd60f..4f341e1e 100644 --- a/cps/templates/index.html +++ b/cps/templates/index.html @@ -8,7 +8,10 @@
diff --git a/cps/templates/search.html b/cps/templates/search.html index cba430a4..e619e856 100644 --- a/cps/templates/search.html +++ b/cps/templates/search.html @@ -41,7 +41,10 @@
{% if entry.has_cover is defined %} - {{ entry.title }} + + {{ entry.title }} + {% if entry.id in read_book_ids %}{% endif %} + {% endif %}
diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index a2655f96..db1c3bcf 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -18,7 +18,10 @@