mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make foreground color of sandboxed html in the book list the same as the theme color
This commit is contained in:
parent
8bc842ddb2
commit
26f61556d1
@ -6,7 +6,7 @@ from __python__ import bound_methods, hash_literals
|
|||||||
from elementmaker import E
|
from elementmaker import E
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
from book_list.details_list import THUMBNAIL_MAX_HEIGHT
|
from book_list.details_list import THUMBNAIL_MAX_HEIGHT, sandbox_css
|
||||||
from book_list.library_data import library_data
|
from book_list.library_data import library_data
|
||||||
from date import format_date
|
from date import format_date
|
||||||
from dom import build_rule, clear, set_css, svgicon
|
from dom import build_rule, clear, set_css, svgicon
|
||||||
@ -234,7 +234,7 @@ def render_template_text(template, book_id, metadata):
|
|||||||
html += f'<div style="margin-bottom:1.5ex">{val}</div>'
|
html += f'<div style="margin-bottom:1.5ex">{val}</div>'
|
||||||
|
|
||||||
if html:
|
if html:
|
||||||
comments = sandboxed_html(html, 'html { overflow: hidden }')
|
comments = sandboxed_html(html, sandbox_css())
|
||||||
ans.appendChild(comments)
|
ans.appendChild(comments)
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
@ -5,9 +5,10 @@ from __python__ import bound_methods, hash_literals
|
|||||||
from elementmaker import E
|
from elementmaker import E
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
|
from book_list.theme import get_color
|
||||||
from dom import build_rule, clear, set_css, svgicon
|
from dom import build_rule, clear, set_css, svgicon
|
||||||
from session import get_interface_data
|
from session import get_interface_data
|
||||||
from utils import fmt_sidx, sandboxed_html, safe_set_inner_html
|
from utils import fmt_sidx, safe_set_inner_html, sandboxed_html
|
||||||
|
|
||||||
DETAILS_LIST_CLASS = 'book-list-details-list'
|
DETAILS_LIST_CLASS = 'book-list-details-list'
|
||||||
ITEM_CLASS = DETAILS_LIST_CLASS + '-item'
|
ITEM_CLASS = DETAILS_LIST_CLASS + '-item'
|
||||||
@ -62,6 +63,12 @@ def on_img_load(img, load_type):
|
|||||||
set_css(div, border='dashed 1px currentColor', border_radius=BORDER_RADIUS+'px')
|
set_css(div, border='dashed 1px currentColor', border_radius=BORDER_RADIUS+'px')
|
||||||
|
|
||||||
|
|
||||||
|
def sandbox_css():
|
||||||
|
if not sandbox_css.ans:
|
||||||
|
sandbox_css.ans = 'html {{ overflow: hidden; color: {} }}'.format(get_color('window-foreground'))
|
||||||
|
return sandbox_css.ans
|
||||||
|
|
||||||
|
|
||||||
def create_item(book_id, metadata, create_image, show_book_details):
|
def create_item(book_id, metadata, create_image, show_book_details):
|
||||||
authors = metadata.authors.join(' & ') if metadata.authors else _('Unknown')
|
authors = metadata.authors.join(' & ') if metadata.authors else _('Unknown')
|
||||||
img = create_image(book_id, THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT, on_img_load)
|
img = create_image(book_id, THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT, on_img_load)
|
||||||
@ -69,7 +76,7 @@ def create_item(book_id, metadata, create_image, show_book_details):
|
|||||||
img.dataset.title, img.dataset.authors = metadata.title, authors
|
img.dataset.title, img.dataset.authors = metadata.title, authors
|
||||||
img_div = E.div(img, class_='details-list-left')
|
img_div = E.div(img, class_='details-list-left')
|
||||||
extra_data = E.div()
|
extra_data = E.div()
|
||||||
comments = sandboxed_html(metadata.comments, 'html { overflow: hidden }')
|
comments = sandboxed_html(metadata.comments, sandbox_css())
|
||||||
if not metadata.comments:
|
if not metadata.comments:
|
||||||
comments.style.display = 'none'
|
comments.style.display = 'none'
|
||||||
comments.style.marginTop = '1ex'
|
comments.style.marginTop = '1ex'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user