diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-21 11:43:39 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-21 11:43:39 +0100 |
commit | b5d7e7966f52386486998299e2f96116ca9cef27 (patch) | |
tree | 9d123e71c36e3705b75caf456b1870ba891f3eee | |
parent | be2da0fab1c467f84c33517950d67da3c9b5768d (diff) | |
download | gitbook-b5d7e7966f52386486998299e2f96116ca9cef27.zip gitbook-b5d7e7966f52386486998299e2f96116ca9cef27.tar.gz gitbook-b5d7e7966f52386486998299e2f96116ca9cef27.tar.bz2 |
Fix site generator polluting basegenerator
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | lib/generators/site.js | 30 | ||||
-rw-r--r-- | lib/utils/fs.js | 1 | ||||
-rw-r--r-- | test/generation.js | 4 |
4 files changed, 25 insertions, 11 deletions
@@ -6,6 +6,7 @@ GitBook ChangeLog with 1.0.0: - Hooks `summary` and `glossary` (after and before) have been removed +- Add support for AsciiDoc - Exercises and Quizzes are no longer parsed in the markdown parser - You can now also use the `.markdown` extension for markdown files - Templates are rendered with nunjucks instead of swig, syntax is almost compatible, there is some changes with contexts and filters. diff --git a/lib/generators/site.js b/lib/generators/site.js index 4ce34e2..c8b9e91 100644 --- a/lib/generators/site.js +++ b/lib/generators/site.js @@ -12,6 +12,9 @@ var pageUtil = require("../utils/page"); var Generator = function() { BaseGenerator.apply(this, arguments); + // revision + this.revision = new Date(); + // Style to integrates i nthe output this.styles = ["website"]; @@ -21,20 +24,20 @@ var Generator = function() { util.inherits(Generator, BaseGenerator); // Prepare the genertor -BaseGenerator.prototype.load = function() { +Generator.prototype.prepare = function() { var that = this; - return BaseGenerator.prototype.load.apply(this) + return BaseGenerator.prototype.prepare.apply(this) .then(function() { - return that.loadStyles(); + return that.prepareStyles(); }) .then(function() { - return that.loadTemplates(); + return that.prepareTemplates(); }); }; -// Load all styles -Generator.prototype.loadStyles = function() { +// Prepare all styles +Generator.prototype.prepareStyles = function() { var that = this; this.styles = _.chain(this.styles) .map(function(style) { @@ -48,8 +51,8 @@ Generator.prototype.loadStyles = function() { .value(); }; -// Load template engine -Generator.prototype.loadTemplates = 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, 'templates/website/glossary.html'); @@ -86,8 +89,17 @@ Generator.prototype.finish = function() { // Convert an input file Generator.prototype.writeParsedFile = function(page) { - var output = links.changeExtension(page.path, ".json"); + var that = this; + + var output = links.changeExtension(page.path, ".html"); output = path.join(that.options.output, output); + + return that.normalizePage(page) + .then(function() { + return that._writeTemplate(that.pageTemplate, { + + }, output); + }); }; // Write the index for langs diff --git a/lib/utils/fs.js b/lib/utils/fs.js index 8f04435..8a5d4e4 100644 --- a/lib/utils/fs.js +++ b/lib/utils/fs.js @@ -87,5 +87,6 @@ module.exports = { fs.exists(path, d.resolve); return d.promise; }, + existsSync: fs.existsSync.bind(fs), readFileSync: fs.readFileSync.bind(fs) }; diff --git a/test/generation.js b/test/generation.js index fc4f604..d2d0574 100644 --- a/test/generation.js +++ b/test/generation.js @@ -49,9 +49,9 @@ describe('Book generation', function () { }, done); }); - /*it('should correctly generate a book to website', function(done) { + it('should correctly generate a book to website', function(done) { testGeneration(book1, "site", function(output) { assert(fs.existsSync(path.join(output, "index.html"))); }, done); - });*/ + }); }); |