mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement epubReadingSystem for the in browser viewer
This commit is contained in:
parent
d97e1ce707
commit
195b083c3a
@ -215,7 +215,10 @@ def compile_srv():
|
||||
base = P('content-server', allow_user_override=False)
|
||||
fname = os.path.join(rapydscript_dir, 'srv.pyj')
|
||||
with lopen(fname, 'rb') as f:
|
||||
js = compile_fast(f.read(), fname).replace('__RENDER_VERSION__', rv, 1).replace('__MATHJAX_VERSION__', mathjax_version, 1).encode('utf-8')
|
||||
js = compile_fast(f.read(), fname).replace(
|
||||
'__RENDER_VERSION__', rv, 1).replace(
|
||||
'__MATHJAX_VERSION__', mathjax_version, 1).replace(
|
||||
'__CALIBRE_VERSION__', __version__, 1).encode('utf-8')
|
||||
with lopen(os.path.join(base, 'index.html'), 'rb') as f:
|
||||
html = f.read().replace(b'RESET_STYLES', reset, 1).replace(b'ICONS', icons, 1).replace(b'MAIN_JS', js, 1)
|
||||
|
||||
|
@ -28,10 +28,38 @@ from read_book.touch import create_handlers as create_touch_handlers
|
||||
from utils import debounce
|
||||
|
||||
FORCE_FLOW_MODE = False
|
||||
CALIBRE_VERSION = '__CALIBRE_VERSION__'
|
||||
ERS_SUPPORTED_FEATURES = {'dom-manipulation', 'layout-changes', 'touch-events', 'mouse-events', 'keyboard-events', 'spine-scripting'}
|
||||
|
||||
|
||||
class EPUBReadingSystem:
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return 'calibre'
|
||||
|
||||
@property
|
||||
def version(self):
|
||||
return CALIBRE_VERSION
|
||||
|
||||
@property
|
||||
def layoutStyle(self):
|
||||
return 'scrolling' if current_layout_mode() is 'flow' else 'paginated'
|
||||
|
||||
def hasFeature(self, feature, version):
|
||||
return feature in ERS_SUPPORTED_FEATURES
|
||||
|
||||
def __repr__(self):
|
||||
return f'{{name:{self.name}, version:{self.version}, layoutStyle:{self.layoutStyle}}}'
|
||||
|
||||
def __str__(self):
|
||||
return self.__repr__()
|
||||
|
||||
|
||||
class IframeBoss:
|
||||
|
||||
def __init__(self):
|
||||
window.navigator.epubReadingSystem = EPUBReadingSystem()
|
||||
self.ready_sent = False
|
||||
self.last_cfi = None
|
||||
self.replace_history_on_next_cfi_update = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user