Permalink
Browse files

[ux] Generate books using pandoc

  • Loading branch information...
1 parent 9b8c3f7 commit 3c76a707c43cecef4427beb5ef884c434782390b @jfhbrook jfhbrook committed Aug 18, 2012
Showing with 99 additions and 1,226 deletions.
  1. +94 −68 Makefile
  2. +1 −1,154 book.html
  3. +2 −2 book.md
  4. BIN book.pdf
  5. +2 −2 chapters/hello_world.md
  6. BIN fig/jitsu.png
  7. BIN fig/login.png
View
162 Makefile
@@ -2,100 +2,98 @@
# https://github.com/visionmedia/masteringnode
#
+# used with pdf generator tool. TODO: Replace with pandoc.
PDF_FLAGS = --fontsize 9.0 \
--linkstyle plain \
--linkcolor blue \
--embedfonts \
--footer "c 1" \
--no-toc
+# Pages that make up the full text (in markdown)
MD = pages/title.md \
- chapters/toc.md \
- chapters/introduction.md \
- chapters/hello_world.md \
- chapters/platform_features.md \
- chapters/jitsu.md \
- chapters/web_admin.md \
- chapters/json_api.md \
- chapters/haibu.md \
- chapters/open_source_projects.md \
- chapters/faq.md \
- chapters/support.md \
- appendices/toc.md \
- appendices/package.json.md \
- appendices/resources.md \
- appendices/building_the_handbook.md
-
-README = pages/title.md \
- chapters/toc.readme.md \
- chapters/introduction.md \
- chapters/hello_world.md \
- chapters/platform_features.md \
- chapters/jitsu.md \
- chapters/web_admin.md \
- chapters/json_api.md \
- chapters/haibu.md \
- chapters/open_source_projects.md \
- chapters/faq.md \
- chapters/support.md
-
+ chapters/toc.md \
+ chapters/introduction.md \
+ chapters/hello_world.md \
+ chapters/platform_features.md \
+ chapters/jitsu.md \
+ chapters/web_admin.md \
+ chapters/json_api.md \
+ chapters/haibu.md \
+ chapters/open_source_projects.md \
+ chapters/faq.md \
+ chapters/support.md \
+ appendices/toc.md \
+ appendices/package.json.md \
+ appendices/resources.md \
+ appendices/building_the_handbook.md
+
+# An abridged version of the handbook
+README = pages/title.md \
+ chapters/toc.readme.md \
+ chapters/introduction.md \
+ chapters/hello_world.md \
+ chapters/platform_features.md \
+ chapters/jitsu.md \
+ chapters/web_admin.md \
+ chapters/json_api.md \
+ chapters/haibu.md \
+ chapters/open_source_projects.md \
+ chapters/faq.md \
+ chapters/support.md
+
+# Just the API docs
API = chapters/json_api.md
+# HTML files (generated by ronn)
HTML = $(MD:.md=.html)
-all: book.html book.pdf book.md ReadMe.md API.md website clear
+# We use make with sed to implement microtemplating so that we may
+# use multiple folders/sources for images as needed.
+# SEE: book.md ReadMe.md API.md %.html
+GITHUB_FIG = https://raw.github.com/nodejitsu/handbook/master/fig
+LOCAL_FIG = fig
-regenerate: clean all
- git commit -a -m '[dist] Regenerated handbook' && echo done
-
-publish: clean all
- git commit -am '[dist] Regenerated handbook'
- git push origin master
- ./bin/deploy.sh
+all: book.html book.pdf book.md ReadMe.md API.md website clear
-book.pdf: $(HTML)
+book.md:
@echo "\n... generating $@"
- htmldoc --webpage -f $@ $(PDF_FLAGS) $(HTML)
+ cat $(MD) \
+ | sed "s {{fig}} $(GITHUB_FIG) " \
+ > book.md
-book.md: $(HTML)
+ReadMe.md:
@echo "\n... generating $@"
- cat $(MD) > book.md
+ cat $(README) \
+ | sed "s {{fig}} $(GITHUB_FIG) " \
+ > ReadMe.md
-ReadMe.md: $(HTML)
+API.md:
@echo "\n... generating $@"
- cat $(README) > ReadMe.md
+ cat $(API) \
+ | sed "s {{fig}} $(GITHUB_FIG) " \
+ > API.md
-API.md: $(HTML)
+book.html: pages/head.html pages/tail.html book.md
@echo "\n... generating $@"
- cat $(API) > API.md
+ echo `cat pages/head.html` \
+ `cat pandoc -t html book.md` \
+ `cat pages/tail.html` \
+ > book.html
-book.html: pages/head.html pages/tail.html $(HTML)
+# TODO: Use pandoc and latex instead of htmldoc
+book.pdf:
@echo "\n... generating $@"
- @echo $(HTML)
- cat pages/head.html $(HTML) pages/tail.html > book.html
-
-public:
- mkdir public
-
-website: book.html public
- @echo "\n... copying items into ./public"
- cp book.html public/index.html
- cp book.pdf public/book.pdf
- cp -r fig public/fig
-
-serve: website
- @echo "\n... serving website!"
- node ./bin/server
-
-%.html: %.md
- ronn --pipe --fragment $< \
- | sed -r 's/<h1>([^ ]+) - /<h1>/' \
- > $@
+ cat $(MD) \
+ | sed "s {{fig}} $(LOCAL_FIG) " \
+ | pandoc -f markdown -o book.pdf
+# .mobi version
book.mobi:
@echo "\n... generating $@"
ebook-convert book.html book.mobi --output-profile kindle
+# .epub version
book.epub:
@echo "\n... generating $@"
ebook-convert book.html book.epub \
@@ -105,8 +103,27 @@ book.epub:
--language en \
--cover pages/cover.jpg
-view: book.pdf
- open book.pdf
+# Assemble our "website" bundle (move things into public folder, etc.)
+website: book.html public
+ @echo "\n... copying items into ./public"
+ cp book.html public/index.html
+ cp book.pdf public/book.pdf
+ cp -r fig public/fig
+
+public:
+ mkdir public
+
+# Regenerate handbook, commit
+regenerate: clean all
+ git commit -a -m '[dist] Regenerated handbook'
+
+# Push code changes to github and nodejitsu
+publish: regenerate
+ git push origin master
+ if [ "nodejitsu" != $(jitsu whoami) ]; then
+ jitsu login --username nodejitsu
+ fi
+ jitsu deploy
clean:
rm -f book.*
@@ -122,4 +139,13 @@ clear:
rm -f pages/index.html
rm -f pages/title.html
+# TODO: Fall back to evince
+view: book.pdf
+ open book.pdf || evince book.pdf
+
+serve: website
+ @echo "\n... serving website!"
+ node ./bin/server
+
+# TODO: Do I need this? Unsure.
.PHONY: view clean regenerate
Oops, something went wrong.

0 comments on commit 3c76a70

Please sign in to comment.