From 14a6e7c42c6d27369467a05986a82f16d73290f8 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Fri, 25 Mar 2022 18:30:12 +0100 Subject: [PATCH] Deactivated several functions for kindle tolino and kobo. Opening books now working for ebook readers --- cps/admin.py | 2 +- cps/render_template.py | 19 ++++++++++--------- cps/templates/admin.html | 4 +++- cps/templates/book_exists_flash.html | 4 ++-- cps/templates/config_view_edit.html | 2 ++ cps/templates/discover.html | 4 ++-- cps/templates/email_edit.html | 2 +- cps/templates/index.html | 10 +++++----- cps/templates/layout.html | 2 +- cps/templates/search.html | 4 ++-- cps/templates/shelf.html | 4 ++-- cps/templates/user_edit.html | 4 ++-- 12 files changed, 33 insertions(+), 28 deletions(-) diff --git a/cps/admin.py b/cps/admin.py index 447e0227..1004ee78 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -1493,7 +1493,7 @@ def _handle_edit_user(to_save, content, languages, translations, kobo_support): content.role &= ~constants.ROLE_ANONYMOUS val = [int(k[5:]) for k in to_save if k.startswith('show_')] - sidebar = get_sidebar_config() + sidebar, __ = get_sidebar_config() for element in sidebar: value = element['visibility'] if value in val and not content.check_visibility(value): diff --git a/cps/render_template.py b/cps/render_template.py index 09a32497..91118049 100644 --- a/cps/render_template.py +++ b/cps/render_template.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from flask import render_template +from flask import render_template, request from flask_babel import gettext as _ from flask import g from werkzeug.local import LocalProxy @@ -30,6 +30,7 @@ log = logger.create() def get_sidebar_config(kwargs=None): kwargs = kwargs or [] + simple = bool([e for e in ['kindle', 'tolino', "kobo"] if (e in request.headers.get('User-Agent', "").lower())]) if 'content' in kwargs: content = kwargs['content'] content = isinstance(content, (User, LocalProxy)) and not content.role_anonymous() @@ -93,12 +94,12 @@ def get_sidebar_config(kwargs=None): {"glyph": "glyphicon-trash", "text": _('Archived Books'), "link": 'web.books_list', "id": "archived", "visibility": constants.SIDEBAR_ARCHIVED, 'public': (not g.user.is_anonymous), "page": "archived", "show_text": _('Show archived books'), "config_show": content}) - sidebar.append( - {"glyph": "glyphicon-th-list", "text": _('Books List'), "link": 'web.books_table', "id": "list", - "visibility": constants.SIDEBAR_LIST, 'public': (not g.user.is_anonymous), "page": "list", - "show_text": _('Show Books List'), "config_show": content}) - - return sidebar + if not simple: + sidebar.append( + {"glyph": "glyphicon-th-list", "text": _('Books List'), "link": 'web.books_table', "id": "list", + "visibility": constants.SIDEBAR_LIST, 'public': (not g.user.is_anonymous), "page": "list", + "show_text": _('Show Books List'), "config_show": content}) + return sidebar, simple def get_readbooks_ids(): if not config.config_read_column: @@ -116,7 +117,7 @@ def get_readbooks_ids(): # Returns the template for rendering and includes the instance name def render_title_template(*args, **kwargs): - sidebar = get_sidebar_config(kwargs) - return render_template(instance=config.config_calibre_web_title, sidebar=sidebar, + sidebar, simple = get_sidebar_config(kwargs) + return render_template(instance=config.config_calibre_web_title, sidebar=sidebar, simple=simple, accept=constants.EXTENSIONS_UPLOAD, read_book_ids=get_readbooks_ids(), *args, **kwargs) diff --git a/cps/templates/admin.html b/cps/templates/admin.html index 6cd7815e..c8c6eb82 100644 --- a/cps/templates/admin.html +++ b/cps/templates/admin.html @@ -47,7 +47,9 @@ {% endfor %} {% endif %} - {{_('Edit Users')}} + {% if not simple %} + {{_('Edit Users')}} + {% endif %} {{_('Add New User')}} {% if (config.config_login_type == 1) %}
{{_('Import LDAP Users')}}
diff --git a/cps/templates/book_exists_flash.html b/cps/templates/book_exists_flash.html index b0855120..b55192ce 100644 --- a/cps/templates/book_exists_flash.html +++ b/cps/templates/book_exists_flash.html @@ -1,3 +1,3 @@ - + {{entry.title|shortentitle}} - \ No newline at end of file + diff --git a/cps/templates/config_view_edit.html b/cps/templates/config_view_edit.html index 1dc02a5e..e4fea44d 100644 --- a/cps/templates/config_view_edit.html +++ b/cps/templates/config_view_edit.html @@ -162,8 +162,10 @@ + {% if not simple %} {{_('Add Allowed/Denied Tags')}} {{_('Add Allowed/Denied custom column values')}} + {% endif %} diff --git a/cps/templates/discover.html b/cps/templates/discover.html index 852d6210..900dad8c 100644 --- a/cps/templates/discover.html +++ b/cps/templates/discover.html @@ -7,7 +7,7 @@
- +

