0.5
---
- Discovered the jar: protocol works in Firefox. No need for my own
  "zip filesystem". Can discard much Unix code! Syntax is
     jar:file:///dir/file.epub!/ etc ("!/" is end-of-filename)
  See http://kaioa.com/node/99 for security discussion 
  i.e. it's ok if local, must have application/java-archive mime
  type otherwise
	
	
0.4
---
- XP_UNIX is defined in nspr/prcpucfg.h which is included by nspr/prtypes.h
  which is included by moz-sdk/nsapi.h. I guess the Windows versions define
  _WINDOWS etc

- Wrote my own "zip httpd" server. This is started to deliver files out
  of an epub file


0.3
---
- But I can't start a server for every epub doc! So just start
  one. (If one is already running, the call to bozohttpd will just fail).

0.2
---
- security issue with asking FF to load a local URL when the original
  comes from the network. Resolved by calling a local http server to
  deliver the pages. Used bozohttp as this is small.

0.1
---

Getting epub compiled
- started with original diamondx example from ...
- renamed diamondx files to epub
- edited epub.h to change DIAMOND_H to EPUB_H
- changed MIME TYPE to application/epub+zip
- changed /etc/mimetypes to use .epub as extension for this type
- edited Makefile.am and configure.ac to change diamondx to epub
- ran autoreconf to rebuild build system
- then ./configure, make
- use make install-plugin to copy .so to ~/.mozilla/plugins
- this installed my plugin and showed the diamondX screen

Getting a known epub document downloaded and one chapter shown
- edited npshell.c to uncomment calls to NP_NewStream so I could detect loading of stream
- added NP_NewStream to epub.c
- added code to NP_NewStream, NP_WriteReady and NP_Write to copy the stream to a local file
- used system("unzip...") to unpack it
- used NPN_GetURL to load a (hardcoded) file from the OEBPS/html
- found API reference on http://docs.rinet.ru/Plugi/ch10.htm#NPN_GetURLandNPN_PostURL
- Used NPN_GetURL to load a file from the OEBPS/html directory

Building a stylesheet for content.opf
- on http://davidwalsh.name/firefox-internal-rendering-css there is a pointer to html.css as default rendered for HTML. That file plus others is on /usr/lib/xulrunner-1.9.0.11/res on my machine. Removing those made a mess of firefox, so those are the default stylesheets
- OPF has its own name space. To match XSLT patterns against this need to use namespace matching. Found out how in http://msdn.microsoft.com/en-us/library/ms950779.aspx#Mtps_DropDownFilterText. Basically, declare opf namespace, then use "opf:manifest", etc
- OPF uses id and idref labels for X-referencing from the contents order in <spine> to URLs in <manifest>. but we can't use the id() function since there is no DTD/schema in the OPF. Used key() instead.
- stylesheet completed after much sweat :-). Ended up buying "XSLT" by Doug Tidwell and that helped a lot.

All together
- Created a wrapper XML that just includes stylesheet and toplevel file
- Put all the bits together and it worked!
- Lots of tidying up to be done

Tests
Works on
- Peter Hamilton, Temporal Void: commercial book from Pan Macmillan
- Alexander Dumas, Ten Years Later: free epub from http://www.epubbooks.com/book/54/dumas-ten-years-later.epub
- Others from epubbooks:
  - fitzgerald-tales-of-the-jazz-age
  - montgomery-anne-of-green-gables.epub

As at 10/07/2009 does NOT work on
- Either of the two sample OCF (.epub) files on the official IDPF site!
  These are  listed on page http://www.idpf.org/forums/viewtopic.php?t=18&sid=50385826f24148e19da3c83bf7905404 and are
    www.ebooktechnologies.com/downloads/ocf10-20060911.epub
    www.ebooktechnologies.com/downloads/Thoughts.epub
- henry-give-me-liberty-or-give-me-death.epub from epubbooks

  None of these documents have conforming OPF files!
  All of the OPF files are missing the XML namespace declaration
    xmlns="http://www.idpf.org/2007/opf"
  required by Open Packaging Format (OPF) 2.0 v0.9871.0, section 1.3.2:
    "The namespace for the OPF Package Document is 
    http://www.idpf.org/2007/opf, and must be declared 
    at the root of all OPF Package Documents."
  I could duplicate all XSLT templates to look for no namespace (DUH!!!)
  or label the documents as broken.
