From 54cf3652b0383c612dd374a4682f78efbeb2afd8 Mon Sep 17 00:00:00 2001 From: Michael Knepher Date: Wed, 27 May 2020 21:57:59 -0700 Subject: [PATCH 1/5] Add series name and index to book cover info --- cps/static/css/style.css | 6 ++++++ cps/templates/discover.html | 10 +++++++++- cps/templates/index.html | 16 ++++++++++++++++ cps/templates/search.html | 9 +++++++++ cps/templates/shelf.html | 8 ++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/cps/static/css/style.css b/cps/static/css/style.css index c043f459..5b22c835 100644 --- a/cps/static/css/style.css +++ b/cps/static/css/style.css @@ -127,6 +127,12 @@ a { color: #45b29d; } color: #444; } +.container-fluid .book .meta .series { + font-weight: 400; + font-size: 12px; + color: #444; +} + .container-fluid .book .meta .author { font-size: 12px; color: #999; diff --git a/cps/templates/discover.html b/cps/templates/discover.html index 650bdeda..dd8dc9bb 100644 --- a/cps/templates/discover.html +++ b/cps/templates/discover.html @@ -21,7 +21,7 @@ {% if loop.index > g.config_authors_max and g.config_authors_max != 0 %} {% if not loop.first %} & - {% endif %} + {% endif %} {{author.name.replace('|',',')|shortentitle(30)}} {% if loop.last %} (...) @@ -34,6 +34,14 @@ {% endif %} {% endfor %}

+ {% if entry.series.__len__() > 0 %} +

+ + {{entry.series[0].name}} + + ({{entry.series_index}}) +

+ {% endif %} {% if entry.ratings.__len__() > 0 %}
{% for number in range((entry.ratings[0].rating/2)|int(2)) %} diff --git a/cps/templates/index.html b/cps/templates/index.html index b65beccb..16f2b461 100644 --- a/cps/templates/index.html +++ b/cps/templates/index.html @@ -33,6 +33,14 @@ {% endif %} {% endfor %}

+ {% if entry.series.__len__() > 0 %} +

+ + {{entry.series[0].name}} + + ({{entry.series_index}}) +

+ {% endif %} {% if entry.ratings.__len__() > 0 %}
{% for number in range((entry.ratings[0].rating/2)|int(2)) %} @@ -101,6 +109,14 @@ {% endif %} {%endfor%}

+ {% if entry.series.__len__() > 0 %} +

+ + {{entry.series[0].name}} + + ({{entry.series_index}}) +

+ {% endif %} {% if entry.ratings.__len__() > 0 %}
{% for number in range((entry.ratings[0].rating/2)|int(2)) %} diff --git a/cps/templates/search.html b/cps/templates/search.html index fa8176e9..7e546c8e 100644 --- a/cps/templates/search.html +++ b/cps/templates/search.html @@ -76,6 +76,15 @@ {% endif %} {% endfor %}

+ {% if entry.series.__len__() > 0 %} +

+ + {{entry.series[0].name}} + + ({{entry.series_index}}) +

+ {% endif %} + {% if entry.ratings.__len__() > 0 %}
{% for number in range((entry.ratings[0].rating/2)|int(2)) %} diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index f37661ce..cf44cccf 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -43,6 +43,14 @@ {% endif %} {% endfor %}

+ {% if entry.series.__len__() > 0 %} +

+ + {{entry.series[0].name}} + + ({{entry.series_index|int}}) +

+ {% endif %} {% if entry.ratings.__len__() > 0 %}
{% for number in range((entry.ratings[0].rating/2)|int(2)) %} From 67dd4a72b09306fa410425904797c7be98afdac8 Mon Sep 17 00:00:00 2001 From: Michael Knepher Date: Fri, 26 Jun 2020 12:26:36 -0700 Subject: [PATCH 2/5] Add series info to all book "meta" displays --- cps/templates/author.html | 16 ++++++++++++++++ cps/templates/index.html | 2 +- cps/templates/shelfdown.html | 9 ++++++++- cps/web.py | 3 ++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/cps/templates/author.html b/cps/templates/author.html index 0d4369a3..cce173b0 100644 --- a/cps/templates/author.html +++ b/cps/templates/author.html @@ -70,6 +70,14 @@ {% endif %} {% endfor %}

+ {% if entry.series.__len__() > 0 %} +

+ + {{entry.series[0].name}} + + ({{entry.series_index}}) +

+ {% endif %} {% if entry.ratings.__len__() > 0 %}
{% for number in range((entry.ratings[0].rating/2)|int(2)) %} @@ -114,6 +122,14 @@ {% endif %} {% endfor %}

+ {% if entry.series.__len__() > 0 %} +

+ + {{entry.series[0].name}} + + ({{entry.series_index}}) +

+ {% endif %}
{% for number in range((entry.average_rating)|float|round|int(2)) %} diff --git a/cps/templates/index.html b/cps/templates/index.html index 16f2b461..f39a7181 100644 --- a/cps/templates/index.html +++ b/cps/templates/index.html @@ -20,7 +20,7 @@ {% if loop.index > g.config_authors_max and g.config_authors_max != 0 %} {% if not loop.first %} & - {% endif %} + {% endif %} {{author.name.replace('|',',')|shortentitle(30)}} {% if loop.last %} (...) diff --git a/cps/templates/shelfdown.html b/cps/templates/shelfdown.html index b2ac947f..0491bbec 100644 --- a/cps/templates/shelfdown.html +++ b/cps/templates/shelfdown.html @@ -43,7 +43,14 @@ {% endif %} {% endfor %}

- + {% if entry.series.__len__() > 0 %} +

+ + {{entry.series[0].name}} + + ({{entry.series_index}}) +

+ {% endif %}
diff --git a/cps/web.py b/cps/web.py index 3c31dee1..3e6d7c63 100644 --- a/cps/web.py +++ b/cps/web.py @@ -841,8 +841,9 @@ def books_table(): @login_required_if_no_ano def author_list(): if current_user.check_visibility(constants.SIDEBAR_AUTHOR): - entries = calibre_db.session.query(db.Authors, func.count('books_authors_link.book').label('count')) \ + entries = calibre_db.session.query(db.Authors, func.count('books_authors_link.book').label('count'), db.Series) \ .join(db.books_authors_link).join(db.Books).filter(calibre_db.common_filters()) \ + .join(db.books_series_link).join(db.Series).filter(calibre_db.common_filters()) \ .group_by(text('books_authors_link.author')).order_by(db.Authors.sort).all() charlist = calibre_db.session.query(func.upper(func.substr(db.Authors.sort, 1, 1)).label('char')) \ .join(db.books_authors_link).join(db.Books).filter(calibre_db.common_filters()) \ From 7e0d9fbace922e60c34d89aea16d6bc061b52c81 Mon Sep 17 00:00:00 2001 From: Michael Knepher Date: Mon, 29 Jun 2020 23:34:26 -0700 Subject: [PATCH 3/5] series_index filter to show x.0 as x --- cps/jinjia.py | 7 +++++++ cps/templates/author.html | 4 ++-- cps/templates/detail.html | 2 +- cps/templates/discover.html | 2 +- cps/templates/index.html | 4 ++-- cps/templates/search.html | 2 +- cps/templates/shelf.html | 2 +- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cps/jinjia.py b/cps/jinjia.py index 28c2621a..b01ad69f 100644 --- a/cps/jinjia.py +++ b/cps/jinjia.py @@ -111,3 +111,10 @@ def timestamptodate(date, fmt=None): @jinjia.app_template_filter('yesno') def yesno(value, yes, no): return yes if value else no + +@jinjia.app_template_filter('formatseriesindex') +def formatseriesindex_filter(series_index): + if int(series_index) - series_index == 0: + return int(series_index) + else: + return series_index \ No newline at end of file diff --git a/cps/templates/author.html b/cps/templates/author.html index cce173b0..5148dfef 100644 --- a/cps/templates/author.html +++ b/cps/templates/author.html @@ -75,7 +75,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} {% if entry.ratings.__len__() > 0 %} @@ -127,7 +127,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %}
diff --git a/cps/templates/detail.html b/cps/templates/detail.html index 24ba10c7..d348b7f6 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -114,7 +114,7 @@ {% endif %} {% if entry.series|length > 0 %} -

