mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Load HTML resources for viewer
This commit is contained in:
parent
f721d49e32
commit
8234dc5436
@ -172,6 +172,13 @@ class WebPage(QWebEnginePage):
|
|||||||
self.runJavaScript(src, QWebEngineScript.ApplicationWorld, callback)
|
self.runJavaScript(src, QWebEngineScript.ApplicationWorld, callback)
|
||||||
|
|
||||||
|
|
||||||
|
def viewer_html():
|
||||||
|
ans = getattr(viewer_html, 'ans', None)
|
||||||
|
if ans is None:
|
||||||
|
ans = viewer_html.ans = P('viewer.html', data=True, allow_user_override=False).decode('utf-8')
|
||||||
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class WebView(RestartingWebEngineView):
|
class WebView(RestartingWebEngineView):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
@ -203,7 +210,7 @@ class WebView(RestartingWebEngineView):
|
|||||||
self.pageAction(QWebEnginePage.Reload).trigger()
|
self.pageAction(QWebEnginePage.Reload).trigger()
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self.setHtml('<p> ', QUrl('{}://{}/'.format(FAKE_PROTOCOL, FAKE_HOST)))
|
self.setHtml(viewer_html(), QUrl('{}://{}/'.format(FAKE_PROTOCOL, FAKE_HOST)))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def bridge(self):
|
def bridge(self):
|
||||||
|
@ -225,6 +225,15 @@ def compile_editor():
|
|||||||
|
|
||||||
def compile_viewer():
|
def compile_viewer():
|
||||||
base = base_dir()
|
base = base_dir()
|
||||||
|
iconf = os.path.join(base, 'imgsrc', 'srv', 'generate.py')
|
||||||
|
g = {'__file__': iconf}
|
||||||
|
execfile(iconf, g)
|
||||||
|
icons = g['merge']().encode('utf-8')
|
||||||
|
with lopen(os.path.join(base, 'resources', 'content-server', 'reset.css'), 'rb') as f:
|
||||||
|
reset = f.read()
|
||||||
|
html = '<!DOCTYPE html>\n<html><head><style>{reset}</style></head><body>{icons}</body></html>'.format(
|
||||||
|
icons=icons, reset=reset)
|
||||||
|
|
||||||
rapydscript_dir = os.path.join(base, 'src', 'pyj')
|
rapydscript_dir = os.path.join(base, 'src', 'pyj')
|
||||||
fname = os.path.join(rapydscript_dir, 'viewer-main.pyj')
|
fname = os.path.join(rapydscript_dir, 'viewer-main.pyj')
|
||||||
with lopen(fname, 'rb') as f:
|
with lopen(fname, 'rb') as f:
|
||||||
@ -234,6 +243,7 @@ def compile_viewer():
|
|||||||
'__FAKE_HOST__', FAKE_HOST, 1)
|
'__FAKE_HOST__', FAKE_HOST, 1)
|
||||||
base = os.path.join(base, 'resources')
|
base = os.path.join(base, 'resources')
|
||||||
atomic_write(base, 'viewer.js', js)
|
atomic_write(base, 'viewer.js', js)
|
||||||
|
atomic_write(base, 'viewer.html', html)
|
||||||
|
|
||||||
|
|
||||||
def compile_srv():
|
def compile_srv():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user