diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-08-08 18:35:43 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-08-11 07:36:45 -0700 |
commit | d914eae40a9730d76295750ac47ebed9fe4f7146 (patch) | |
tree | ca85886ff5fc64968a8abfe55aa86174a0574310 | |
parent | 74f95f4d0d404e6df533d056a5acab60623407c8 (diff) | |
download | gitbook-d914eae40a9730d76295750ac47ebed9fe4f7146.zip gitbook-d914eae40a9730d76295750ac47ebed9fe4f7146.tar.gz gitbook-d914eae40a9730d76295750ac47ebed9fe4f7146.tar.bz2 |
Remove html5 cache manifest
-rwxr-xr-x | bin/gitbook.js | 1 | ||||
-rw-r--r-- | lib/generate/manifest.js | 72 | ||||
-rw-r--r-- | lib/generate/site/index.js | 35 | ||||
-rw-r--r-- | theme/templates/site.html | 2 |
4 files changed, 2 insertions, 108 deletions
diff --git a/bin/gitbook.js b/bin/gitbook.js index 18c5c75..7a49cde 100755 --- a/bin/gitbook.js +++ b/bin/gitbook.js @@ -46,7 +46,6 @@ build.command(prog.command('serve [source_dir]')) server.stop() .then(function() { return build.folder(dir, _.extend(options || {}, { - cache: false, defaultsPlugins: ["livereload"] })); }) 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; diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index 73765ae..6f29991 100644 --- a/lib/generate/site/index.js +++ b/lib/generate/site/index.js @@ -9,7 +9,6 @@ var parse = require("../../parse"); var BaseGenerator = require("../generator"); var links = require("../../utils/links"); var indexer = require('./search_indexer'); -var Manifest = require('../manifest'); @@ -21,10 +20,6 @@ var Generator = function() { this.revision = Date.now(); this.indexer = indexer(); - this.manifest = new Manifest(Date.now()); - this.manifest.add("NETWORK", [ - '*' - ]); }; util.inherits(Generator, BaseGenerator); @@ -144,8 +139,6 @@ Generator.prototype.convertFile = function(content, _input) { return _callHook("page"); }) .then(function() { - that.manifest.add("CACHE", _output); - return that._writeTemplate(that.template, { progress: page.progress, @@ -189,22 +182,12 @@ Generator.prototype.copyAssets = function() { path.join(that.options.output, "gitbook") ) - // Add to cache manifest - .then(function() { - return that.manifest.addFolder(path.join(that.options.output, "gitbook"), "gitbook"); - }) - // Copy plugins assets .then(function() { return Q.all( _.map(that.plugins.list, function(plugin) { var pluginAssets = path.join(that.options.output, "gitbook/plugins/", plugin.name); - return plugin.copyAssets(pluginAssets) - .then(function(copiedStuff) { - // Nothing was copied - if(!copiedStuff) { return; } - return that.manifest.addFolder(pluginAssets, "gitbook/plugins/"+plugin.name); - }); + return plugin.copyAssets(pluginAssets); }) ); }); @@ -219,24 +202,10 @@ Generator.prototype.writeSearchIndex = function() { }; -// Add cache manifest -Generator.prototype.writeCacheManifest = function() { - return fs.writeFile( - path.join(this.options.output, 'manifest.appcache'), - this.manifest.dump() - ); -}; - Generator.prototype.finish = function() { - var deferred = this.copyAssets() + return this.copyAssets() .then(this.copyCover) .then(this.writeSearchIndex); - - if (this.options.cache !== false) { - deferred = deferred.then(this.writeCacheManifest); - } - - return deferred; }; module.exports = Generator; diff --git a/theme/templates/site.html b/theme/templates/site.html index 6fcbebd..ac1054f 100644 --- a/theme/templates/site.html +++ b/theme/templates/site.html @@ -1,7 +1,5 @@ {% extends "layout.html" %} -{% block htmlTag %}{% if options.cache !== false %}manifest="{{ basePath }}/manifest.appcache"{% endif %}{% endblock %} - {% block head %} {% parent %} {% if githubAuthor %} |