mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-26 01:50:31 +00:00
Start refactor sidebar and view settings sidebar
This commit is contained in:
parent
fb23db57b4
commit
f0de822ce7
@ -702,6 +702,9 @@ def edit_user(user_id):
|
||||
elif "edit_shelf_role" not in to_save and content.role_edit_shelfs():
|
||||
content.role = content.role - ub.ROLE_EDIT_SHELFS
|
||||
|
||||
# next(v for k, v in my_dict.items() if k.startswith('show'))
|
||||
val=[{k[5:]:v} for k, v in to_save.items() if k.startswith('show')]
|
||||
# ['15th july']
|
||||
if "show_random" in to_save and not content.show_random_books():
|
||||
content.sidebar_view += ub.SIDEBAR_RANDOM
|
||||
elif "show_random" not in to_save and content.show_random_books():
|
||||
|
@ -114,7 +114,15 @@
|
||||
</div>
|
||||
<div id="collapseseven" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
|
||||
{% for element in sidebar %}
|
||||
<div class="form-group">
|
||||
<input type="checkbox" name="show_{{element['visibility']}}" id="show_{{element['visibility']}}" {% if content.show_element(element['visibility']) %}checked{% endif %}>
|
||||
<label for="show_{{element['visibility']}}">{{element['show_text']}}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<!--div class="form-group">
|
||||
<input type="checkbox" name="show_random" id="show_random" {% if content.show_random_books() %}checked{% endif %}>
|
||||
<label for="show_random">{{_('Show random books')}}</label>
|
||||
</div>
|
||||
@ -157,7 +165,7 @@
|
||||
<div class="form-group">
|
||||
<input type="checkbox" name="show_read_and_unread" id="show_read_and_unread" {% if content.show_read_and_unread() %}checked{% endif %}>
|
||||
<label for="show_read_and_unread">{{_('Show read and unread')}}</label>
|
||||
</div>
|
||||
</div-->
|
||||
<div class="form-group">
|
||||
<input type="checkbox" name="show_detail_random" id="show_detail_random" {% if content.show_detail_random() %}checked{% endif %}>
|
||||
<label for="show_detail_random">{{_('Show random books in detail view')}}</label>
|
||||
|
@ -119,11 +119,8 @@
|
||||
<nav class="navigation">
|
||||
<ul class="list-unstyled" id="scnd-nav" intent in-standard-append="nav.navigation" in-mobile-after="#main-nav" in-mobile-class="nav navbar-nav">
|
||||
<li class="nav-head hidden-xs">{{_('Browse')}}</li>
|
||||
{% if g.user.show_recent() %}
|
||||
<li id="nav_new" {% if page == 'root' %}class="active"{% endif %}><a href="{{url_for('web.index')}}"><span class="glyphicon glyphicon-book"></span> {{_('Recently Added')}}</a></li>
|
||||
{%endif%}
|
||||
{% if g.user.show_sorted() %}
|
||||
<li id="nav_sort" class="dropdown">
|
||||
<!--li id="nav_sort" class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="glyphicon glyphicon-sort-by-attributes"></span>{{_('Sorted Books')}}
|
||||
<span class="caret"></span>
|
||||
@ -134,38 +131,14 @@
|
||||
<li id="nav_sort_asc" {% if page == 'a-z' %}class="active"{% endif %}><a href="{{url_for('web.titles_ascending')}}">{{_('Sort By')}} {{_('Title')}} ({{_('Ascending')}})</a></li>
|
||||
<li id="nav_sort_desc" {% if page == 'z-a' %}class="active"{% endif %}><a href="{{url_for('web.titles_descending')}}">{{_('Sort By')}} {{_('Title')}} ({{_('Descending')}})</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</li-->
|
||||
{%endif%}
|
||||
{% if g.user.show_hot_books() %}
|
||||
<li id="nav_hot" {% if page == 'hot' %}class="active"{% endif %}><a href="{{url_for('web.hot_books')}}"><span class="glyphicon glyphicon-fire"></span>{{_('Hot Books')}}</a></li>
|
||||
{%endif%}
|
||||
{% if g.user.show_best_rated_books() %}
|
||||
<li id="nav_rated" {% if page == 'rated' %}class="active"{% endif %}><a href="{{url_for('web.best_rated_books')}}"><span class="glyphicon glyphicon-star"></span>{{_('Best rated Books')}}</a></li>
|
||||
{%endif%}
|
||||
{% if g.user.show_read_and_unread() %}
|
||||
{% if not g.user.is_anonymous %}
|
||||
<li id="nav_read" {% if page == 'read' %}class="active"{% endif %}><a href="{{url_for('web.read_books')}}"><span class="glyphicon glyphicon-eye-open"></span>{{_('Read Books')}}</a></li>
|
||||
{%endif%}
|
||||
<li id="nav_unread" {% if page == 'read' %}class="active"{% endif %}><a href="{{url_for('web.unread_books')}}"><span class="glyphicon glyphicon-eye-close"></span>{{_('Unread Books')}}</a></li>
|
||||
{%endif%}
|
||||
{% if g.user.show_random_books() %}
|
||||
<li id="nav_rand" {% if page == 'discover' %}class="active"{% endif %}><a href="{{url_for('web.discover')}}"><span class="glyphicon glyphicon-random"></span>{{_('Discover')}}</a></li>
|
||||
{%endif%}
|
||||
{% if g.user.show_category() %}
|
||||
<li id="nav_cat" {% if page == 'discover' %}class="category"{% endif %}><a href="{{url_for('web.category_list')}}"><span class="glyphicon glyphicon-inbox"></span>{{_('Categories')}}</a></li>
|
||||
{%endif%}
|
||||
{% if g.user.show_series() %}
|
||||
<li id="nav_serie" {% if page == 'series' %}class="active"{% endif %}><a href="{{url_for('web.series_list')}}"><span class="glyphicon glyphicon-bookmark"></span>{{_('Series')}}</a></li>
|
||||
{%endif%}
|
||||
{% if g.user.show_author() %}
|
||||
<li id="nav_author" {% if page == 'author' %}class="active"{% endif %}><a href="{{url_for('web.author_list')}}"><span class="glyphicon glyphicon-user"></span>{{_('Authors')}}</a></li>
|
||||
{%endif%}
|
||||
{% if g.user.show_publisher() %}
|
||||
<li id="nav_publisher" {% if page == 'publisher' %}class="active"{% endif %}><a href="{{url_for('web.publisher_list')}}"><span class="glyphicon glyphicon-text-size"></span>{{_('Publishers')}}</a></li>
|
||||
{%endif%}
|
||||
{% if g.user.filter_language() == 'all' and g.user.show_language() %}
|
||||
<li id="nav_lang" {% if page == 'language' %}class="active"{% endif %}><a href="{{url_for('web.language_overview')}}"><span class="glyphicon glyphicon-flag"></span>{{_('Languages')}} </a></li>
|
||||
{% for element in sidebar %}
|
||||
{% if g.user.check_visibility(element['visibility']) and element['public'] %}
|
||||
<li id="nav_{{element['id']}}" {% if page == element['page'] %}class="active"{% endif %}><a href="{{element['link']}}"><span class="glyphicon {{element['glyph']}}"></span>{{_(element['text'])}}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if g.user.is_authenticated or g.user.is_anonymous %}
|
||||
<li class="nav-head hidden-xs public-shelves">{{_('Public Shelves')}}</li>
|
||||
{% for shelf in g.public_shelfes %}
|
||||
|
@ -60,7 +60,16 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col-sm-6">
|
||||
{% for element in sidebar %}
|
||||
{% if element['public'] %}
|
||||
<div class="form-group">
|
||||
<input type="checkbox" name="show_{{element['visibility']}}" id="show_{{element['visibility']}}" {% if content.check_visibility(element['visibility']) %}checked{% endif %}>
|
||||
<label for="show_{{element['visibility']}}">{{element['show_text']}}</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<!--div class="form-group">
|
||||
<input type="checkbox" name="show_random" id="show_random" {% if content.show_random_books() %}checked{% endif %}>
|
||||
<label for="show_random">{{_('Show random books')}}</label>
|
||||
</div>
|
||||
@ -99,7 +108,7 @@
|
||||
<div class="form-group">
|
||||
<input type="checkbox" name="show_publisher" id="show_publisher" {% if content.show_publisher() %}checked{% endif %}>
|
||||
<label for="show_publisher">{{_('Show publisher selection')}}</label>
|
||||
</div>
|
||||
</div-->
|
||||
{% if not content.role_anonymous() %}
|
||||
<div class="form-group">
|
||||
<input type="checkbox" name="show_read_and_unread" id="show_read_and_unread" {% if content.show_read_and_unread() %}checked{% endif %}>
|
||||
|
@ -156,6 +156,9 @@ class UserBase:
|
||||
def filter_language(self):
|
||||
return self.default_language
|
||||
|
||||
def check_visibility(self, value):
|
||||
return bool((self.sidebar_view is not None) and (self.sidebar_view & value == value))
|
||||
|
||||
def show_random_books(self):
|
||||
return bool((self.sidebar_view is not None)and(self.sidebar_view & SIDEBAR_RANDOM == SIDEBAR_RANDOM))
|
||||
|
||||
@ -548,6 +551,10 @@ class Config:
|
||||
return bool((self.config_default_show is not None) and
|
||||
(self.config_default_show & DETAIL_RANDOM == DETAIL_RANDOM))
|
||||
|
||||
def show_element(self, value):
|
||||
return bool((self.config_default_show is not None) and
|
||||
(self.config_default_show & value == value))
|
||||
|
||||
def show_language(self):
|
||||
return bool((self.config_default_show is not None) and
|
||||
(self.config_default_show & SIDEBAR_LANGUAGE == SIDEBAR_LANGUAGE))
|
||||
|
22
cps/web.py
22
cps/web.py
@ -22,7 +22,8 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from cps import mimetypes, global_WorkerThread, searched_ids
|
||||
from flask import render_template, request, redirect, url_for, send_from_directory, make_response, g, flash, abort
|
||||
from flask import render_template, request, redirect, send_from_directory, make_response, g, flash, abort, \
|
||||
url_for
|
||||
from werkzeug.exceptions import default_exceptions
|
||||
import helper
|
||||
import os
|
||||
@ -109,6 +110,8 @@ EXTENSIONS_AUDIO = {'mp3', 'm4a', 'm4b'}
|
||||
(['rar','cbr'] if feature_support['rar'] else []))'''
|
||||
|
||||
|
||||
# with app.app_context():
|
||||
|
||||
# custom error page
|
||||
def error_http(error):
|
||||
return render_template('http_error.html',
|
||||
@ -321,7 +324,19 @@ def get_search_results(term):
|
||||
|
||||
# Returns the template for rendering and includes the instance name
|
||||
def render_title_template(*args, **kwargs):
|
||||
return render_template(instance=config.config_calibre_web_title, *args, **kwargs)
|
||||
sidebar=list()
|
||||
sidebar.append({"glyph":"glyphicon-book","text":_('Recently Added'),"link":url_for('web.index'),"id":"new", "visibility":ub.SIDEBAR_RECENT, 'public':True, "page": "root", "show_text":_('Show recent books')})
|
||||
sidebar.append({"glyph":"glyphicon-fire","text":_('Hot Books'),"link":url_for('web.hot_books'),"id":"hot", "visibility":ub.SIDEBAR_HOT, 'public':True, "page": "hot", "show_text":_('Show hot books')})
|
||||
sidebar.append({"glyph":"glyphicon-star","text":_('Best rated Books'),"link":url_for('web.best_rated_books'),"id":"rated","visibility":ub.SIDEBAR_BEST_RATED, 'public':True, "page": "rated", "show_text":_('Show best rated books')})
|
||||
sidebar.append({"glyph":"glyphicon-eye-open","text":_('Read Books'),"link":url_for('web.read_books'),"id":"read","visibility":ub.SIDEBAR_READ_AND_UNREAD, 'public':(not g.user.is_anonymous), "page": "read", "show_text":_('Show read')})
|
||||
sidebar.append({"glyph":"glyphicon-eye-close","text":_('Unread Books'),"link":url_for('web.unread_books'),"id":"unread","visibility":ub.SIDEBAR_READ_AND_UNREAD, 'public':(not g.user.is_anonymous), "page": "read", "show_text":_('Show unread')})
|
||||
sidebar.append({"glyph":"glyphicon-random","text":_('Discover'),"link":url_for('web.discover'),"id":"rand","visibility":ub.SIDEBAR_RANDOM, 'public':True, "page": "discover", "show_text":_('Show random books')})
|
||||
sidebar.append({"glyph":"glyphicon-inbox","text":_('Categories'),"link":url_for('web.category_list'),"id":"cat","visibility":ub.SIDEBAR_CATEGORY, 'public':True, "page": "category", "show_text":_('Show category selection')})
|
||||
sidebar.append({"glyph":"glyphicon-bookmark","text":_('Series'),"link":url_for('web.series_list'),"id":"serie","visibility":ub.SIDEBAR_SERIES, 'public':True, "page": "series", "show_text":_('Show series selection')})
|
||||
sidebar.append({"glyph":"glyphicon-user","text":_('Authors'),"link":url_for('web.author_list'),"id":"author","visibility":ub.SIDEBAR_AUTHOR, 'public':True, "page": "author", "show_text":_('Show author selection')})
|
||||
sidebar.append({"glyph":"glyphicon-text-size","text":_('Publishers'),"link":url_for('web.publisher_list'),"id":"publisher","visibility":ub.SIDEBAR_PUBLISHER, 'public':True, "page": "publisher", "show_text":_('Show publisher selection')})
|
||||
sidebar.append({"glyph":"glyphicon-flag","text":_('Languages'),"link":url_for('web.language_overview'),"id":"lang","visibility":ub.SIDEBAR_LANGUAGE, 'public':(g.user.filter_language() == 'all'), "page": "language", "show_text":_('Show language selection')})
|
||||
return render_template(instance=config.config_calibre_web_title, sidebar=sidebar, *args, **kwargs)
|
||||
|
||||
|
||||
@web.before_app_request
|
||||
@ -346,6 +361,9 @@ def get_email_status_json():
|
||||
return response
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'''
|
||||
@web.route("/ajax/getcomic/<int:book_id>/<book_format>/<int:page>")
|
||||
@login_required
|
||||
|
Loading…
Reference in New Issue
Block a user