couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ryanram...@apache.org
Subject [25/51] [partial] Restructure to simpler jam/erica style.
Date Sat, 11 May 2013 05:48:38 GMT
http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/bootstrap/docs/build/index.js
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/bootstrap/docs/build/index.js b/src/fauxton/jam/bootstrap/docs/build/index.js
new file mode 100644
index 0000000..1a9cb38
--- /dev/null
+++ b/src/fauxton/jam/bootstrap/docs/build/index.js
@@ -0,0 +1,44 @@
+#!/usr/bin/env node
+var hogan = require('hogan.js')
+  , fs    = require('fs')
+  , prod  = process.argv[2] == 'production'
+  , title = 'Bootstrap'
+
+var layout, pages
+
+// compile layout template
+layout = fs.readFileSync(__dirname + '/../templates/layout.mustache', 'utf-8')
+layout = hogan.compile(layout, { sectionTags: [{o:'_i', c:'i'}] })
+
+// retrieve pages
+pages = fs.readdirSync(__dirname + '/../templates/pages')
+
+// iterate over pages
+pages.forEach(function (name) {
+
+  if (!name.match(/\.mustache$/)) return
+
+  var page = fs.readFileSync(__dirname  + '/../templates/pages/' + name, 'utf-8')
+    , context = {}
+
+  context[name.replace(/\.mustache$/, '')] = 'active'
+  context._i = true
+  context.production = prod
+  context.title = name
+    .replace(/\.mustache/, '')
+    .replace(/\-.*/, '')
+    .replace(/(.)/, function ($1) { return $1.toUpperCase() })
+
+  if (context.title == 'Index') {
+    context.title = title
+  } else {
+    context.title += ' ยท ' + title
+  }
+
+  page = hogan.compile(page, { sectionTags: [{o:'_i', c:'i'}] })
+  page = layout.render(context, {
+    body: page
+  })
+
+  fs.writeFileSync(__dirname + '/../' + name.replace(/mustache$/, 'html'), page, 'utf-8')
+})
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/bootstrap/docs/build/package.json
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/bootstrap/docs/build/package.json b/src/fauxton/jam/bootstrap/docs/build/package.json
new file mode 100644
index 0000000..97ab259
--- /dev/null
+++ b/src/fauxton/jam/bootstrap/docs/build/package.json
@@ -0,0 +1,6 @@
+{
+  "name": "bootstrap-doc-builder"
+, "version": "0.0.1"
+, "description": "build bootstrap docs"
+, "dependencies": { "hogan.js": "1.0.5-dev" }
+}


Mime
View raw message