Permalink
Browse files

Convert to markdown, upgrade to responsive layout and markdown-styles

1 parent 4fa4a82 commit b8c0a313ead0fb0de4329a3405c82dd8c3a9ea30 @mixu committed Sep 25, 2015
Showing with 20,204 additions and 5,530 deletions.
  1. +2 −0 .gitignore
  2. +47 −0 Makefile
  3. +15 −0 bin/remove-meta.js
  4. +0 −35 bookgen/extras.html
  5. +0 −108 bookgen/generate.js
  6. +0 −55 generate.js
  7. 0 {content → input}/assets/Drawing1.xml
  8. BIN {content → input}/assets/Thumbs.db
  9. BIN {content → input}/assets/dependencies.png
  10. BIN {content → input}/assets/document-code.png
  11. BIN {content → input}/assets/document-pdf.png
  12. 0 {content → input}/assets/dom.graphml
  13. BIN {content → input}/assets/dom.png
  14. BIN {content → input}/assets/e-book-reader-black.png
  15. BIN {content → input}/assets/e-book-reader.png
  16. BIN {content → input}/assets/es6-proxies.png
  17. BIN {content → input}/assets/fig31.gif
  18. BIN {content → input}/assets/gmail_collapse.png
  19. BIN {content → input}/assets/gmail_displaydensity.png
  20. BIN {content → input}/assets/gmail_stars.png
  21. BIN input/assets/image.png
  22. BIN {content → input}/assets/js-dom.pptx
  23. 0 {content → input}/assets/model-detail.graphml
  24. BIN {content → input}/assets/model-detail.png
  25. BIN {content → input}/assets/model-view.png
  26. BIN {content → input}/assets/modularity.png
  27. BIN {content → input}/assets/modularityandsimplicity.pptx
  28. 0 {content → input}/assets/mv.graphml
  29. 0 {content → input}/assets/overview.graphml
  30. BIN {content → input}/assets/overview.png
  31. 0 {content → input}/assets/pileofpoo.graphml
  32. BIN {content → input}/assets/pileofpoo.png
  33. +52 −0 input/assets/prettify.css
  34. +28 −0 input/assets/prettify.js
  35. +71 −0 input/assets/prettify_coffee.css
  36. +35 −0 input/assets/runner.js
  37. BIN input/assets/spa-book-cover.png
  38. BIN {content → input}/assets/tdd.png
  39. BIN {content → input}/assets/tdd.pptx
  40. BIN {content → input}/assets/test_double.png
  41. BIN {content → input}/assets/trees.png
  42. BIN {content → input}/assets/view-approaches.png
  43. BIN {content → input}/assets/view-approaches.pptx
  44. BIN input/assets/webkitflow.png
  45. +352 −0 input/collections1.md
  46. +242 −0 input/collections2.md
  47. +181 −0 input/collections3.md
  48. +110 −0 input/collections4.md
  49. +71 −0 input/collections5.md
  50. +283 −0 input/detail1.md
  51. +58 −0 input/detail2.md
  52. +141 −0 input/goal.md
  53. +38 −0 input/index.md
  54. +414 −0 input/maintainability1.md
  55. +108 −0 input/maintainability2.md
  56. +414 −0 input/maintainability3.md
  57. +199 −0 input/views1.md
  58. +169 −0 input/views2.md
  59. +178 −0 input/views3.md
  60. BIN layout/.DS_Store
  61. BIN layout/assets/.DS_Store
  62. +10 −0 layout/assets/assert.css
  63. BIN layout/assets/fonts/.DS_Store
  64. +93 −0 layout/assets/fonts/OFL.txt
  65. BIN layout/assets/fonts/droidsansmono-webfont.eot
  66. +243 −0 layout/assets/fonts/droidsansmono-webfont.svg
  67. BIN layout/assets/fonts/droidsansmono-webfont.ttf
  68. BIN layout/assets/fonts/droidsansmono-webfont.woff
  69. BIN layout/assets/fonts/droidsansmono-webfont.woff2
  70. BIN layout/assets/fonts/lora-regular-webfont.eot
  71. +4,322 −0 layout/assets/fonts/lora-regular-webfont.svg
  72. BIN layout/assets/fonts/lora-regular-webfont.ttf
  73. BIN layout/assets/fonts/lora-regular-webfont.woff
  74. BIN layout/assets/fonts/lora-regular-webfont.woff2
  75. +218 −0 layout/assets/hljs-github.min.css
  76. +18 −0 layout/assets/jquery-1.6.1.min.js
  77. +42 −0 layout/assets/pilcrow.css
  78. +25 −0 layout/assets/snippet.css
  79. +769 −0 layout/assets/style.css
  80. +53 −0 layout/assets/sunburst.css
  81. +77 −0 layout/highlighters/inline-snippet.js
  82. +22 −0 layout/highlighters/lib/get-each-rule-declaration-values.js
  83. +15 −0 layout/highlighters/lib/get-first-rule-dimensions.js
  84. +11 −0 layout/highlighters/lib/hl.js
  85. +31 −0 layout/highlighters/lib/rename-css-classes.js
  86. +10 −0 layout/highlighters/lib/rename-html-classes.js
  87. +53 −0 layout/highlighters/lib/row-scale.js
  88. +10 −0 layout/highlighters/problem.js
  89. +65 −0 layout/highlighters/snippet-matrix.js
  90. +33 −0 layout/highlighters/snippet.js
  91. +11 −0 layout/highlighters/spoiler.js
  92. +132 −0 layout/page.html
  93. +0 −10 layouts/default/header.hdbs
  94. +93 −0 output/assets/fonts/OFL.txt
  95. BIN output/assets/fonts/droidsansmono-webfont.eot
  96. +243 −0 output/assets/fonts/droidsansmono-webfont.svg
  97. BIN output/assets/fonts/droidsansmono-webfont.ttf
  98. BIN output/assets/fonts/droidsansmono-webfont.woff
  99. BIN output/assets/fonts/droidsansmono-webfont.woff2
  100. BIN output/assets/fonts/lora-regular-webfont.eot
  101. +4,322 −0 output/assets/fonts/lora-regular-webfont.svg
  102. BIN output/assets/fonts/lora-regular-webfont.ttf
  103. BIN output/assets/fonts/lora-regular-webfont.woff
  104. BIN output/assets/fonts/lora-regular-webfont.woff2
  105. +218 −0 output/assets/hljs-github.min.css
  106. +42 −0 output/assets/pilcrow.css
  107. +25 −0 output/assets/snippet.css
  108. +414 −68 output/assets/style.css
  109. +153 −237 output/collections1.html
  110. +100 −156 output/collections2.html
  111. +134 −238 output/collections3.html
  112. +87 −180 output/collections4.html
  113. +77 −136 output/collections5.html
  114. +137 −290 output/detail1.html
  115. +77 −128 output/detail2.html
  116. +96 −176 output/goal.html
  117. +88 −132 output/index.html
  118. +243 −438 output/maintainability1.html
  119. +83 −160 output/maintainability2.html
  120. +211 −375 output/maintainability3.html
  121. +1,210 −1,974 output/single-page.html
  122. +2,349 −0 output/single.html
  123. +115 −225 output/views1.html
  124. +108 −181 output/views2.html
  125. +105 −225 output/views3.html
  126. +3 −3 package.json
