I want to publish things in chunks that are bigger and more logical than blog posts, so I’ve been experimenting with my ZIP/PDF/EPUB/MOBI workflow.
Org Mode, Calibre, and Vagrant are terrific tools. Org Mode lets me write easy-to-modify source that I can export to different formats, like HTML and LaTeX (with the Beamer package), which lets me use PdfLatex to convert to PDF. Calibre converts HTML to EPUB and MOBI. Since tools can be difficult to set up on Windows, I use Vagrant to set up a virtual machine running Linux and I share my working directory with it.
multiple-cursors was so useful when I was wrangling the directory listing into the right format for Org. I’m glad I learned how to use it!
Here’s a Makefile I put together that simplifies the process for me:
all: index.html sketched-books.epub sketched-books.mobi ebook.pdf sketched-books.zip
rm -f *.dvi *.log *.nav *.out *.tex *.snm *.toc
rm -f Sketched\ Books.zip index.html *.epub *.pdf *.mobi
Sketched\ Books.zip: *.png index.html
(cd ..; zip sketched-books/sketched-books.zip sketched-books/* -i *.css -i *.png -i *.html)
emacs --batch -l build.el index.org -f org-html-export-to-html --kill
cp index.html index.tmp
sed -e "s/org-ul/org-ul small-block-grid-3/" -e 's/div id="content"/div id="content" class="columns"/' -e 's/class="status"/class="status columns"/' index.tmp > index.html
rm -f index.html~ index.tmp
emacs --batch -l build.el ebook.org -f org-html-export-to-html --kill
montage *Sketched*.png -geometry -30-30 -thumbnail x400 -tile 6x5 cover.png
ebook-convert ebook.html sketched-books.epub --cover cover.png --authors "Sacha Chua" --language "English"
ebook-convert ebook.html sketched-books.mobi --cover cover.png --authors "Sacha Chua" --language "English"
emacs --batch -l build.el ebook.org -f org-beamer-export-to-latex --kill
cp ebook.pdf sketched-books.pdf
And here’s a very simple build.el:
(setq org-html-validation-link nil)
(setq org-export-with-section-numbers nil)
(setq backup-directory-alist '(("." . nil)))
This assumes I’ve already set up the environment by installing the latest Org from MELPA.
You can check out the index.org and ebook.org I use, too.
I’m not quite sure about the MOBI output yet. I have to test it on a Kindle, or in the app on my tablet. Most of the things display fine on my computer, though. Hooray!
Neat, huh? I want to get into the habit of making and also making it easy for me to update these things. You can check out the results at http://sketchedbooks.com/collection .
Someday I might even figure out how to use the Gumroad API to publish updated resources automatically. Wouldn’t that be neat? In the meantime, I’ll just have to replace them myself.
I like giving people the ability to choose which files to download. If I get annoyed with replacing multiple files, though, I might change this to one large ZIP that has the images, PDF, EPUB, and MOBI.
View the source on Github