{{_('Book')}} {{entry.series_index}} {{_('of')}} {{entry.series[0].name}}

+

{{_('Book')}} {{entry.series_index|formatseriesindex}} {{_('of')}} {{entry.series[0].name}}

{% endif %} {% if entry.languages.__len__() > 0 %} diff --git a/cps/templates/discover.html b/cps/templates/discover.html index dd8dc9bb..dac0afb7 100644 --- a/cps/templates/discover.html +++ b/cps/templates/discover.html @@ -39,7 +39,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} {% if entry.ratings.__len__() > 0 %} diff --git a/cps/templates/index.html b/cps/templates/index.html index f39a7181..1fed6be2 100644 --- a/cps/templates/index.html +++ b/cps/templates/index.html @@ -38,7 +38,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} {% if entry.ratings.__len__() > 0 %} @@ -114,7 +114,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} {% if entry.ratings.__len__() > 0 %} diff --git a/cps/templates/search.html b/cps/templates/search.html index 7e546c8e..213bed84 100644 --- a/cps/templates/search.html +++ b/cps/templates/search.html @@ -81,7 +81,7 @@ {{entry.series[0].name}} - ({{entry.series_index}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index cf44cccf..6551bef6 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -48,7 +48,7 @@ {{entry.series[0].name}} - ({{entry.series_index|int}}) + ({{entry.series_index|formatseriesindex}})

{% endif %} {% if entry.ratings.__len__() > 0 %} From 057f70ea9cbe3cfd8888b9f854c67f6d5fc6e871 Mon Sep 17 00:00:00 2001 From: Michael Knepher Date: Sat, 29 Aug 2020 18:53:00 -0700 Subject: [PATCH 4/5] Add author sort --- cps/web.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cps/web.py b/cps/web.py index 3e6d7c63..a4b767a0 100644 --- a/cps/web.py +++ b/cps/web.py @@ -644,6 +644,10 @@ def books_list(data, sort, book_id, page): order = [db.Books.timestamp.desc()] if sort == 'old': order = [db.Books.timestamp] + if sort == 'authaz': + order = [db.Books.author_sort.asc()] + if sort == 'authza': + order = [db.Books.author_sort.desc()] if data == "rated": if current_user.check_visibility(constants.SIDEBAR_BEST_RATED): From e16c0caebb93244d3ad1d2482553cc84d762c089 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sat, 10 Oct 2020 12:53:10 +0200 Subject: [PATCH 5/5] Fix opds search --- cps/db.py | 4 +--- cps/opds.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cps/db.py b/cps/db.py index b2ab257a..c4f95b3c 100644 --- a/cps/db.py +++ b/cps/db.py @@ -687,9 +687,7 @@ class CalibreDB(): limit_all = result_count ub.store_ids(result) - - - return result[offset:limit_all], result_count, pagination, + return result[offset:limit_all], result_count, pagination # Creates for all stored languages a translated speaking name in the array for the UI def speaking_language(self, languages=None): diff --git a/cps/opds.py b/cps/opds.py index ac0e103b..1eb3c49f 100644 --- a/cps/opds.py +++ b/cps/opds.py @@ -408,7 +408,7 @@ def get_metadata_calibre_companion(uuid, library): def feed_search(term): if term: - entries, __ = calibre_db.get_search_results(term) + entries, __, ___ = calibre_db.get_search_results(term) entriescount = len(entries) if len(entries) > 0 else 1 pagination = Pagination(1, entriescount, entriescount) return render_xml_template('feed.xml', searchterm=term, entries=entries, pagination=pagination)