Access the publications Landmarks via Go to...

This commit is contained in:
Kovid Goyal 2017-01-02 14:22:54 +05:30
parent 1600c3a347
commit 929595c805
2 changed files with 9 additions and 2 deletions

View File

@ -26,7 +26,7 @@ from calibre.ebooks.oeb.polish.cover import set_epub_cover, find_cover_image
from calibre.ebooks.oeb.polish.css import transform_css from calibre.ebooks.oeb.polish.css import transform_css
from calibre.ebooks.oeb.polish.utils import extract from calibre.ebooks.oeb.polish.utils import extract
from calibre.ebooks.css_transform_rules import StyleDeclaration from calibre.ebooks.css_transform_rules import StyleDeclaration
from calibre.ebooks.oeb.polish.toc import get_toc from calibre.ebooks.oeb.polish.toc import get_toc, get_landmarks
from calibre.ebooks.oeb.polish.utils import guess_type from calibre.ebooks.oeb.polish.utils import guess_type
from calibre.utils.short_uuid import uuid4 from calibre.utils.short_uuid import uuid4
from calibre.utils.logging import default_log from calibre.utils.logging import default_log
@ -182,11 +182,14 @@ class Container(ContainerBase):
} }
raster_cover_name, titlepage_name = self.create_cover_page(input_fmt.lower()) raster_cover_name, titlepage_name = self.create_cover_page(input_fmt.lower())
toc = get_toc(self).to_dict(count()) toc = get_toc(self).to_dict(count())
spine = [name for name, is_linear in self.spine_names]
spineq = frozenset(spine)
landmarks = [l for l in get_landmarks(self) if l['dest'] in spineq]
self.book_render_data = data = { self.book_render_data = data = {
'version': RENDER_VERSION, 'version': RENDER_VERSION,
'toc':toc, 'toc':toc,
'spine':[name for name, is_linear in self.spine_names], 'spine':spine,
'link_uid': uuid4(), 'link_uid': uuid4(),
'book_hash': book_hash, 'book_hash': book_hash,
'is_comic': input_fmt.lower() in {'cbc', 'cbz', 'cbr', 'cb7'}, 'is_comic': input_fmt.lower() in {'cbc', 'cbz', 'cbr', 'cb7'},
@ -196,6 +199,7 @@ class Container(ContainerBase):
'total_length': 0, 'total_length': 0,
'spine_length': 0, 'spine_length': 0,
'toc_anchor_map': toc_anchor_map(toc), 'toc_anchor_map': toc_anchor_map(toc),
'landmarks': landmarks,
} }
# Mark the spine as dirty since we have to ensure it is normalized # Mark the spine as dirty since we have to ensure it is normalized
for name in data['spine']: for name in data['spine']:

View File

@ -14,6 +14,7 @@ from read_book.globals import current_book
def create_goto_list(onclick): def create_goto_list(onclick):
ans = E.div() ans = E.div()
items = v'[]' items = v'[]'
landmarks = current_book().manifest.landmarks
toc = current_book().manifest.toc toc = current_book().manifest.toc
id_map = get_toc_maps(toc)[1] id_map = get_toc_maps(toc)[1]
before, after = get_border_nodes(toc, id_map) before, after = get_border_nodes(toc, id_map)
@ -23,6 +24,8 @@ def create_goto_list(onclick):
items.push(create_item(_('Previous Section'), icon='caret-left', subtitle=before.title, action=onclick.bind(None, before.dest, before.frag))) items.push(create_item(_('Previous Section'), icon='caret-left', subtitle=before.title, action=onclick.bind(None, before.dest, before.frag)))
items.push(create_item(_('Document Start'), action=onclick.bind(None, def(view): view.goto_doc_boundary(True);))) items.push(create_item(_('Document Start'), action=onclick.bind(None, def(view): view.goto_doc_boundary(True);)))
items.push(create_item(_('Document End'), action=onclick.bind(None, def(view): view.goto_doc_boundary(False);))) items.push(create_item(_('Document End'), action=onclick.bind(None, def(view): view.goto_doc_boundary(False);)))
for l in landmarks:
items.push(create_item(l.title, action=onclick.bind(None, l.dest, l.frag)))
build_list(ans, items) build_list(ans, items)
return ans return ans