Tuesday, August 9, 2011

Kindle Mobi Start Page (no worky)

‹prev | My Chain | next›

Up today, I would like to see if I can get the mobi version of The SPDY Book to start on the correct page. Currently, it opens at the very beginning of the book—before the copyright notice, before the table of contents, before the acknowledgements. I would prefer that the reader be taken directly to the Introduction upon opening the book on the Kindle.

The first thing that I try is adding a "start" page to the book.opf file:
<guide>
<reference type="toc" title="Table of Contents" href="toc.html"></reference>
  <reference type="start" title="Startup Page" href="book.html#_introduction"></reference>
<reference type="text" title="Contents" href="book.html"></reference>
</guide>
Several sources seem to suggest that this will work however, when I delete the file from within the Kindle, mount the Kindle via USB, transfer a new mobi to the Kindle and open the replacement, I still start on the very first page.

Next up, I try fiddling with the book.ncx file. When generating that file (which puts markers on the Kindle's progress meter at the bottom of the page), git-scribe had been creating an entry for all headers in the book, including the copyright, etc. I try starting the NCX build only after the Introduction is reached:
chapters = 0
toc.each do |section|
  ch = section['section']
  next unless (chapters > 0 || ch['name'].to_s =~ /Introduction/i)

  chapters += 1
  ncx.puts('<navPoint class="chapter" id="chapter_' + chapters.to_s + '" playOrder="' + (chapters).to_s + '">')
...
That produces an NCX navmap that looks like:
<navMap>
<navPoint class="chapter" id="chapter_1" playOrder="1">
  <navLabel><text>Introduction</text></navLabel>
  <content src="book.html#_introduction"/>
</navPoint>
<navPoint class="chapter" id="chapter_2" playOrder="2">
  <navLabel><text>1. Who Should Read This Book?</text></navLabel>
  <content src="book.html#_who_should_read_this_book"/>
</navPoint>
....
That looks better (though the IDs are wrong). Sadly, I am still greeted by the very first page rather than the Introduction when I open the replacement. I am able to get to the Introduction by right-arrowing on the D-pad, but the reader should not have to know to do that.

I will call it a night at this point. Up tomorrow, I will see if correct IDs help in any way (or if I can think of anything else to check). Otherwise I may have to live with a sub-optimal start page on the Kindle.


Day #109

No comments:

Post a Comment