diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-20 02:04:15 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-20 02:04:15 +0200 |
commit | 878c105def7ee73648a79019311730a662c11144 (patch) | |
tree | 83fe542865cfe80ae95579274147b04a049b8d7a | |
parent | 74d628676b3d5a49b0f461261ba39c6839557410 (diff) | |
download | gitbook-878c105def7ee73648a79019311730a662c11144.zip gitbook-878c105def7ee73648a79019311730a662c11144.tar.gz gitbook-878c105def7ee73648a79019311730a662c11144.tar.bz2 |
Use complete assets folder for plugins
-rw-r--r-- | lib/generate/plugin.js | 16 | ||||
-rw-r--r-- | lib/generate/site/index.js | 9 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | theme/templates/site.html | 4 |
4 files changed, 17 insertions, 13 deletions
diff --git a/lib/generate/plugin.js b/lib/generate/plugin.js index 77bbee5..d1becd4 100644 --- a/lib/generate/plugin.js +++ b/lib/generate/plugin.js @@ -2,7 +2,6 @@ var _ = require("lodash"); var Q = require("q"); var semver = require("semver"); var path = require("path"); -var crc = require('crc'); var fs = require("./fs"); var pkg = require("../../package.json"); @@ -44,8 +43,7 @@ Plugin.prototype.getResources = function(resource) { return _.chain(this.infos.book[resource]) .map(function(resource) { return { - "path": this.resolveFile(resource), - "id": crc.hex32(crc.crc32(resource)) + "path": this.name+"/"+resource } }.bind(this)) .value(); @@ -80,6 +78,18 @@ Plugin.prototype.callHook = function(name, args) { }); }; +// Copy plugin assets fodler +Plugin.prototype.copyAssets = function(out) { + if (!this.infos.book || !this.infos.book.assets) return Q(); + return fs.copy( + this.resolveFile(this.infos.book.assets), + out + ); +}; + + + + // Normalize a list of plugin name to use Plugin.normalizeNames = function(names) { // Normalize list to an array diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index eaba6ee..809a7fc 100644 --- a/lib/generate/site/index.js +++ b/lib/generate/site/index.js @@ -159,13 +159,8 @@ Generator.prototype.copyAssets = function() { // Copy plugins assets .then(function() { return Q.all( - _.map(that.plugins.resources, function(resources, resourceType) { - return Q.all(_.map(resources, function(resource) { - return fs.copy( - resource.path, - path.join(that.options.output, "gitbook/plugins/", resource.id+"."+resourceType) - ); - })); + _.map(that.plugins.list, function(plugin) { + return plugin.copyAssets(path.join(that.options.output, "gitbook/plugins/", plugin.name)) }) ); }) diff --git a/package.json b/package.json index 782f515..686bbb7 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "highlight.js": "8.0.0", "tmp": "0.0.23", "semver": "2.2.1", - "crc": "0.2.1", "gitbook-plugin": "0.0.1", "gitbook-plugin-mixpanel": "0.0.1" diff --git a/theme/templates/site.html b/theme/templates/site.html index 5e5bfb2..ef74bd2 100644 --- a/theme/templates/site.html +++ b/theme/templates/site.html @@ -39,13 +39,13 @@ {% block javascript %} {% parent %} {% for resource in plugins.resources.js %} -<script src="{{ staticBase }}/plugins/{{ resource.id }}.js"></script> +<script src="{{ staticBase }}/plugins/{{ resource.path }}"></script> {% endfor %} {% endblock %} {% block style %} {% parent %} {% for resource in plugins.resources.css %} -<link rel="stylesheet" href="{{ staticBase }}/plugins/{{ resource.id }}.css"> +<link rel="stylesheet" href="{{ staticBase }}/plugins/{{ resource.path }}"> {% endfor %} {% endblock %} |