diff --git a/cps/admin.py b/cps/admin.py index 20e901e3..a54c21cb 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -563,6 +563,7 @@ def update_view_configuration(): to_save = request.form.to_dict() _config_string(to_save, "config_calibre_web_title") + _config_checkbox(to_save, "config_use_logo") _config_string(to_save, "config_columns_to_ignore") if _config_string(to_save, "config_title_regex"): calibre_db.update_title_sort(config) diff --git a/cps/config_sql.py b/cps/config_sql.py index 21644ccd..a5dfbdef 100644 --- a/cps/config_sql.py +++ b/cps/config_sql.py @@ -74,6 +74,7 @@ class _Settings(_Base): config_certfile = Column(String) config_keyfile = Column(String) config_trustedhosts = Column(String, default='') + config_use_logo = Column(Boolean, default=False) config_calibre_web_title = Column(String, default='Calibre-Web') config_books_per_page = Column(Integer, default=60) config_random_books = Column(Integer, default=4) diff --git a/cps/render_template.py b/cps/render_template.py index 68b46459..1e9f81fa 100644 --- a/cps/render_template.py +++ b/cps/render_template.py @@ -21,6 +21,7 @@ from flask_babel import gettext as _ from werkzeug.local import LocalProxy from flask_login import current_user from sqlalchemy.sql.expression import or_ +from pathlib import Path from . import config, constants, logger, ub from .ub import User @@ -106,12 +107,18 @@ def get_sidebar_config(kwargs=None): return sidebar, simple +def logo_file(): + dir_static_path = Path(constants.STATIC_DIR) + file_name = Path('logo.png') + file_path = dir_static_path / file_name + return file_path.is_file() # Returns the template for rendering and includes the instance name def render_title_template(*args, **kwargs): sidebar, simple = get_sidebar_config(kwargs) try: return render_template(instance=config.config_calibre_web_title, sidebar=sidebar, simple=simple, + use_logo=config.config_use_logo and logo_file(), accept=constants.EXTENSIONS_UPLOAD, *args, **kwargs) except PermissionError: diff --git a/cps/templates/config_view_edit.html b/cps/templates/config_view_edit.html index e4fea44d..0fd2cd12 100644 --- a/cps/templates/config_view_edit.html +++ b/cps/templates/config_view_edit.html @@ -20,7 +20,11 @@
-
+
+ + +
+
diff --git a/cps/templates/layout.html b/cps/templates/layout.html index 1bee1c1d..f742c3dd 100644 --- a/cps/templates/layout.html +++ b/cps/templates/layout.html @@ -34,7 +34,13 @@ - {{instance}} + + {% if use_logo %} + {{instance}} + {% else %} + {{instance}} + {% endif %} +
{% if g.current_theme == 1 %}