Reference pages: add synthetic pagemap#14405
Conversation
|
Cool! There is a user on MobileRead who asked about this just a few days ago: https://www.mobileread.com/forums/showthread.php?t=370154 |
|
IMO, synthetic page numbering should be available even if the book has built-in reference pages. Built-in reference pages are mostly useful for just that -- referencing the page number in the physical copy. And they often contain alphanumeric characters, or are lacking altogether in appendices etc, which makes them less suitable (or unsuitable) for things like statistics tracking or 'go to page' functions etc. Wheareas KOReader-produced synthetic page numbers will be predictable across all books and use cases. |
|
Current implementation in crengine doesn't allow that. |
|
Statistics and GoTo work fine with non-numeric labels, see recent changes. |
|
I see, thanks. |
|
A few points to discuss: Previously, Also, and this is I think a first: you have a submenu for the global setting (
I did the current implementation quickly, just so we can experiment with it. |
The reasons: In-built pagemap indicator: "Characters per page" menu item is disabled. I think it may be useful to allow synthetic pagemap to override the built-in one. |
|
The API is good. |
So, the API is not good :) buildSyntheticPageMapIfNoneDocumentProvided() needs another name.
That's in frontend. In case things get desync'ed (cr3cache from the device with synthetic pagemap vs. metadata.epub.lua sync'ed from another device without |
Yes, that may be a problem. (By the way, currently cr3 cache files are never deleted, neither while deleting nor resetting a book, the cache folder grows up without control) |
has reason finally caught up with you? about time ;)
that the green light to finally fix that whole menu? can I put this forward too #9020 (comment), maybe you can find a way to get it working... ;) |
It's supposed to keep at max 64MB. There's code in crengine to clean up on opening a new book. That's why we don't really need to care, and it's good enough to just delete it when deleting a book. (If that is still working, you think it doesn't ?) koreader/frontend/document/credocument.lua Lines 85 to 87 in 4bad102
No. No decision yet. No green light. Read a book.
As I answered:
Moreover, at this level, we don't/can't know the chapter level for which you would want a new page. If there's |
|
To summarize: |
You are right, we do koreader/frontend/docsettings.lua Lines 463 to 468 in 4bad102 |
Looks like in crengine, all this was already possible: I can keep it for the transition time, and I could easily make these crengine pagemap methods (isDocumentProvided, hasDocumentProvided, isSynthetic, buildSyntheticPageMap(chars_per_synthetic_page)) directly available to frontend - if you feel these are enough, and it's right to copilot that from frontend without anything more clever in cre.cpp. |
|
I think having all crengine pagemap methods in frontend would be good. I see in crengine: Can we have |
|
Changed the property name to |
|
Does this look ok to you ? (the names sounds a bit inconsistent... but they read gramatically correct) --- a/cre.cpp
+++ b/cre.cpp
@@ -1227,6 +1227,36 @@ static int isPageMapSynthetic(lua_State *L) {
return 1;
}
+static int buildSyntheticPageMap(lua_State *L) {
+ CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
+ int chars_per_synthetic_page = luaL_checkint(L, 2);
+ if (doc->dom_doc) {
+ doc->dom_doc->buildSyntheticPageMap(chars_per_synthetic_page);
+ }
+ return 0;
+}
+
+static int getSyntheticPageMapCharsPerPage(lua_State *L) {
+ CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
+ LVPageMap * pagemap = doc->text_view->getPageMap();
+ lua_pushinteger(L, pagemap->isSynthetic());
+ return 1;
+}
+
+static int hasPageMapDocumentProvided(lua_State *L) {
+ CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
+ LVPageMap * pagemap = doc->text_view->getPageMap();
+ lua_pushboolean(L, pagemap->hasDocumentProvided());
+ return 1;
+}
+
+static int isPageMapDocumentProvided(lua_State *L) {
+ CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
+ LVPageMap * pagemap = doc->text_view->getPageMap();
+ lua_pushboolean(L, pagemap->isDocumentProvided());
+ return 1;
+}
+
static int hasPageMap(lua_State *L) {
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
@@ -4311,6 +4341,10 @@ static const struct luaL_Reg credocument_meth[] = {
{"getPageMapVisiblePageLabels", getPageMapVisiblePageLabels},
{"buildSyntheticPageMapIfNoneDocumentProvided", buildSyntheticPageMapIfNoneDocumentProvided},
{"isPageMapSynthetic", isPageMapSynthetic},
+ {"buildSyntheticPageMap", buildSyntheticPageMap},
+ {"getSyntheticPageMapCharsPerPage", getSyntheticPageMapCharsPerPage},
+ {"hasPageMapDocumentProvided", hasPageMapDocumentProvided},
+ {"isPageMapDocumentProvided", isPageMapDocumentProvided},
{"hasNonLinearFlows", hasNonLinearFlows},
{"checkRegex", checkRegex},
{"getAndClearRegexSearchError", getAndClearRegexSearchError},On a book with provided reference pages: function ReaderPageMap:_postInit()
local logger = require("logger")
logger.warn("getSyntheticPageMapCharsPerPage", self.ui.document._document:getSyntheticPageMapCharsPerPage())
logger.warn("hasPageMapDocumentProvided", self.ui.document._document:hasPageMapDocumentProvided())
logger.warn("isPageMapDocumentProvided", self.ui.document._document:isPageMapDocumentProvided())
logger.warn("buildSyntheticPageMap", self.ui.document._document:buildSyntheticPageMap(1400))
-- logger.warn("buildSyntheticPageMap", self.ui.document._document:buildSyntheticPageMap(0))
logger.warn("getSyntheticPageMapCharsPerPage", self.ui.document._document:getSyntheticPageMapCharsPerPage())
logger.warn("hasPageMapDocumentProvided", self.ui.document._document:hasPageMapDocumentProvided())
logger.warn("isPageMapDocumentProvided", self.ui.document._document:isPageMapDocumentProvided()) |
|
Very good, thanks. I didn't know this worked: |
It will just do: m_pagemap.clear();
m_pagemap.invalidatePageInfo();
if ( chars_per_synthetic_page <= 0 ) {
m_pagemap._chars_per_synthetic_page = 0;
return;
}I'll let you see what else you need to do on frontend when setting and unsetting for everything to be consistent.
When unsetting (=0) probably. When setting (=1400), I don't know. I think it may be similar to what we need when switching to/from the Alternative ToC. |
|
I'm sure you don't forget, just in case: please also fix the |
|
Forgot to mention that above: if unsetting synthetic pages, if the book has no documentprovided, you may not need to reload it, just to clear/reset stuff in the pagemap module. |
|
^ I'd like to be told the "source" (I call if "source", but there may be another better name), so I never have to go see that menu. Source can be a url, or |
|
In my has stable page numbers provided by the publisher, that refer to:, I was trying to keep a last trace of the word that you have savagely anihilated : "refer(ence)" |
|
We have "Page numbers source" in the menu item. |
I think it is, but well. May be now "Publisher reference" can just work, now that we don't use "reference" anywhere ? |
|
No "reference" in the spec |
|
By the way, they use "static page break". |
|
I only just realised that "book hardcopy" doesn't make much sense, all books are physical copies of something, maybe it was meant to be hardback/paperback? What would that become exactly? |
|
Maybe we should change "stable" to "static"? |
I prefer "stable", it states exactly why these would be useful. "static" doesn't say that as clearly. |
static means it doesn't change, "stable" although it also has a similar meaning, hints more at equilibrium or things being balanced. I actually think static fits the bill better. |
|
Not opposed to "static" if you all feel it's better. |
|
@Frenzie 's final decision: "stable page numbers" or "static page numbers"? |
|
PDF is commonly known to have stable page numbers. Static page numbers are a problem in Microsoft Word where it doesn't update a page number when it should. ;-) https://www.historians.org/perspectives-article/do-digital-docs-need-page-numbers-june-2011/
https://connect.ebsco.com/s/article/Citing-EBSCO-eBooks?language=en_US
Etc. |
|
Okay, it's ready. |
|
Also stable is a more familiar word because of its usage in diverse topics like stable income, stable personality, stable desk etc. It is generally used like this even in distant languages. So it might have a little advantage here. |
|
Congrats we are now Living in the plastic age. |
|
Oh, thank you. This page counting mechanism is much better than I expected. Even the (x)html file includes only a handful of texts (like Part 1) or only an image with no text, is counted as 1. It makes sense. |
Thanks for the feedback. Illustrated at #14426 (comment) . |
|
Just updated, and I was a bit confused, as I didn't get the popup on a new book with ref pages. (So, Show page labels in margin was defaulted to true - given the amount of people getting them and not liking them - but @Frenzie does, if we go at (p) in Book information, may be we could default to not enabled ?) |
Are they? It all looks very disabled to me. (Same on my Kobo, where I almost certainly didn't touch these settings.) Edit:
I don't have that either. |
Discussed in and closes koreader#9020.


Discussed in and closes #9020.
A book with built-in reference pages.

A book without built-in and without synthetic reference pages.

A book with synthetic reference pages.

Default settings menu (for newly opened books).

This change is