Syllabus 20100224

From XPUB & Lens-Based wiki
Revision as of 20:33, 23 September 2010 by Migratebot (talk | contribs) (Created page with "= Epub hacking Day 3 = == Review of last week's assignments == '''Reminder''' Try to combine in one python script: * fetching the images from 4chan * add them in an epu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Epub hacking Day 3

Review of last week's assignments

Reminder Try to combine in one python script:

  • fetching the images from 4chan
  • add them in an epub container while experimenting with the layout and image captions
  • use a customized ePub skeleton that has your fonts embedded for the image captions
  • generate the ePub
  • Presentation of the produced ePubs
  • Feedback from assignments, difficulties encountered while working on the ebook, ...

Practical ePub dissection: table of content

The last file that we need to understand for hacking ePubs is the TOC (Table Of Content) and is usually called toc.ncx and located in the OEBPS folder of the ePub container. So far we have only covered ePub with only one html file used for the content, which is why the TOC only had only one item/link.

The three important parts of the toc.ncx file are:

  • <head>: make sure you use same ebook uid as the one you declared in content.opf
  • <docTitle>: make sure you use the same or similar title as your ebook title. This one will be displayed as the book title in your TOC.
  • <navMap>: This is where you need to describe the chapters of your book. The navMap is made of navPoints, Each navPoint tag represents a chapter and where it is located in the container. More particularly:
    <navPoint id="navpoint-1" playOrder="1">
      <navLabel>
        <text>Book cover</text>
      </navLabel>
      <content src="title.html"/>
    </navPoint>
  • id: can be anything you want in theory but to make it easier to remember and for the sake of compatibility, use the same id names as those defined in content.opf.
  • playOrder: the display order of this item in the TOC. Must be an integer and continuous, ie: 1, 2, 3, 4
  • <text>: the title of the chapter as it will be displayed in the TOC
  • <content>: needs to point to a valid declared HTML content file in your container.

Exercise: use the ePub skeleton or an existing ePub and add an extra HTML content file. This file must show up as an extra chapter in the ebook's TOC

Automatic TOC generation

Following this proof-of-concept recipe, it is possible to automatically create an ePub and a working TOC from a couple of HTML files. The trick this time is to:

1. Find out which files need to be copied in the skeleton
2. generate in one go the manifest, spine and toc tag entries for each chapter
3. insert our changes in the hardcoded toc.ncx and content.opf 

Assignment

No assignment for the next session, we want you to start working on your trimester's final project. The last epub hacking session will address the problems or questions you have in the form of group or individual tutorials.