summaryrefslogtreecommitdiffstats
path: root/lib/generators
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-01-21 19:51:35 +0100
committerSamy Pessé <samypesse@gmail.com>2015-01-21 19:51:35 +0100
commit3d8db17bc35d22ae514805ded1a4dd12ae968b60 (patch)
treeb35bdd95dc73824e00838d64aaea8c96cafbd2b4 /lib/generators
parent3c605ea8099bcba58d8eeb0435d87c563d434e46 (diff)
downloadgitbook-3d8db17bc35d22ae514805ded1a4dd12ae968b60.zip
gitbook-3d8db17bc35d22ae514805ded1a4dd12ae968b60.tar.gz
gitbook-3d8db17bc35d22ae514805ded1a4dd12ae968b60.tar.bz2
Copy theme assets to output
Diffstat (limited to 'lib/generators')
-rw-r--r--lib/generators/site.js40
1 files changed, 31 insertions, 9 deletions
diff --git a/lib/generators/site.js b/lib/generators/site.js
index cd63bbe..4999de9 100644
--- a/lib/generators/site.js
+++ b/lib/generators/site.js
@@ -19,11 +19,8 @@ var Generator = function() {
// revision
this.revision = new Date();
- // Style to integrates i nthe output
+ // Style to integrates in the output
this.styles = ["website"];
-
- // base folder for templates
- this.templatesRoot = path.resolve(__dirname, "../../theme/templates/website")
};
util.inherits(Generator, BaseGenerator);
@@ -57,9 +54,9 @@ Generator.prototype.prepareStyles = function() {
// Prepare template engine
Generator.prototype.prepareTemplates = function() {
- this.pageTemplate = this.plugins.template("site:page") || path.resolve(this.templatesRoot, 'page.html');
- this.langsTemplate = this.plugins.template("site:langs") || path.resolve(this.templatesRoot, 'langs.html');
- this.glossaryTemplate = this.plugins.template("site:glossary") || path.resolve(this.templatesRoot, 'glossary.html');
+ this.pageTemplate = this.plugins.template("site:page") || path.resolve(this.options.theme, 'templates/website/page.html');
+ this.langsTemplate = this.plugins.template("site:langs") || path.resolve(this.options.theme, 'templates/website/langs.html');
+ this.glossaryTemplate = this.plugins.template("site:glossary") || path.resolve(this.options.theme, 'templates/website/glossary.html');
var folders = _.chain(
[
@@ -92,9 +89,10 @@ Generator.prototype.transferFile = function(input) {
};
-
+// Finis generation
Generator.prototype.finish = function() {
-
+ return this.copyAssets()
+ .then(this.copyCover)
};
// Normalize a link to .html and convert README -> index
@@ -191,4 +189,28 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
});
};
+
+// Copy assets
+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) {
+ var pluginAssets = path.join(that.options.output, "gitbook/plugins/", plugin.name);
+ return plugin.copyAssets(pluginAssets, {
+ base: that.pluginAssetsBase
+ });
+ })
+ );
+ });
+};
+
module.exports = Generator;