mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Pass in the custom list template via interface_data
This commit is contained in:
parent
3e6d7c93d2
commit
e62ade9d20
@ -118,6 +118,26 @@ def get_translations():
|
||||
DEFAULT_NUMBER_OF_BOOKS = 50
|
||||
|
||||
|
||||
def custom_list_template():
|
||||
ans = getattr(custom_list_template, 'ans', None)
|
||||
if ans is None:
|
||||
ans = {
|
||||
'thumbnail': True,
|
||||
'thumbnail_height': 140,
|
||||
'height': 'auto',
|
||||
'comments_fields': ['comments'],
|
||||
'lines': [
|
||||
_('<b>{title}</b> by {authors}'),
|
||||
_('{series_index} of <i>{series}</i>') + '|||{rating}',
|
||||
'{tags}',
|
||||
_('Date: {timestamp}') + '|||' + _('Published: {pubdate}') + '|||' + _('Publisher: {publisher}'),
|
||||
'',
|
||||
]
|
||||
}
|
||||
custom_list_template.ans = ans
|
||||
return ans
|
||||
|
||||
|
||||
def basic_interface_data(ctx, rd):
|
||||
ans = {
|
||||
'username': rd.username,
|
||||
@ -126,12 +146,12 @@ def basic_interface_data(ctx, rd):
|
||||
for x in available_input_formats()},
|
||||
'gui_pubdate_display_format': tweaks['gui_pubdate_display_format'],
|
||||
'gui_timestamp_display_format': tweaks['gui_timestamp_display_format'],
|
||||
'gui_last_modified_display_format':
|
||||
tweaks['gui_last_modified_display_format'],
|
||||
'gui_last_modified_display_format': tweaks['gui_last_modified_display_format'],
|
||||
'use_roman_numerals_for_series_number': get_use_roman(),
|
||||
'translations': get_translations(),
|
||||
'icon_map': icon_map(),
|
||||
'icon_path': ctx.url_for('/icon', which=''),
|
||||
'custom_list_template': getattr(ctx, 'custom_list_template', None) or custom_list_template(),
|
||||
}
|
||||
ans['library_map'], ans['default_library_id'] = ctx.library_info(rd)
|
||||
return ans
|
||||
|
@ -6,7 +6,7 @@ from __python__ import bound_methods, hash_literals
|
||||
from elementmaker import E
|
||||
from gettext import gettext as _
|
||||
|
||||
from book_list.details_list import THUMBNAIL_MAX_HEIGHT, sandbox_css, BORDER_RADIUS
|
||||
from book_list.details_list import sandbox_css, BORDER_RADIUS
|
||||
from book_list.library_data import library_data
|
||||
from date import format_date
|
||||
from dom import build_rule, clear, set_css, svgicon
|
||||
@ -15,7 +15,7 @@ from utils import fmt_sidx, safe_set_inner_html, sandboxed_html
|
||||
|
||||
CUSTOM_LIST_CLASS = 'book-list-custom-list'
|
||||
ITEM_CLASS = CUSTOM_LIST_CLASS + '-item'
|
||||
DESCRIPTION = _('A customizable list')
|
||||
DESCRIPTION = _('A customizable list (see Preferences->Sharing over the net->Book list template)')
|
||||
|
||||
def custom_list_css():
|
||||
ans = ''
|
||||
@ -37,10 +37,11 @@ def custom_list_css():
|
||||
|
||||
|
||||
def default_template():
|
||||
# Should never actually be needed
|
||||
if not default_template.ans:
|
||||
default_template.ans = {
|
||||
'thumbnail': True,
|
||||
'thumbnail_height': THUMBNAIL_MAX_HEIGHT,
|
||||
'thumbnail_height': 140,
|
||||
'height': 'auto',
|
||||
'comments_fields': v"['comments']",
|
||||
'lines': [
|
||||
@ -263,7 +264,7 @@ def on_img_load(img, load_type):
|
||||
|
||||
|
||||
def create_item(book_id, metadata, create_image, show_book_details):
|
||||
template = default_template()
|
||||
template = get_interface_data().custom_list_template or default_template()
|
||||
text_data = render_template_text(template, book_id, metadata)
|
||||
text_data.style.flexGrow = '10'
|
||||
text_data.style.overflow = 'hidden'
|
||||
|
@ -165,6 +165,7 @@ default_interface_data = {
|
||||
'library_map': None,
|
||||
'icon_map': {},
|
||||
'icon_path': '',
|
||||
'custom_list_template': None,
|
||||
}
|
||||
|
||||
def get_interface_data():
|
||||
|
Loading…
x
Reference in New Issue
Block a user