Choosing Theme is now a global setting

pull/772/head
Ozzieisaacs 5 years ago
parent d5a913e195
commit 36030b559c

@ -144,7 +144,7 @@
<div class="modal-body text-center">
<p>{{_('Do you really want to restart Calibre-Web?')}}</p>
<div id="spinner" class="spinner" style="display:none;">
<img id="img-spinner" src="/static/css/images/loading-icon.gif"/>
<img id="img-spinner" src="{{ url_for('static', filename='css/images/loading-icon.gif') }}"/>
</div>
<p></p>
<button type="button" class="btn btn-default" id="restart" >{{_('Ok')}}</button>
@ -176,7 +176,7 @@
</div>
<div class="modal-body text-center">
<div id="spinner2" class="spinner2" style="display:none;">
<img id="img-spinner" src="/static/css/images/loading-icon.gif"/>
<img id="img-spinner" src="{{ url_for('static', filename='css/images/loading-icon.gif') }}"/>
</div>
<p></p>
<div id="Updatecontent"></div>

@ -27,6 +27,13 @@
<label for="config_random_books">{{_('No. of random books to show')}}</label>
<input type="number" min="1" max="30" class="form-control" name="config_random_books" id="config_random_books" value="{% if content.config_random_books != None %}{{ content.config_random_books }}{% endif %}" autocomplete="off">
</div>
<div class="form-group">
<label for="config_theme">{{_('Theme')}}</label>
<select name="config_theme" id="config_theme" class="form-control">
<option value="0" {% if content.config_theme == 0 %}selected{% endif %}>{{ _("Standard Theme") }}</option>
<option value="1" {% if content.config_theme == 1 %}selected{% endif %}>{{ _("caliBlur! Dark Theme (Beta)") }}</option>
</select>
</div>
<div class="form-group">
<label for="config_columns_to_ignore">{{_('Regular expression for ignoring columns')}}</label>
<input type="text" class="form-control" name="config_columns_to_ignore" id="config_columns_to_ignore" value="{% if content.config_columns_to_ignore != None %}{{ content.config_columns_to_ignore }}{% endif %}" autocomplete="off">

@ -12,7 +12,7 @@
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link href="{{ url_for('static', filename='css/libs/bootstrap.min.css') }}" rel="stylesheet" media="screen">
<link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet" media="screen">
{% if g.user.get_theme == 1 %}
{% if g.current_theme == 1 %}
<link href="{{ url_for('static', filename='css/caliBlur.min.css') }}" rel="stylesheet" media="screen">
{% endif %}
</head>

@ -47,7 +47,7 @@
</div>
{% endif %}
<div class="discover load-more">
<h2>{{title}}</h2>
<h2 class="{{title}}">{{_(title)}}</h2>
<div class="row">
{% if entries[0] %}
{% for entry in entries %}

@ -12,7 +12,7 @@
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link href="{{ url_for('static', filename='css/libs/bootstrap.min.css') }}" rel="stylesheet" media="screen">
<link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet" media="screen">
{% if g.user.get_theme == 1 %}
{% if g.current_theme == 1 %}
<link href="{{ url_for('static', filename='css/caliBlur.min.css') }}" rel="stylesheet" media="screen">
{% endif %}
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
@ -240,7 +240,7 @@
<script src="{{ url_for('static', filename='js/libs/plugins.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/jquery.form.js') }}"></script>
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
{% if g.user.get_theme == 1 %}
{% if g.current_theme == 1 %}
<script src="{{ url_for('static', filename='js/libs/jquery.visible.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/compromise.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/readmore.min.js') }}"></script>

@ -1,6 +1,6 @@
{% extends "layout.html" %}
{% block body %}
<h1>{{title}}</h1>
<h1 class="{{page}}">{{_(title)}}</h1>
<div class="container">
<div class="col-xs-12 col-sm-6">
{% for entry in entries %}

@ -35,14 +35,6 @@
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="theme">{{_('Theme')}}</label>
<select name="theme" id="theme" class="form-control">
<option value="0" {% if content.get_theme == 0 %}selected{% endif %}>{{ _("Standard Theme") }}</option>
<option value="1" {% if content.get_theme == 1 %}selected{% endif %}>{{ _("caliBlur! Dark Theme (Beta)") }}</option>
</select>
</div>
<div class="form-group">
<label for="default_language">{{_('Show books with language')}}</label>
<select name="default_language" id="default_language" class="form-control">

