summaryrefslogtreecommitdiffstats
path: root/lib/generate
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-01-14 22:19:40 +0100
committerSamy Pessé <samypesse@gmail.com>2015-01-14 22:19:40 +0100
commit3382f1b0840a7759508357acf88d770f2c5bcaf2 (patch)
tree56f1041ae643392e44a6053b4354152a9bd3a7b5 /lib/generate
parent7d90cd2a9ea729566118f617f0d5674a02d04652 (diff)
downloadgitbook-3382f1b0840a7759508357acf88d770f2c5bcaf2.zip
gitbook-3382f1b0840a7759508357acf88d770f2c5bcaf2.tar.gz
gitbook-3382f1b0840a7759508357acf88d770f2c5bcaf2.tar.bz2
Include styles in website format
Diffstat (limited to 'lib/generate')
-rw-r--r--lib/generate/fs.js1
-rw-r--r--lib/generate/page/index.js4
-rw-r--r--lib/generate/site/index.js21
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,