Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Page with Chapters to Chapters List broken #1540

Open
gamebeaker opened this issue Oct 4, 2024 · 5 comments
Open

Add Page with Chapters to Chapters List broken #1540

gamebeaker opened this issue Oct 4, 2024 · 5 comments

Comments

@gamebeaker
Copy link
Collaborator

In Advanced Options is an option "Add Page with Chapters to Chapters List" on royalroad it does nothing. (https://www.royalroad.com/fiction/81569/magus-reborn-mana-cultivation-kingdom-building)
I would expect a page like the Information page to be added to the epub.
What is the problem?

// returns promise, because may need to fetch additional pages to find list of chapters
that.getChapterUrls(firstPageDom, chapterUrlsUI).then(function(chapters) {
if (that.userPreferences.chaptersPageInChapterList.value) {
chapters = that.addFirstPageUrlToWebPages(url, firstPageDom, chapters);
}
chapters = that.cleanWebPageUrls(chapters);
that.userPreferences.readingList.deselectOldChapters(url, chapters);

getChapterUrls() is overwritten from RoyalRoadParsers.js and the check isn't done.

I think the check is on the wrong position of the code as it always fails if getChapterUrls() is overwriten from the parser.

@dteviot
Copy link
Owner

dteviot commented Oct 6, 2024

@gamebeaker
Possibly the feature is not well named. What it was intended to do was add the web page that held the Table of Contents to the epub.
It's always been flaky, because it assumes the Table of Contents page has the same format as the chapters. When this is not true, it fails.

@gamebeaker
Copy link
Collaborator Author

@dteviot Ok
I expected that WebToEpub creates a page which contains all Chapter names and links to them like an Index.
You can create suche an Index page in calibre if you convert an epub file to zip.
Example:
image

What it was intended to do was add the web page that held the Table of Contents to the epub.

If i deselect Chapters that wouldn't be reflected.
Is a better name "Add Index Page"? (after fix to reflect the rename)

@dteviot
Copy link
Owner

dteviot commented Oct 6, 2024

@gamebeaker

It's purpose wasn't to create an index page. It an early (and only partially successful) attempt to provide an information page.
The case was, there's a lot of sites where the "Table of Contents" page for a story has other information as well, e.g. Synopsis, Author, Dates, etc. So, the intent of this option was to capture this web page along with the actual chapters and package it into the epub.

But it has been (in my opinion) mostly replaced by the information page. I think it's still used by a number of people, for a limited number of sites.

@dteviot
Copy link
Owner

dteviot commented Oct 6, 2024

If you want to create an index page, the Epub 3 format specified a HTML index page. So code to do it is already there.
See:

buildNavigationDocument(epubItemSupplier) {
let ns = "http://www.w3.org/1999/xhtml";
let navDoc = document.implementation.createDocument(ns, "html", null);
navDoc.documentElement.setAttribute("xml:lang", this.metaInfo.language);
navDoc.documentElement.setAttribute("xmlns:epub", "http://www.idpf.org/2007/ops");
navDoc.documentElement.setAttribute("lang", this.metaInfo.language);
let head = this.createAndAppendChildNS(navDoc.documentElement, ns, "head");
this.createAndAppendChildNS(head, ns, "title").textContent = "Table of Contents";
this.addDocType(navDoc);
let body = this.createAndAppendChildNS(navDoc.documentElement, ns, "body");
let nav = this.createAndAppendChildNS(body, ns, "nav");
nav.setAttribute("epub:type", "toc");
nav.setAttribute("id", "toc");
this.populateNavElement(nav, ns, epubItemSupplier);
return util.xmlToString(navDoc);
}

@gamebeaker
Copy link
Collaborator Author

@dteviot

If you want to create an index page, the Epub 3 format specified a HTML index page. So code to do it is already there.

I don't think an Index is necessary, so i won't implement it. (All readers i know provide simple options to navigate different Chapter.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants