diff options
Diffstat (limited to 'lib/generate')
-rw-r--r-- | lib/generate/fs.js | 1 | ||||
-rw-r--r-- | lib/generate/page/index.js | 4 | ||||
-rw-r--r-- | lib/generate/site/index.js | 21 |
3 files changed, 25 insertions, 1 deletions
diff --git a/lib/generate/fs.js b/lib/generate/fs.js index 50219eb..371051c 100644 --- a/lib/generate/fs.js +++ b/lib/generate/fs.js @@ -87,5 +87,6 @@ module.exports = { fs.exists(path, d.resolve); return d.promise; }, + existsSync: fs.existsSync, readFileSync: fs.readFileSync.bind(fs) }; diff --git a/lib/generate/page/index.js b/lib/generate/page/index.js index a926d13..c5f9420 100644 --- a/lib/generate/page/index.js +++ b/lib/generate/page/index.js @@ -11,6 +11,8 @@ var BaseGenerator = require("../site"); var Generator = function() { BaseGenerator.apply(this, arguments); + this.styles = ["ebook"]; + // Base for assets in plugins this.pluginAssetsBase = "ebook"; @@ -49,7 +51,7 @@ Generator.prototype.finish = function() { var output = path.join(this.options.output, "index.html"); var progress = parse.progress(this.options.navigation, "README.md"); - + return Q() // Write table of contents diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index 94ee6c0..dfdbf68 100644 --- a/lib/generate/site/index.js +++ b/lib/generate/site/index.js @@ -18,6 +18,7 @@ var Generator = function() { // Attach methods to instance _.bindAll(this); + this.styles = ["website"]; this.revision = Date.now(); this.indexer = indexer(); }; @@ -29,10 +30,28 @@ Generator.prototype.load = function() { return BaseGenerator.prototype.load.apply(this) .then(function() { + return that.loadStyles(); + }) + .then(function() { return that.loadTemplates(); }); }; +// Load all styles +Generator.prototype.loadStyles = function() { + var that = this; + this.styles = _.chain(this.styles) + .map(function(style) { + var stylePath = that.options.styles[style]; + if (fs.existsSync(path.resolve(that.options.input, stylePath))) { + return stylePath; + } + return null; + }) + .compact() + .value(); +}; + // Load all templates Generator.prototype.loadTemplates = function() { this.template = swig.compileFile( @@ -54,6 +73,8 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate) return Q() .then(function(sections) { return tpl(_.extend({ + styles: that.styles, + revision: that.revision, title: that.options.title, |