diff options
author | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-07-30 10:17:06 -0700 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-07-30 10:17:07 -0700 |
commit | 4705548860452cb3e2c0b1532cb04977d8712f27 (patch) | |
tree | 75dd530cdb6b0e5ba32d0e0a2e0f2bd3bb6d4855 /lib/generate | |
parent | 7d51ae36897ef7035bbc901bd9b4fc03038b074a (diff) | |
download | gitbook-4705548860452cb3e2c0b1532cb04977d8712f27.zip gitbook-4705548860452cb3e2c0b1532cb04977d8712f27.tar.gz gitbook-4705548860452cb3e2c0b1532cb04977d8712f27.tar.bz2 |
Fix resource normalization in when loading plugins
Fixes #384
Diffstat (limited to 'lib/generate')
-rw-r--r-- | lib/generate/plugin.js | 22 | ||||
-rw-r--r-- | lib/generate/site/index.js | 4 |
2 files changed, 21 insertions, 5 deletions
diff --git a/lib/generate/plugin.js b/lib/generate/plugin.js index ff94483..ca34923 100644 --- a/lib/generate/plugin.js +++ b/lib/generate/plugin.js @@ -65,7 +65,7 @@ Plugin.prototype.normalizeResource = function(resource) { }; // Return resources -Plugin.prototype.getResources = function() { +Plugin.prototype._getResources = function() { var book = this.infos.book; // Nothing specified, fallback to default @@ -80,7 +80,24 @@ Plugin.prototype.getResources = function() { } // Plain data object - return Q(book); + return Q(_.cloneDeep(book)); +}; + +// Normalize resources and return them +Plugin.prototype.getResources = function() { + var that = this; + + + + return this._getResources() + .then(function(resources) { + + _.each(RESOURCES, function(resourceType) { + resources[resourceType] = (resources[resourceType] || []).map(that.normalizeResource); + }); + + return resources; + }); }; // Test if it's a valid plugin @@ -165,7 +182,6 @@ Plugin.normalizeNames = function(names) { // Extract data from a list of plugin Plugin.fromList = function(names, root, generator) { - var that = this; var failed = []; // Load plugins diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index bd1da53..73765ae 100644 --- a/lib/generate/site/index.js +++ b/lib/generate/site/index.js @@ -202,12 +202,12 @@ Generator.prototype.copyAssets = function() { return plugin.copyAssets(pluginAssets) .then(function(copiedStuff) { // Nothing was copied - if(!copiedStuff) return; + if(!copiedStuff) { return; } return that.manifest.addFolder(pluginAssets, "gitbook/plugins/"+plugin.name); }); }) ); - }) + }); }; // Dump search index to disk |