diff options
Diffstat (limited to 'lib/generate/site/index.js')
-rw-r--r-- | lib/generate/site/index.js | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index 4d8803e..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,20 +30,38 @@ 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( - this.plugins.template("site:page") || path.resolve(this.options.theme, 'templates/book/page.html') + this.plugins.template("site:page") || path.resolve(this.options.theme, 'templates/website/page.html') ); this.langsTemplate = swig.compileFile( - this.plugins.template("site:langs") || path.resolve(this.options.theme, 'templates/book/langs.html') + this.plugins.template("site:langs") || path.resolve(this.options.theme, 'templates/website/langs.html') ); this.glossaryTemplate = swig.compileFile( - this.plugins.template("site:glossary") || path.resolve(this.options.theme, 'templates/book/glossary.html') + this.plugins.template("site:glossary") || path.resolve(this.options.theme, 'templates/website/glossary.html') ); }; @@ -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, @@ -154,12 +175,12 @@ Generator.prototype.convertFile = function(content, _input) { if (_output == "README.html") _output = "index.html"; var output = path.join(this.options.output, _output); var basePath = path.relative(path.dirname(output), this.options.output) || "."; - + // Bug fix for issue #493 which would occur when relative-links are 2-level or more deep in win32 if (process.platform === 'win32') { basePath = basePath.replace(/\\/g, '/'); } - + return this.prepareFile(content, _input) .then(function(page) { // Index page in search |