mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix loading of non-virtualized resources when html files are not in the book root
This commit is contained in:
parent
ac036ccf1b
commit
7ca139a210
@ -201,7 +201,7 @@ class PopupIframeBoss:
|
||||
window.URL.revokeObjectURL(self.blob_url_map[name])
|
||||
document.body.style.removeProperty('font-family')
|
||||
root_data, self.mathjax, self.blob_url_map = finalize_resources(self.book, data.name, data.resource_data)
|
||||
self.resource_urls = unserialize_html(root_data, self.content_loaded, self.show_only_footnote)
|
||||
self.resource_urls = unserialize_html(root_data, self.content_loaded, self.show_only_footnote, data.name)
|
||||
|
||||
def on_clear(self, data):
|
||||
clear(document.head)
|
||||
|
@ -175,7 +175,7 @@ class IframeBoss:
|
||||
window.URL.revokeObjectURL(self.blob_url_map[name])
|
||||
document.body.style.removeProperty('font-family')
|
||||
root_data, self.mathjax, self.blob_url_map = finalize_resources(self.book, data.name, data.resource_data)
|
||||
self.resource_urls = unserialize_html(root_data, self.content_loaded)
|
||||
self.resource_urls = unserialize_html(root_data, self.content_loaded, None, data.name)
|
||||
|
||||
def on_scroll_to_frac(self, data):
|
||||
self.to_scroll_fraction(data.frac)
|
||||
|
@ -225,7 +225,7 @@ def process_stack(stack, tag_map, ns_map, load_required, onload, resource_urls):
|
||||
for v'var i = node.length - 1; i >= 1; i--': # noqa: unused-local
|
||||
stack.push(v'[node[i], elem]')
|
||||
|
||||
def unserialize_html(serialized_data, proceed, postprocess_dom):
|
||||
def unserialize_html(serialized_data, proceed, postprocess_dom, root_name):
|
||||
nonlocal hide_tooltips
|
||||
tag_map = serialized_data.tag_map
|
||||
tree = serialized_data.tree
|
||||
@ -241,6 +241,13 @@ def unserialize_html(serialized_data, proceed, postprocess_dom):
|
||||
document.head.appendChild(
|
||||
E.style(type='text/css', 'html::-webkit-scrollbar, body::-webkit-scrollbar { display: none !important }')
|
||||
)
|
||||
if runtime.is_standalone_viewer and root_name:
|
||||
if root_name.indexOf('/') > -1:
|
||||
base = window.location.pathname.rpartition('/')[0]
|
||||
base = f'{window.location.protocol}//{window.location.hostname}{base}/' + root_name
|
||||
document.head.appendChild(E.base(href=base))
|
||||
|
||||
|
||||
# Default stylesheet
|
||||
if not runtime.is_standalone_viewer:
|
||||
# for the standalone viewer the default font family is set
|
||||
|
Loading…
x
Reference in New Issue
Block a user