diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-03-09 10:43:12 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-03-09 10:43:12 +0100 |
commit | 34fc2831e0cf0fed01c71cec28d93472d87f455b (patch) | |
tree | a803cc907c20491ba02863b5d3dd5aedf6bfed10 /lib/generate/generator.js | |
parent | e1594cde2c32e4ff48f6c4eff3d3d461743d74e1 (diff) | |
parent | 1bf68a5aa0703b5a1815cfe4ebb731b5fb6ed9d2 (diff) | |
download | gitbook-34fc2831e0cf0fed01c71cec28d93472d87f455b.zip gitbook-34fc2831e0cf0fed01c71cec28d93472d87f455b.tar.gz gitbook-34fc2831e0cf0fed01c71cec28d93472d87f455b.tar.bz2 |
Merge branch 'version/2.0'
Diffstat (limited to 'lib/generate/generator.js')
-rw-r--r-- | lib/generate/generator.js | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/lib/generate/generator.js b/lib/generate/generator.js deleted file mode 100644 index 4791c98..0000000 --- a/lib/generate/generator.js +++ /dev/null @@ -1,87 +0,0 @@ -var _ = require("lodash"); -var path = require("path"); -var Q = require("q"); -var fs = require("./fs"); - -var Plugin = require("./plugin"); - -var BaseGenerator = function(options) { - this.options = options; - - // Base for assets in plugins - this.pluginAssetsBase = "book"; - - this.options.plugins = Plugin.normalizeNames(this.options.plugins); - this.options.plugins = _.union(this.options.plugins, this.options.defaultsPlugins); - this.plugins = []; -}; - -BaseGenerator.prototype.callHook = function(name, data) { - return this.plugins.hook(name, data); -}; - -// Sets up generator -BaseGenerator.prototype.load = function() { - return this.loadPlugins(); -}; - -BaseGenerator.prototype.loadPlugins = function() { - var that = this; - - return Plugin.fromList(this.options.plugins, this.options.input, this, { - assetsBase: this.pluginAssetsBase - }) - .then(function(_plugins) { - that.plugins = _plugins; - - return that.callHook("init"); - }); -}; - -BaseGenerator.prototype.convertFile = function(content, input) { - return Q.reject(new Error("Could not convert "+input)); -}; - -BaseGenerator.prototype.transferFile = function(input) { - return fs.copy( - path.join(this.options.input, input), - path.join(this.options.output, input) - ); -}; - -BaseGenerator.prototype.transferFolder = function(input) { - return fs.mkdirp( - path.join(this.options.output, input) - ); -}; - -BaseGenerator.prototype.copyCover = function() { - var that = this; - - return Q.all([ - fs.copy(path.join(this.options.input, "cover.jpg"), path.join(this.options.output, "cover.jpg")), - fs.copy(path.join(this.options.input, "cover_small.jpg"), path.join(this.options.output, "cover_small.jpg")) - ]) - .fail(function() { - // If orignally from multi-lang, try copy from originalInput - if (!that.options.originalInput) return; - - return Q.all([ - fs.copy(path.join(that.options.originalInput, "cover.jpg"), path.join(that.options.output, "cover.jpg")), - fs.copy(path.join(that.options.originalInput, "cover_small.jpg"), path.join(that.options.output, "cover_small.jpg")) - ]); - }) - .fail(function(err) { - return Q(); - }); -}; - -BaseGenerator.prototype.langsIndex = function(langs) { - return Q.reject(new Error("Langs index is not supported in this generator")); -}; - -BaseGenerator.prototype.finish = function() { - return Q.reject(new Error("Could not finish generation")); -}; - -module.exports = BaseGenerator; |