diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-19 18:49:02 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-19 18:49:02 +0100 |
commit | 6344928580e521974508d445238c207aecec299b (patch) | |
tree | ecf21b32a777115b4fdec1adbdbd7ec987adbd7d /lib/generator.js | |
parent | 2dbf9b0d4a88a6461ca60f49f3d66ccd42143be3 (diff) | |
download | gitbook-6344928580e521974508d445238c207aecec299b.zip gitbook-6344928580e521974508d445238c207aecec299b.tar.gz gitbook-6344928580e521974508d445238c207aecec299b.tar.bz2 |
Write file in json generator
Diffstat (limited to 'lib/generator.js')
-rw-r--r-- | lib/generator.js | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/generator.js b/lib/generator.js index 32ce3b5..fa6b8b0 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -3,32 +3,40 @@ var path = require("path"); var Q = require("q"); var fs = require("./utils/fs"); -var BaseGenerator = function(book, options) { - this.options = options; +var BaseGenerator = function(book) { + this.book = book; + + Object.defineProperty(this, "options", { + get: function () { + return this.book.options; + } + }); // Base for assets in plugins this.pluginAssetsBase = "book"; }; BaseGenerator.prototype.callHook = function(name, data) { - return this.plugins.hook(name, data); + //return this.plugins.hook(name, data); + return Q(); }; -// Sets up generator +// Prepare the genertor BaseGenerator.prototype.load = function() { - return this.loadPlugins(); + return this.preparePlugins(); }; BaseGenerator.prototype.preparePlugins = function() { var that = this; - }; -BaseGenerator.prototype.convertFile = function(content, input) { +// Write a parsed file to the output +BaseGenerator.prototype.writeParsedFile = function(page, input) { return Q.reject(new Error("Could not convert "+input)); }; +// Copy file to the output (non parsable) BaseGenerator.prototype.transferFile = function(input) { return fs.copy( path.join(this.options.input, input), @@ -36,12 +44,14 @@ BaseGenerator.prototype.transferFile = function(input) { ); }; +// Copy a folder to the output BaseGenerator.prototype.transferFolder = function(input) { return fs.mkdirp( - path.join(this.options.output, input) + path.join(this.book.options.output, input) ); }; +// Copy the cover picture BaseGenerator.prototype.copyCover = function() { var that = this; @@ -63,10 +73,12 @@ BaseGenerator.prototype.copyCover = function() { }); }; +// Generate the langs index BaseGenerator.prototype.langsIndex = function(langs) { return Q.reject(new Error("Langs index is not supported in this generator")); }; +// At teh end of the generation BaseGenerator.prototype.finish = function() { return Q.reject(new Error("Could not finish generation")); }; |