From 1c26a6ce17e64392e25d6e2c9e41cc8e2b5a0591 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 22 Aug 2024 19:46:15 +0530 Subject: [PATCH] Show current page number in goto printed page --- src/calibre/srv/render_book.py | 4 ++-- src/pyj/read_book/goto.pyj | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/calibre/srv/render_book.py b/src/calibre/srv/render_book.py index 68961f707f..782829c85a 100644 --- a/src/calibre/srv/render_book.py +++ b/src/calibre/srv/render_book.py @@ -197,11 +197,11 @@ def pagelist_anchor_map(page_list): ans = defaultdict(list) seen_map = defaultdict(set) for i, x in enumerate(page_list): - x['id'] = i + x['id'] = i + 1 name = x['dest'] frag = x['frag'] if name and frag not in seen_map[name]: - ans[name].append({'id': i, 'pagenum': x['pagenum'], 'frag':frag}) + ans[name].append({'id': x['id'], 'pagenum': x['pagenum'], 'frag':frag}) seen_map[name].add(frag) return dict(ans) diff --git a/src/pyj/read_book/goto.pyj b/src/pyj/read_book/goto.pyj index e89d007634..0796501621 100644 --- a/src/pyj/read_book/goto.pyj +++ b/src/pyj/read_book/goto.pyj @@ -63,6 +63,15 @@ def create_goto_panel(current_position_data, book, container, onclick): def create_page_list_overlay(book, overlay, container): + list_container = E.div() + pl = overlay.view.current_pagelist_items + if pl and pl.length > 0: + if pl.length is 1: + text = _('Currently on page: {}').format(pl[0].pagenum) + else: + text = _('Currently on pages: {}').format(pl[0].pagenum + ' - ' + pl[1].pagenum) + container.appendChild(E.div(style='margin: 1em', text)) + container.appendChild(list_container) page_list = book.manifest.page_list or v'[]' items = v'[]' @@ -73,7 +82,7 @@ def create_page_list_overlay(book, overlay, container): for x in page_list: items.push(create_item(x.pagenum, action=goto.bind(None, x), )) - build_list(container, items) + build_list(list_container, items) def create_location_overlay(current_position_data, book, overlay, container):