Permalink
Browse files

moving to static site generation so i can use github.io

  • Loading branch information...
1 parent 3d7b9e9 commit 72e3d1b8a8fcca4f6da3c16bff806a672ede4408 @themadcreator committed Mar 24, 2014
Showing with 150 additions and 40,350 deletions.
  1. +1 −0 .gitignore
  2. +79 −20 Cakefile
  3. 0 dist/{ → 0.1.0}/seen.coffee
  4. 0 dist/{ → 0.1.0}/seen.js
  5. +1 −0 dist/0.1.0/seen.js.map
  6. 0 dist/{ → 0.1.0}/seen.min.js
  7. +1 −0 dist/latest
  8. +0 −1 dist/seen.js.map
  9. +0 −506 docs/docco/docco.css
  10. BIN docs/docco/public/fonts/aller-bold.eot
  11. BIN docs/docco/public/fonts/aller-bold.ttf
  12. BIN docs/docco/public/fonts/aller-bold.woff
  13. BIN docs/docco/public/fonts/aller-light.eot
  14. BIN docs/docco/public/fonts/aller-light.ttf
  15. BIN docs/docco/public/fonts/aller-light.woff
  16. BIN docs/docco/public/fonts/novecento-bold.eot
  17. BIN docs/docco/public/fonts/novecento-bold.ttf
  18. BIN docs/docco/public/fonts/novecento-bold.woff
  19. +0 −375 docs/docco/public/stylesheets/normalize.css
  20. +0 −4,514 docs/docco/seen.html
  21. +2 −1 package.json
  22. +0 −12 site/lib/coffee-script.min.js
  23. +0 −8,783 site/lib/d3.js
  24. +0 −1 site/lib/highlight.pack.js
  25. +0 −153 site/lib/highlightjs-default.css
  26. +0 −149 site/lib/highlightjs-monokai-sublime.css
  27. +0 −1,177 site/lib/jquery-ui.css
  28. +0 −15,003 site/lib/jquery-ui.js
  29. +0 −9,597 site/lib/jquery.js
  30. 0 {docs → site/markdown}/guide.md
  31. 0 {docs → site/markdown}/release-notes.md
  32. +6 −6 site/markdowns.coffee
  33. +20 −0 site/options.coffee
  34. +4 −3 site/views/demo-material-gallery.html
  35. +2 −2 site/views/demo-multi-views.html
  36. +1 −1 site/views/demo-noisy-patch.html
  37. +1 −1 site/views/demo-noisy-sphere.html
  38. +0 −19 site/views/demo-simple-static.html
  39. +0 −1 site/views/demo-svg-canvas.html
  40. +6 −4 site/views/demo-template.html
  41. +15 −13 site/views/index.html
  42. +6 −3 site/views/markdown-template.html
  43. +2 −2 site/views/snippets/code-block.html
  44. +3 −3 site/views/snippets/demo-nav.html
