summaryrefslogtreecommitdiffstats
path: root/lib/generators/website.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-09-15 13:57:21 +0200
committerSamy Pessé <samypesse@gmail.com>2015-09-15 13:57:21 +0200
commit5a205346e3d125b1c834220ce98a206d88697811 (patch)
tree47700546d3b7a3e484975e37b1bb06e7efa88b92 /lib/generators/website.js
parente1930046599d430a6bb378af62bce78fb9d24ff7 (diff)
downloadgitbook-5a205346e3d125b1c834220ce98a206d88697811.zip
gitbook-5a205346e3d125b1c834220ce98a206d88697811.tar.gz
gitbook-5a205346e3d125b1c834220ce98a206d88697811.tar.bz2
Jshint all files
Diffstat (limited to 'lib/generators/website.js')
-rw-r--r--lib/generators/website.js35
1 files changed, 15 insertions, 20 deletions
diff --git a/lib/generators/website.js b/lib/generators/website.js
index 675092f..4bde473 100644
--- a/lib/generators/website.js
+++ b/lib/generators/website.js
@@ -10,7 +10,6 @@ var FilterExtension = require("nunjucks-filter")(nunjucks);
var fs = require("../utils/fs");
var BaseGenerator = require("../generator");
var links = require("../utils/links");
-var pageUtil = require("../utils/page");
var i18n = require("../utils/i18n");
var pkg = require("../../package.json");
@@ -64,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();
};
@@ -98,13 +97,13 @@ Generator.prototype.prepareTemplateEngine = function() {
// Add filter
that.env.addFilter("contentLink", that.book.contentLink.bind(that.book));
- that.env.addFilter('lvl', function(lvl) {
+ 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));
});
};
@@ -114,7 +113,7 @@ Generator.prototype.finish = function() {
.then(this.copyCover)
.then(this.writeGlossary)
.then(this.writeSearchIndex)
- .then(this.writeLangsIndex)
+ .then(this.writeLangsIndex);
};
// Convert an input file
@@ -135,11 +134,11 @@ Generator.prototype.convertFile = function(input) {
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, '/');
+ if (process.platform === "win32") basePath = basePath.replace(/\\/g, "/");
that.book.log.debug.ln("write parsed file", page.path, "to", relativeOutput);
- return that._writeTemplate(that.templates["page"], {
+ return that._writeTemplate(that.templates.page, {
progress: page.progress,
_input: page.path,
@@ -153,27 +152,23 @@ Generator.prototype.convertFile = function(input) {
// Write the index for langs
Generator.prototype.writeLangsIndex = function() {
- var that = this;
if (!this.book.langs.length) return Q();
- return this._writeTemplate(this.templates["langs"], {
+
+ return this._writeTemplate(this.templates.langs, {
langs: this.book.langs
}, path.join(this.options.output, "index.html"));
};
// Write glossary
Generator.prototype.writeGlossary = function() {
- var that = this;
-
// No glossary
- if (this.book.glossary.length == 0) return Q();
+ 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"));
};
// Write the search index
Generator.prototype.writeSearchIndex = function() {
- var that = this;
-
return fs.writeFile(
path.join(this.options.output, "search_index.json"),
JSON.stringify(this.book.searchIndex)
@@ -207,7 +202,7 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
interpolate = interpolate || _.identity;
return Q()
- .then(function(sections) {
+ .then(function() {
return that.env.render(
tpl,
_.extend({
@@ -239,7 +234,7 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
basePath: ".",
staticBase: path.join(".", "gitbook"),
- '__': that.book.i18n.bind(that.book)
+ "__": that.book.i18n.bind(that.book)
}, options)
);
})