@ -103,10 +103,6 @@ class UserBase:
def is_anonymous(self):
return False
@property
def get_theme(self):
return self.theme
def get_id(self):
return str(self.id)
@ -170,7 +166,7 @@ class User(UserBase, Base):
sidebar_view = Column(Integer, default=1)
default_language = Column(String(3), default="all")
mature_content = Column(Boolean, default=True)
theme = Column(Integer, default=0)
# theme = Column(Integer, default=0)
# Class for anonymous user is derived from User base and completly overrides methods and properties for the
@ -316,6 +312,7 @@ class Settings(Base):
config_converterpath = Column(String)
config_calibre = Column(String)
config_rarfile_location = Column(String)
config_theme = Column(Integer, default=0)
def __repr__(self):
pass
@ -389,6 +386,7 @@ class Config:
if data.config_logfile:
self.config_logfile = data.config_logfile
self.config_rarfile_location = data.config_rarfile_location
self.config_theme = data.config_theme
@property
def get_main_dir(self):
@ -610,12 +608,7 @@ def migrate_Database():
except exc.OperationalError:
conn = engine.connect()
conn.execute("ALTER TABLE user ADD column `mature_content` INTEGER DEFAULT 1")
try:
session.query(exists().where(User.theme)).scalar()
except exc.OperationalError:
conn = engine.connect()
conn.execute("ALTER TABLE user ADD column `theme` INTEGER DEFAULT 0")
session.commit()
if session.query(User).filter(User.role.op('&')(ROLE_ANONYMOUS) == ROLE_ANONYMOUS).first() is None:
create_anonymous_user()
try:
@ -668,6 +661,13 @@ def migrate_Database():
conn.execute("ALTER TABLE Settings ADD column `config_converterpath` String DEFAULT ''")
conn.execute("ALTER TABLE Settings ADD column `config_calibre` String DEFAULT ''")
session.commit()
try:
session.query(exists().where(Settings.config_theme)).scalar()
except exc.OperationalError: # Database is not compatible, some rows are missing
conn = engine.connect()
conn.execute("ALTER TABLE Settings ADD column `config_theme` INTEGER DEFAULT 0")
session.commit()
# Remove login capability of user Guest
conn = engine.connect()

@ -681,6 +681,7 @@ def before_request():
g.user = current_user
g.allow_registration = config.config_public_reg
g.allow_upload = config.config_uploading
g.current_theme = config.config_theme
g.public_shelfes = ub.session.query(ub.Shelf).filter(ub.Shelf.is_public == 1).order_by(ub.Shelf.name).all()
if not config.db_configured and request.endpoint not in ('basic_configuration', 'login') and '/static/' not in request.path:
return redirect(url_for('basic_configuration'))
@ -1418,7 +1419,7 @@ def author_list():
for entry in entries:
entry.Authors.name = entry.Authors.name.replace('|', ',')
return render_title_template('list.html', entries=entries, folder='author',
title=_(u"Author list"), page="authorlist")
title=u"Author list", page="authorlist")
else:
abort(404)
@ -2842,7 +2843,6 @@ def profile():
content.sidebar_view += ub.DETAIL_RANDOM
content.mature_content = "show_mature_content" in to_save
content.theme = int(to_save["theme"])
try:
ub.session.commit()
@ -2903,6 +2903,8 @@ def view_configuration():
content.config_columns_to_ignore = to_save["config_columns_to_ignore"]
if "config_read_column" in to_save:
content.config_read_column = int(to_save["config_read_column"])
if "config_theme" in to_save:
content.config_theme = int(to_save["config_theme"])
if "config_title_regex" in to_save:
if content.config_title_regex != to_save["config_title_regex"]:
content.config_title_regex = to_save["config_title_regex"]
@ -2961,6 +2963,7 @@ def view_configuration():
ub.session.commit()
flash(_(u"Calibre-Web configuration updated"), category="success")
config.loadSettings()
before_request()
if reboot_required:
# db.engine.dispose() # ToDo verify correct
# ub.session.close()
@ -3180,7 +3183,6 @@ def new_user():
to_save = request.form.to_dict()
content.default_language = to_save["default_language"]
content.mature_content = "show_mature_content" in to_save
content.theme = int(to_save["theme"])
if "locale" in to_save:
content.locale = to_save["locale"]
content.sidebar_view = 0
@ -3403,7 +3405,6 @@ def edit_user(user_id):
content.sidebar_view -= ub.DETAIL_RANDOM
content.mature_content = "show_mature_content" in to_save
content.theme = int(to_save["theme"])
if "default_language" in to_save:
content.default_language = to_save["default_language"]

Loading…
Cancel
Save