How can I implement multi-level support of <navmap> based on Epub.php?
I read the source code, and seems no where to configure the level when I add content through addChaper().
Does there any way to achieve it?
|2011-09-21 10:15:14 - In reply to message 1 from Mark Wu|
For example, I like to have my book structure like:
-Chapter 1 - Introduction
-Chapter 2 - Story 1
-Chapter 3 - Story 2
-Chapter 4 - Story 3
I read the source code, seems the $chapterData can be an array, but I am not sure it is what I am looking for.
Hope this description can make my question more clear.
|2011-09-21 10:21:00 - In reply to message 2 from Mark Wu|
|I am wrong. $chapterData only can be string, ...|
Than, I really have no idea how to implement multi-leve navmap.
|2011-09-21 10:22:14 - In reply to message 2 from Mark Wu|
|Currently you can't have multiple levels in the navmap, it is something that is also on my to do list :)|
The array for chapter data is merely because one chapter can span multiple html files, needed as Adobe Digital Editions used in most e-book readers today have a 250kb file limit on the html files.
|2011-09-21 10:30:05 - In reply to message 4 from Asbjorn Grandt|
Thanks, I see.
Would you kindly give me some hints If I want to enhance Epub.php to support multi-level navmap by myself.
If it not hard to understand, I will see if I can implement it and make some contributions to this project.
|2011-09-21 10:51:41 - In reply to message 5 from Mark Wu|
|It'll have to wait till I get home from work. Then I can provide some line numbers where the current nav map is being handled.|
You might be interested in version 2.10RC4 of EPub I have in progress.:
|2011-09-21 10:53:45 - In reply to message 6 from Asbjorn Grandt|
|I see, thanks!|
I'll take a look and see what I can do.
|2011-09-23 04:55:16 - In reply to message 6 from Asbjorn Grandt|
I have some available time in next several days, so ..If you could kindly give me further hints for multi-level <navmap> development, I will be appreciate.
I think you might be very busy, take your time. :D
|2011-09-23 14:21:27 - In reply to message 8 from Mark Wu|
Starting from the 2.04 version currently on this site, rather than the 2.10 release candidate simply because this is the version I could drop into an editor here :)
Lines 228 and 250, in the addChapter function, are adding entries to the navmap on the fly. So there aren't really an array being filled up, and used to build the actual structure during the finalize stage.
This is the problem that needs fixing, preferably while maintaining backwards compatibility.
The solution, may be to add a pair of functions to set the navmap level. (incrNavMapLevel and decrNavMapLevel?) along with a variables to maintain the current and the deepest level used. The second variable is needed for the navmap header.
I must admit that I haven't done much work on the navmaps, as I've so far never had to go beyond one level.
Using methods to push and pull the navmap levels in this matter would also make it a bit easier to build several books into the ePub, as the builder don't have to bother with the current level it's at, when it start adding a book.
The first step will definitely be to extract the navmap building code as seen in the two lines mentioned above, into separate functions, as the content src links in these can point to fragment id's (apart from the top level, though that is a restriction in books based on ADE it seems, and not really a specification limitation)
At this time I think the better solution will be to make a NavPoint class with the variables needed to hold the attributes, as well as an array to hold it's children, as writing a multilevel navMap on the fly is going to get very interesting very fast :)
That of course means another step to perform during finalization.
|2011-09-29 05:01:10 - In reply to message 9 from Asbjorn Grandt|
Sorry to reply this message so late, I just got cold ..
I will take your advice and see what I can do.
BTW, I'll create a github for version control, it is easier for me to control the branch, and easier for you to got the patch.
I'll let you know when I set it up.