{{entry.title|shortentitle}}

diff --git a/cps/templates/email_edit.html b/cps/templates/email_edit.html index 9f23f78b..2a844209 100644 --- a/cps/templates/email_edit.html +++ b/cps/templates/email_edit.html @@ -69,7 +69,7 @@ {% endif %} {{_('Back')}} - {% if g.allow_registration %} + {% if g.allow_registration and not simple%}

{{_('Allowed Domains (Whitelist)')}}

diff --git a/cps/templates/index.html b/cps/templates/index.html index 28807343..a4547705 100644 --- a/cps/templates/index.html +++ b/cps/templates/index.html @@ -7,7 +7,7 @@ {% for entry in random %}
- +

{{entry.title|shortentitle}}

@@ -24,7 +24,7 @@ {% if not loop.first %} & {% endif %} - {{author.name.replace('|',',')|shortentitle(30)}} + {{author.name.replace('|',',')|shortentitle(30)}} {% if loop.last %} (...) {% endif %} @@ -89,7 +89,7 @@ {% for entry in entries %}

- +

{{entry.title|shortentitle}}

diff --git a/cps/templates/layout.html b/cps/templates/layout.html index 0d0df778..46f03da1 100644 --- a/cps/templates/layout.html +++ b/cps/templates/layout.html @@ -69,7 +69,7 @@

{% endif %} - {% if not g.user.is_anonymous %} + {% if not g.user.is_anonymous and not simple%}
  • {% endif %} {% if g.user.role_admin() %} diff --git a/cps/templates/search.html b/cps/templates/search.html index 4f8d607b..77c01c80 100644 --- a/cps/templates/search.html +++ b/cps/templates/search.html @@ -43,7 +43,7 @@
    - +

    {{entry.Books.title|shortentitle}}

    diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index e5cb2ffb..a7b5bcf0 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -32,7 +32,7 @@ {% for entry in entries %}

    - +

    {{entry.title|shortentitle}}

    diff --git a/cps/templates/user_edit.html b/cps/templates/user_edit.html index de7a4fb3..b489cbaf 100644 --- a/cps/templates/user_edit.html +++ b/cps/templates/user_edit.html @@ -83,7 +83,7 @@

    - {% if ( g.user and g.user.role_admin() and not new_user ) %} + {% if ( g.user and g.user.role_admin() and not new_user ) and not simple %} {{_('Add Allowed/Denied Tags')}} {{_('Add allowed/Denied Custom Column Values')}} {% endif %} @@ -131,7 +131,7 @@
    {% endif %} {% endif %} - {% if kobo_support and not content.role_anonymous() %} + {% if kobo_support and not content.role_anonymous() and not simple%}