summaryrefslogtreecommitdiffstats
path: root/lib/generators/website.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-10-06 14:21:02 +0200
committerSamy Pessé <samypesse@gmail.com>2015-10-06 14:21:02 +0200
commit321b24a7b9e7bcdb786ea25c4e1ae481a8796a2b (patch)
tree6b6bf6bb5ec72a5c1d622aef579cb555a837df30 /lib/generators/website.js
parent22e0c1fb54f1ffb632e7c155978929fa185b932c (diff)
downloadgitbook-321b24a7b9e7bcdb786ea25c4e1ae481a8796a2b.zip
gitbook-321b24a7b9e7bcdb786ea25c4e1ae481a8796a2b.tar.gz
gitbook-321b24a7b9e7bcdb786ea25c4e1ae481a8796a2b.tar.bz2
Don't copy assets for ebook to website bundle
Diffstat (limited to 'lib/generators/website.js')
-rw-r--r--lib/generators/website.js76
1 files changed, 38 insertions, 38 deletions
diff --git a/lib/generators/website.js b/lib/generators/website.js
index e1a3cce..18ec65d 100644
--- a/lib/generators/website.js
+++ b/lib/generators/website.js
@@ -1,18 +1,18 @@
-var util = require("util");
-var path = require("path");
-var Q = require("q");
-var _ = require("lodash");
+var util = require('util');
+var path = require('path');
+var Q = require('q');
+var _ = require('lodash');
-var nunjucks = require("nunjucks");
-var AutoEscapeExtension = require("nunjucks-autoescape")(nunjucks);
-var FilterExtension = require("nunjucks-filter")(nunjucks);
+var nunjucks = require('nunjucks');
+var AutoEscapeExtension = require('nunjucks-autoescape')(nunjucks);
+var FilterExtension = require('nunjucks-filter')(nunjucks);
-var fs = require("../utils/fs");
-var BaseGenerator = require("../generator");
-var links = require("../utils/links");
-var i18n = require("../utils/i18n");
+var fs = require('../utils/fs');
+var BaseGenerator = require('../generator');
+var links = require('../utils/links');
+var i18n = require('../utils/i18n');
-var pkg = require("../../package.json");
+var pkg = require('../../package.json');
var Generator = function() {
BaseGenerator.apply(this, arguments);
@@ -21,10 +21,10 @@ var Generator = function() {
this.revision = new Date();
// Resources namespace
- this.namespace = "website";
+ this.namespace = 'website';
// Style to integrates in the output
- this.styles = ["website"];
+ this.styles = ['website'];
// Convert images (svg -> png)
this.convertImages = false;
@@ -63,9 +63,9 @@ Generator.prototype.prepareStyles = function() {
// Prepare templates
Generator.prototype.prepareTemplates = function() {
- this.templates.page = this.book.plugins.template("site:page") || path.resolve(this.options.theme, "templates/website/page.html");
- this.templates.langs = this.book.plugins.template("site:langs") || path.resolve(this.options.theme, "templates/website/langs.html");
- this.templates.glossary = this.book.plugins.template("site:glossary") || path.resolve(this.options.theme, "templates/website/glossary.html");
+ this.templates.page = this.book.plugins.template('site:page') || path.resolve(this.options.theme, 'templates/website/page.html');
+ this.templates.langs = this.book.plugins.template('site:langs') || path.resolve(this.options.theme, 'templates/website/langs.html');
+ this.templates.glossary = this.book.plugins.template('site:glossary') || path.resolve(this.options.theme, 'templates/website/glossary.html');
return Q();
};
@@ -79,7 +79,7 @@ Generator.prototype.prepareTemplateEngine = function() {
var language = that.book.config.normalizeLanguage();
if (!i18n.hasLocale(language)) {
- that.book.log.warn.ln("Language '"+language+"' is not available as a layout locales (en, "+i18n.getLocales().join(", ")+")");
+ that.book.log.warn.ln('Language "'+language+'" is not available as a layout locales (en, '+i18n.getLocales().join(', ')+')');
}
var folders = _.chain(that.templates)
@@ -96,14 +96,14 @@ Generator.prototype.prepareTemplateEngine = function() {
);
// Add filter
- that.env.addFilter("contentLink", that.book.contentLink.bind(that.book));
- that.env.addFilter("lvl", function(lvl) {
- return lvl.split(".").length;
+ that.env.addFilter('contentLink', that.book.contentLink.bind(that.book));
+ that.env.addFilter('lvl', function(lvl) {
+ return lvl.split('.').length;
});
// Add extension
- that.env.addExtension("AutoEscapeExtension", new AutoEscapeExtension(that.env));
- that.env.addExtension("FilterExtension", new FilterExtension(that.env));
+ that.env.addExtension('AutoEscapeExtension', new AutoEscapeExtension(that.env));
+ that.env.addExtension('FilterExtension', new FilterExtension(that.env));
});
};
@@ -122,20 +122,20 @@ Generator.prototype.convertFile = function(input) {
return that.book.parsePage(input, {
convertImages: that.convertImages,
interpolateTemplate: function(page) {
- return that.callHook("page:before", page);
+ return that.callHook('page:before', page);
},
interpolateContent: function(page) {
- return that.callHook("page", page);
+ return that.callHook('page', page);
}
})
.then(function(page) {
var relativeOutput = that.book.contentPath(page.path);
var output = path.join(that.options.output, relativeOutput);
- var basePath = path.relative(path.dirname(output), that.options.output) || ".";
- if (process.platform === "win32") basePath = basePath.replace(/\\/g, "/");
+ var basePath = path.relative(path.dirname(output), that.options.output) || '.';
+ if (process.platform === 'win32') basePath = basePath.replace(/\\/g, '/');
- that.book.log.debug.ln("write parsed file", page.path, "to", relativeOutput);
+ that.book.log.debug.ln('write parsed file', page.path, 'to', relativeOutput);
return that._writeTemplate(that.templates.page, {
progress: page.progress,
@@ -144,7 +144,7 @@ Generator.prototype.convertFile = function(input) {
content: page.sections,
basePath: basePath,
- staticBase: links.join(basePath, "gitbook")
+ staticBase: links.join(basePath, 'gitbook')
}, output);
});
};
@@ -155,7 +155,7 @@ Generator.prototype.writeLangsIndex = function() {
return this._writeTemplate(this.templates.langs, {
langs: this.book.langs
- }, path.join(this.options.output, "index.html"));
+ }, path.join(this.options.output, 'index.html'));
};
// Write glossary
@@ -163,7 +163,7 @@ Generator.prototype.writeGlossary = function() {
// No glossary
if (this.book.glossary.length === 0) return Q();
- return this._writeTemplate(this.templates.glossary, {}, path.join(this.options.output, "GLOSSARY.html"));
+ return this._writeTemplate(this.templates.glossary, {}, path.join(this.options.output, 'GLOSSARY.html'));
};
// Convert a page into a normalized data set
@@ -180,7 +180,7 @@ Generator.prototype.normalizePage = function(page) {
return Q()
.then(function() {
- return _callHook("page");
+ return _callHook('page');
})
.then(function() {
return page;
@@ -222,10 +222,10 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
options: that.options,
- basePath: ".",
- staticBase: path.join(".", "gitbook"),
+ basePath: '.',
+ staticBase: path.join('.', 'gitbook'),
- "__": that.book.i18n.bind(that.book)
+ '__': that.book.i18n.bind(that.book)
}, options)
);
})
@@ -244,15 +244,15 @@ Generator.prototype.copyAssets = function() {
// Copy gitbook assets
return fs.copy(
- path.join(that.options.theme, "assets"),
- path.join(that.options.output, "gitbook")
+ path.join(that.options.theme, 'assets/'+this.namespace),
+ path.join(that.options.output, 'gitbook')
)
// Copy plugins assets
.then(function() {
return Q.all(
_.map(that.book.plugins.list, function(plugin) {
- var pluginAssets = path.join(that.options.output, "gitbook/plugins/", plugin.name);
+ var pluginAssets = path.join(that.options.output, 'gitbook/plugins/', plugin.name);
return plugin.copyAssets(pluginAssets, that.namespace);
})
);