Those who have seen my ePUB uploads probably know that I like to supply a set of files (index.html, index.xhtml, index.css) that allow to view the uncompressed ePUB in a web browser, with a frames layout. I create these files by hand (with extensive copy&paste) for every project, but I thought that I could also try to write a script or something that would create them automatically, and be useful for reading any ePUB.
There already exist something similar (
epubjs), but I wanted it simpler. So, this is my try. It is a bash script (so it works on Linux, maybe on OS X, and you'd need a Cygwin environment for Windows, I guess) that uncompresses an ePUB file to a temporary directory, creates the index.* files, outputs the path of the index.html (so you can paste it in your browser) and waits; when you press <Enter>, it deletes the temporary directory, and everything is as it was before.
Some features:
The left frame has a list of all files in the <spine> in order (with their "id" as names), files with "linear=no" are marked with an asterisk. At the top there are four arrow links, clicking on "<" or ">" moves to the previous or next file in the book (skipping entries with asterisks), "<<<" and ">>>" are the first and last files. You can click on any file in the list, and the "<" and ">" links work as expected (but they don't if you follow links in the main book frame). If you click on the red "TOC", the left frame view should change to the TOC instead of the <spine>, but it's not implemented yet
After any change in the main book frame, the index.css file (which is defined inside the script) is applied on top of the normal CSS files of the ePUB, that means text size and layout can change, and anchors may not be as expected (this probably depends on the browser).
For the future I'd like to implement the TOC properly, and I'd also like to make it work directly from the browser, as a sort of CGI script, but I'm afraid it's not possible without installing a local web server, and that's not what I want.
Disclaimer: I tried to make the script safe and clean, but I'm no expert programmer, I basically learn along as I try new things. The script was only tried in Linux, with the Opera browser, and with the ePUB files I have created... I hope it will work in other cases, but there's no guarantee.
By the way, just run the script as:
Code:
./epub-read.sh Some_book.epub
EDIT: There was a (possibly serious) bug in the previous version, which had been downloaded once, I had "rm -r $TMPDIR" instead of "rm -r $TEMPDIR". It's corrected now.
For the latest version, see
post #12