mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Content server: Add an option to control which book list mode is used by default for new users (Preferences->Sharing over the net->Choose book list mode)
This commit is contained in:
parent
1cae595984
commit
1a3d09a61b
@ -151,6 +151,7 @@ def basic_interface_data(ctx, rd):
|
||||
'custom_list_template': getattr(ctx, 'custom_list_template', None) or custom_list_template(),
|
||||
'search_the_net_urls': getattr(ctx, 'search_the_net_urls', None) or [],
|
||||
'num_per_page': rd.opts.num_per_page,
|
||||
'default_book_list_mode': rd.opts.book_list_mode,
|
||||
'donate_link': localize_website_link('https://calibre-ebook.com/donate')
|
||||
}
|
||||
ans['library_map'], ans['default_library_id'] = ctx.library_info(rd)
|
||||
|
@ -187,7 +187,10 @@ raw_options = (
|
||||
' option, any fields not in this list will not be displayed. For example: {}').format(
|
||||
'my_rating,my_tags'),
|
||||
|
||||
|
||||
_('Choose the default book list mode'),
|
||||
'book_list_mode', Choices('cover_grid', 'details_list', 'custom_list'),
|
||||
_('Set the default book list mode that will be used for new users. Individual users'
|
||||
' can override the default in their own settings. The default is to use a cover grid.'),
|
||||
)
|
||||
assert len(raw_options) % 4 == 0
|
||||
|
||||
|
@ -5,11 +5,11 @@ from __python__ import bound_methods, hash_literals
|
||||
from elementmaker import E
|
||||
from gettext import gettext as _
|
||||
|
||||
from book_list.globals import get_db, get_session_data
|
||||
from book_list.globals import get_db
|
||||
from book_list.router import home, open_book
|
||||
from book_list.top_bar import create_top_bar
|
||||
from book_list.ui import set_panel_handler
|
||||
from book_list.views import DEFAULT_MODE, setup_view_mode
|
||||
from book_list.views import DEFAULT_MODE, setup_view_mode, get_view_mode
|
||||
from dom import clear, ensure_id
|
||||
from modals import create_custom_dialog, error_dialog
|
||||
from utils import conditional_timeout
|
||||
@ -127,7 +127,7 @@ def create_books_list(container, books):
|
||||
book_list_data.mode = None
|
||||
book_list_data.thumbnail_cache = {}
|
||||
container.appendChild(E.div(data_component='book_list'))
|
||||
apply_view_mode(get_session_data().get('view_mode'))
|
||||
apply_view_mode(get_view_mode())
|
||||
|
||||
def show_recent_stage2(books):
|
||||
container = document.getElementById(this)
|
||||
|
@ -131,6 +131,14 @@ def render_ids(book_ids):
|
||||
book_list_data.append_item(div, child)
|
||||
|
||||
|
||||
def get_view_mode():
|
||||
idata = get_interface_data()
|
||||
mode = get_session_data().get('view_mode', idata.default_book_list_mode)
|
||||
if mode not in ('cover_grid', 'details_list', 'custom_list'):
|
||||
mode = DEFAULT_MODE
|
||||
return mode
|
||||
|
||||
|
||||
def setup_view_mode(mode, book_list_data):
|
||||
if mode not in ALLOWED_MODES:
|
||||
mode = DEFAULT_MODE
|
||||
@ -259,7 +267,7 @@ def create_books_list(container):
|
||||
container.appendChild(E.div(data_component='book_list'))
|
||||
container.appendChild(E.div(data_component='more_button'))
|
||||
show_top_message()
|
||||
apply_view_mode(get_session_data().get('view_mode'))
|
||||
apply_view_mode(get_view_mode())
|
||||
create_more_button(container.lastChild)
|
||||
add_button(container.parentNode, icon='plus', action=show_subsequent_panel.bind(None, 'book_list^add'), tooltip=_('Add books'))
|
||||
add_button(container.parentNode, icon='sort-amount-desc', action=show_subsequent_panel.bind(None, 'book_list^sort'), tooltip=_('Sort books'))
|
||||
@ -419,7 +427,7 @@ def create_mode_panel(container_id):
|
||||
container = document.getElementById(container_id)
|
||||
create_top_bar(container, title=_('Choose book list mode…'), action=back, icon='close')
|
||||
items = []
|
||||
current_mode = get_session_data().get('view_mode')
|
||||
current_mode = get_view_mode()
|
||||
|
||||
def ci(title, desc, name):
|
||||
ic = 'check' if name is current_mode else None
|
||||
|
@ -168,6 +168,7 @@ default_interface_data = {
|
||||
'gui_last_modified_display_format': 'dd MMM yyyy',
|
||||
'use_roman_numerals_for_series_number': True,
|
||||
'default_library_id': None,
|
||||
'default_book_list_mode': defaults.view_mode,
|
||||
'library_map': None,
|
||||
'search_the_net_urls': [],
|
||||
'donate_link': 'https://calibre-ebook.com/donate',
|
||||
|
Loading…
x
Reference in New Issue
Block a user