View
@@ -1,3 +1,4 @@
.DS_Store
node_modules
*.log
+site-dist
View
@@ -1,3 +1,10 @@
+fs = require 'fs'
+_ = require 'lodash'
+path = require 'path'
+{exec} = require 'child_process'
+UglifyJS = require 'uglify-js'
+CoffeeScript = require 'coffee-script'
+packageJson = require './package.json'
DISTS = {
'seen.js' : [
@@ -26,20 +33,18 @@ DISTS = {
]
}
+DIST = path.join(__dirname, 'dist', packageJson.version)
+SITE_DIST = path.join(__dirname, 'site-dist')
+
# =======
# TASKS
# =======
-fs = require 'fs'
-path = require 'path'
-{exec} = require 'child_process'
-UglifyJS = require 'uglify-js'
-CoffeeScript = require 'coffee-script'
-
task 'build', 'Build and uglify seen', () ->
# Prepare output path
if not fs.existsSync(path.join(__dirname, 'dist')) then fs.mkdirSync(path.join(__dirname, 'dist'))
+ if not fs.existsSync(DIST) then fs.mkdirSync(DIST)
license = fs.readFileSync(path.join(__dirname, 'LICENSE.md'), 'utf-8')
license = license.split('\n').join('\n# ')
@@ -50,29 +55,83 @@ task 'build', 'Build and uglify seen', () ->
# Concat all coffeescript together for Docco
coffeeCode = sources.map((source) -> fs.readFileSync(source, 'utf-8')).join('\n\n')
coffeeCode = "\n\n# #{license}\n\n" + coffeeCode
- fs.writeFileSync path.join(__dirname, 'dist', javascript.replace(/\.js$/, '.coffee')), coffeeCode, {flags: 'w'}
- console.log "Joined."
+ fs.writeFileSync path.join(DIST, javascript.replace(/\.js$/, '.coffee')), coffeeCode, {flags: 'w'}
+ console.log ' Joined.'
# Compile to javascript
jsCode = CoffeeScript.compile coffeeCode
- fs.writeFileSync path.join(__dirname, 'dist', javascript), jsCode, {flags: 'w'}
- console.log "Compiled."
+ fs.writeFileSync path.join(DIST, javascript), jsCode, {flags: 'w'}
+ console.log ' Compiled.'
# Uglify
- ugly = UglifyJS.minify path.join(__dirname, 'dist', javascript),
+ ugly = UglifyJS.minify path.join(DIST, javascript),
outSourceMap : "#{javascript}.map"
- fs.writeFileSync path.join(__dirname, 'dist', javascript.replace(/\.js$/,'.min.js')), ugly.code, {flags: 'w'}
- fs.writeFileSync path.join(__dirname, 'dist', "#{javascript}.map"), ugly.map, {flags: 'w'}
+ fs.writeFileSync path.join(DIST, javascript.replace(/\.js$/,'.min.js')), ugly.code, {flags: 'w'}
+ fs.writeFileSync path.join(DIST, "#{javascript}.map"), ugly.map, {flags: 'w'}
+ console.log ' Minified.'
+
+ latest = path.join(__dirname, 'dist', 'latest')
+ exec("rm #{latest}; ln -s #{DIST} #{latest}")
+ console.log ' Symlinked.'
+
+task 'site', 'Build seen website', (options) ->
+ swig = require 'swig'
+ marked = require 'marked'
+ highlight = require 'highlight.js'
+ demos = require './site/demos'
+ markdowns = require './site/markdowns'
+ pageOptions = require './site/options'
+
+ renderPage = (filename, view, opts) ->
+ opts = _.defaults(opts, pageOptions)
+ opts.version = packageJson.version
+ page = swig.renderFile path.join(__dirname, 'site', 'views', "#{view}.html"), opts
+ fs.writeFileSync(path.join(SITE_DIST, "#{filename}.html"), page)
+
+ # Prepare output path
+ if not fs.existsSync(SITE_DIST) then fs.mkdirSync(SITE_DIST)
+ exec("rm -rf #{SITE_DIST}/*", (err) -> throw err if err)
+
+ # Copy static resources
+ for resource in ['lib', 'css', 'assets']
+ exec("cp -rf site/#{resource} #{SITE_DIST}/#{resource}", (err) -> throw err if err)
+ exec("cp dist/latest/seen.min.js #{SITE_DIST}/lib/.", (err) -> throw err if err)
+ console.log 'Copied static resources'
+
+ # Generate docco
+ script = path.join('node_modules' , '.bin', 'docco')
+ exec("#{script} --output #{SITE_DIST}/docco dist/latest/seen.coffee", (err) -> throw err if err)
+
+ # Demo pages
+ for demo, i in demos then do (demo, i) ->
+ demo.prev = demos[i - 1]
+ demo.next = demos[i + 1]
+ renderPage(demo.view, demo.view, demo)
+ console.log "Rendered '#{demo.title}' demo"
+
+ # Markdowned pages
+ renderer = new marked.Renderer()
+ renderer.code = (code, lang, escaped) ->
+ highlighted = highlight.highlight(lang, code).value
+ return """<pre><code class="hljs #{lang}">#{highlighted}</code></pre>"""
+ marked.setOptions(renderer : renderer)
+ markdowns.forEach (markdown) ->
+ content = fs.readFileSync path.join(__dirname, 'site', markdown.path), {encoding : 'UTF-8'}
+ renderPage(markdown.route, 'markdown-template',
+ title : markdown.title
+ markdown : marked(content)
+ scripts : [pageOptions.cdns.highlightjs.script]
+ styles : pageOptions.styles.concat [pageOptions.cdns.highlightjs.style]
+ )
+ console.log "Rendered '#{markdown.title}' markdown"
+
+ # Index page
+ renderPage 'index', 'index', {demos}
+ console.log 'Rendered index'
+
- console.log "Minified."
-task 'docs', 'Build seen documentation', (options) ->
- for javascript, sources of DISTS
- coffee = path.join('dist', javascript.replace(/\.js$/, '.coffee'))
- script = path.join('node_modules' , '.bin', 'docco')
- exec("#{script} --output docs/docco #{coffee}", (err) -> throw err if err)
- console.log "Documented."
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
File renamed without changes.
View
View
Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 72e3d1b

Please sign in to comment.