View
@@ -1 +1,3 @@
node_modules/
+tmp/
+.DS_Store
View
@@ -1,3 +1,37 @@
+book: concat
+ generate-md \
+ --layout ./layout \
+ --input ./input \
+ --output ./output
+
+.PHONY: book
+
+concat:
+ rm -rf ./tmp || true
+ mkdir ./tmp
+ cat input/index.md > ./tmp/single.md
+ cat input/goal.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/maintainability1.md | bin/remove-meta.js>> ./tmp/single.md
+ cat input/maintainability2.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/maintainability3.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/detail1.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/detail2.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/collections1.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/collections2.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/collections3.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/collections4.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/collections5.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/views1.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/views2.md | bin/remove-meta.js >> ./tmp/single.md
+ cat input/views3.md | bin/remove-meta.js >> ./tmp/single.md
+ generate-md \
+ --input ./tmp/single.md \
+ --layout ./layout \
+ --output ./output
+ cp ./output/single.html ./output/single-page.html
+
+.PHONY: concat
+
book.mobi:
@echo "\n... generating $@"
ebook-convert output/single-page.html output/mixu-single-page-apps.mobi \
@@ -9,6 +43,8 @@ book.mobi:
--language en \
--output-profile kindle
+.PHONY: book.mobi
+
book.epub:
@echo "\n... generating $@"
ebook-convert output/single-page.html output/mixu-single-page-apps.epub \
@@ -19,3 +55,14 @@ book.epub:
--authors "Mikito Takada" \
--no-default-epub-cover \
--language en
+
+.PHONY: book.epub
+
+upload:
+ aws s3 sync ./output/ s3://singlepageappbook.com/ \
+ --region us-west-1 \
+ --delete \
+ --exclude "node_modules/*" \
+ --exclude ".git"
+
+.PHONY: upload
View
@@ -0,0 +1,15 @@
+#!/usr/bin/env node
+var md = require('markdown-stream-utils'),
+ pi = require('pipe-iterators');
+
+process.stdin.setEncoding('utf8');
+
+process.stdin
+ .pipe(pi.reduce(function(obj, current) {
+ obj.contents += current;
+ return obj;
+ }, { content: '' }))
+ .pipe(md.parseHeader())
+ .pipe(pi.map(function(obj) { return obj.contents; }))
+ .pipe(process.stdout);
+
View
@@ -1,35 +0,0 @@
- <p><img src="assets/e-book-reader-black.png">
- <a href="http://singlepageappbook.com/mixu-single-page-apps.mobi" style="color: gray;"> .mobi (Kindle)</a>
- </p>
- <p><img src="assets/e-book-reader.png">
- <a href="http://singlepageappbook.com/mixu-single-page-apps.epub" style="color: gray;">epub</a>
- </p>
- <p><img src="assets/document-code.png">
- <a href="http://singlepageappbook.com/single-page.html" style="color: gray;">Single page HTML</a>
- </p>
- <p><img src="assets/document-pdf.png">
- <a href="http://www.printfriendly.com/print/v2?url=http://singlepageappbook.com/single-page.html" style="color: gray;">PDF</a>
- </p>
- <p><img src="assets/image.png">
- <a href="assets/spa-book-cover.png" style="color: gray;">book cover</a>
- </p>
-
-<br>
-<hr>
-<br>
-
-<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fsinglepageappbook.com%2F&amp;send=false&amp;layout=button_count&amp;width=250&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:250px; height:21px;" allowTransparency="true"></iframe>
-
-<br>
-
-<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://singlepageappbook.com/" data-text="Single page apps in depth" data-via="mikitotakada">Tweet</a>
-<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
-<br>
-
-<br>
-<hr>
-<br>
-
-<p style="color: gray;"><a href="http://mixu.net" style="color: gray;">Who wrote this?</a></p>
-
-<p style="color: gray;">My <a href="http://book.mixu.net" style="color: gray;">other book is about Node.js</a></p>
View
@@ -1,108 +0,0 @@
-var fs = require('fs'),
- path = require('path'),
- util = require('util'),
- handlebars = require('handlebars');
-
-
-var BookGen = function() { };
-
-BookGen.generate = function(config) {
- // get all the files in input
- if(!Array.isArray(config.input.files)) {
- // iterate the path and add all files
- fs.readdir(config.input.files, function (err, files) {
- if (err) throw err;
- BookGen.processFiles(config, files);
- });
- } else {
- BookGen.processFiles(config, config.input.files);
- }
-};
-
-BookGen.processFiles = function(config, files) {
- // load the layout
- var header = handlebars.compile(
- fs.readFileSync(config.layout + 'header.hdbs').toString()
- ),
- header_single = handlebars.compile(
- fs.readFileSync(config.layout + 'header_single.hdbs').toString()
- ),
- footer = handlebars.compile(
- fs.readFileSync(config.layout + 'footer.hdbs').toString()
- );
-
- if(config.input.order == 'sort') {
- // sort the files
- files.sort();
- }
- if(config.input.index) {
- // move the index file first
- var pos = files.indexOf(config.input.index);
- if(pos > -1) {
- files.splice(pos, 1);
- files.unshift(config.input.index);
- }
- }
-
- // concatenate the files
- console.log(files);
-
- var prev = 'index.html';
- var full = '';
- files.forEach(function(name, index) {
- if(path.extname(name) != '.html') {
- return;
- }
- var next;
- for(var i = index+1; path.extname(next) != '.html' && i < files.length; i++) {
- next = path.basename(files[i]) || 'index.html';
- }
- var content = fs.readFileSync(name);
- content = content.toString().replace(/%chapter_number%/g, index+'.');
-
-
-
- var opts = {
- title: config.titles[path.basename(name) ] || 'Single page apps in depth',
- prev: prev,
- next: next,
- extras: (path.basename(name) == 'index.html' ?
- fs.readFileSync(__dirname +'/extras.html').toString() : '')
- };
- fs.writeFile(config.output+ path.basename(name), header(opts) + content + footer(opts));
- prev = path.basename(name);
-
- full += content;
- })
-
- var opts = {
- title: 'Single page apps in depth (a.k.a. Mixu\' single page app book)',
- prev: '',
- next: '',
- extras: ''
- };
-
- // write a single page version as well
- fs.writeFile(config.output+'single-page.html', header_single(opts)+full+footer(opts));
-
- // copy assets
- BookGen.copyDir(config.layout + 'assets/', config.output + 'assets/');
- BookGen.copyDir(config.input.dir + 'assets/', config.output + 'assets/');
-
-};
-
-BookGen.copyDir = function(src, dst) {
- fs.readdir(src, function(err, files) {
- if (err) throw err;
- files.forEach(function(file) {
- // copy
- // console.log(src, dst, file)
- is = fs.createReadStream(src + file);
- os = fs.createWriteStream(dst + file);
- util.pump(is, os);
- });
- });
-};
-
-
-module.exports = BookGen;
View
@@ -1,55 +0,0 @@
-var BookGen = require('./bookgen/generate.js');
-
-var config = {
- output: __dirname + '/output/',
-
- input: {
-
- dir: __dirname + '/content/',
-
- files: //__dirname + '/content/',
- [
- __dirname + '/content/index.html',
- __dirname + '/content/goal.html',
- __dirname + '/content/maintainability1.html',
- __dirname + '/content/maintainability2.html',
- __dirname + '/content/maintainability3.html',
- __dirname + '/content/detail1.html',
- __dirname + '/content/detail2.html',
- __dirname + '/content/collections1.html',
- __dirname + '/content/collections2.html',
- __dirname + '/content/collections3.html',
- __dirname + '/content/collections4.html',
- __dirname + '/content/collections5.html',
- __dirname + '/content/views1.html',
- __dirname + '/content/views2.html',
- __dirname + '/content/views3.html',
-// __dirname + '/content/epilogue.html'
- ],
-
- index: 'index.html'
- },
-
- titles: {
- 'index.html': 'Single page apps in depth (new free book)',
- 'goal.html': '1. Modern web applications: a overview',
- 'maintainability1.html': '2. Maintainability depends on modularity: Stop using namespaces!',
- 'maintainability2.html': '3. Getting to maintainable',
- 'maintainability3.html': '4. Testing',
- 'detail1.html': '5. What\'s in a View? A look at the alternatives',
- 'detail2.html': '6. The model layer: an overview',
- 'collections1.html': '7. Implementing a data source',
- 'collections2.html': '8. Implementing a model',
- 'collections3.html': '9. Collections',
- 'collections4.html': '10. Implementing a data cache',
- 'collections5.html': '11. Implementing associations: hasOne, hasMany',
- 'views3.html': '12. Views - Templating',
- 'views1.html': '13. Views - Behavior',
- 'views2.html': '14. Consuming events from the model layer'
- },
-
- layout: __dirname + '/layouts/default/'
-
-};
-
-BookGen.generate(config);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
@@ -0,0 +1,52 @@
+/* Pretty printing styles. Used with prettify.js. */
+
+/* SPAN elements with the classes below are added by prettyprint. */
+.pln { color: #000 } /* plain text */
+
+@media screen {
+ .str { color: #080 } /* string content */
+ .kwd { color: #008 } /* a keyword */
+ .com { color: #800 } /* a comment */
+ .typ { color: #606 } /* a type name */
+ .lit { color: #066 } /* a literal value */
+ /* punctuation, lisp open bracket, lisp close bracket */
+ .pun, .opn, .clo { color: #660 }
+ .tag { color: #008 } /* a markup tag name */
+ .atn { color: #606 } /* a markup attribute name */
+ .atv { color: #080 } /* a markup attribute value */
+ .dec, .var { color: #606 } /* a declaration; a variable name */
+ .fun { color: red } /* a function name */
+}
+
+/* Use higher contrast and text-weight for printable form. */
+@media print, projection {
+ .str { color: #060 }
+ .kwd { color: #006; font-weight: bold }
+ .com { color: #600; font-style: italic }
+ .typ { color: #404; font-weight: bold }
+ .lit { color: #044 }
+ .pun, .opn, .clo { color: #440 }
+ .tag { color: #006; font-weight: bold }
+ .atn { color: #404 }
+ .atv { color: #060 }
+}
+
+/* Put a border around prettyprinted code snippets. */
+pre.prettyprint { background: none; font-size: 14px;}
+
+/* Specify class=linenums on a pre to get line numbering */
+ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
+li.L0,
+li.L1,
+li.L2,
+li.L3,
+li.L5,
+li.L6,
+li.L7,
+li.L8 { list-style-type: none }
+/* Alternate shading for lines */
+li.L1,
+li.L3,
+li.L5,
+li.L7,
+li.L9 { background: #eee }
Oops, something went wrong.

0 comments on commit b8c0a31

Please sign in to comment.