diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2014-08-11 09:42:18 -0700 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@gmail.com> | 2014-08-11 09:42:18 -0700 |
commit | d216661f2743385ea760b9993fdd46968e37ee42 (patch) | |
tree | de00bb67ffe5728f6175beb1ee0328354aa4f624 /lib/generate/manifest.js | |
parent | 74f95f4d0d404e6df533d056a5acab60623407c8 (diff) | |
parent | 50dfee99b6880da4be442bd43f475ae87a565c46 (diff) | |
download | gitbook-d216661f2743385ea760b9993fdd46968e37ee42.zip gitbook-d216661f2743385ea760b9993fdd46968e37ee42.tar.gz gitbook-d216661f2743385ea760b9993fdd46968e37ee42.tar.bz2 |
Merge pull request #403 from GitbookIO/version/1.0.0
Version 1.0.0
Diffstat (limited to 'lib/generate/manifest.js')
-rw-r--r-- | lib/generate/manifest.js | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/lib/generate/manifest.js b/lib/generate/manifest.js deleted file mode 100644 index 8bb826a..0000000 --- a/lib/generate/manifest.js +++ /dev/null @@ -1,72 +0,0 @@ -var _ = require('lodash'); -var path = require('path'); -var Q = require('q'); - -var fs = require("./fs"); - -var extsToIgnore = [".gz"] - -var Manifest = function() { - this.revision = 0; - this.clear(Date.now()); -}; - -// Regenerate manifest -Manifest.prototype.clear = function(revision) { - if (revision) this.revision = revision; - this.sections = { - 'CACHE': {}, - 'NETWORK': {}, - 'FALLBACK': {} - }; - return Q(this); -}; - -// Add a resource -Manifest.prototype.add = function(category, resource, value) { - if (_.isArray(resource)) { - _.each(resource, function(subres) { - this.add(category, subres, value); - }, this); - return; - } - this.sections[category][resource] = value; -}; - -// Add a directory in cache -Manifest.prototype.addFolder = function(folder, root, except) { - var that = this; - root = root || "/"; - - return fs.list(folder) - .then(function(files) { - _.each( - // Ignore diretcories - _.filter(files, function(file) { - return file.substr(-1) != "/" && !_.contains(except, path.join(root, file)) && !_.contains(extsToIgnore, path.extname(file)); - }), - function(file) { - that.add("CACHE", path.join(root, file)); - } - ); - }) -}; - -// Get manifest content -Manifest.prototype.dump = function() { - var lines = [ - "CACHE MANIFEST", - "# Revision "+this.revision - ]; - - _.each(this.sections, function(content, section) { - if (_.size(content) == 0) return; - lines.push(""); - lines.push(section+":"); - lines = lines.concat(_.keys(content)); - }, this); - - return Q(lines.join("\n")); -}; - -module.exports = Manifest; |