Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use image as logo. - Sponsor: Fundación Karisma #3000

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cps/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions cps/config_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions cps/render_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion cps/templates/config_view_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ <h4 class="panel-title">
</div>
<div id="collapsefour" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group">
<div class="form-group">
<input type="checkbox" id="config_use_logo" name="config_use_logo" {% if conf.config_use_logo %}checked{% endif %}>
<label for="config_use_logo">{{_('Use Logo')}}</label>
</div>
<div class="form-group">
<label for="config_calibre_web_title">{{_('Title')}}</label>
<input type="text" class="form-control" name="config_calibre_web_title" id="config_calibre_web_title" value="{% if conf.config_calibre_web_title != None %}{{ conf.config_calibre_web_title }}{% endif %}" autocomplete="off" required>
</div>
Expand Down
8 changes: 7 additions & 1 deletion cps/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{url_for('web.index')}}">{{instance}}</a>
<a class="navbar-brand" href="{{url_for('web.index')}}" style="display:flex;">
{% if use_logo %}
<img src="{{ url_for('static', filename='logo.png') }}" alt="{{instance}}"/>
{% else %}
{{instance}}
{% endif %}
</a>
</div>
{% if g.current_theme == 1 %}
<div class="home-btn"><a class="home-btn-tooltip" href="{{url_for("web.index",page=1)}}" data-toggle="tooltip" title="" data-placement="bottom" data-original-title="Home"></a></div>
Expand Down