diff options
Diffstat (limited to 'lib/generate/site/index.js')
-rw-r--r-- | lib/generate/site/index.js | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index 4bea547..68328e7 100644 --- a/lib/generate/site/index.js +++ b/lib/generate/site/index.js @@ -30,13 +30,28 @@ var Generator = function() { this.revision = Date.now(); this.indexer = indexer(); - - // Load base template - this.template = swig.compileFile(path.resolve(this.options.theme, 'templates/site.html')); - this.langsTemplate = swig.compileFile(path.resolve(this.options.theme, 'templates/langs.html')); }; util.inherits(Generator, BaseGenerator); +// Load all templates +Generator.prototype.loadTemplates = function() { + this.template = swig.compileFile( + this.plugins.template("site") || path.resolve(this.options.theme, 'templates/site.html') + ); + this.langsTemplate = swig.compileFile( + this.plugins.template("langs") || path.resolve(this.options.theme, 'templates/langs.html') + ); +}; + +// Load plugins +Generator.prototype.loadPlugins = function() { + var that = this; + + return BaseGenerator.prototype.loadPlugins.apply(this) + .then(function() { + return that.loadTemplates(); + }); +}; // Generate a template Generator.prototype._writeTemplate = function(tpl, options, output) { @@ -54,7 +69,10 @@ Generator.prototype._writeTemplate = function(tpl, options, output) { githubHost: that.options.githubHost, summary: that.options.summary, - allNavigation: that.options.navigation + allNavigation: that.options.navigation, + + plugins: that.plugins, + pluginsConfig: JSON.stringify(that.options.pluginsConfig) }, options)); }) .then(function(html) { @@ -134,10 +152,19 @@ Generator.prototype.langsIndex = function(langs) { Generator.prototype.copyAssets = function() { var that = this; + // Copy gitbook assets return fs.copy( path.join(that.options.theme, "assets"), path.join(that.options.output, "gitbook") - ); + ) + // Copy plugins assets + .then(function() { + return Q.all( + _.map(that.plugins.list, function(plugin) { + return plugin.copyAssets(path.join(that.options.output, "gitbook/plugins/", plugin.name)) + }) + ); + }) }; // Dump search index to disk |