diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-27 17:14:57 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-27 17:14:57 +0200 |
commit | 6a33ad9ef7a73faaeb8faa839b2004fbcd502ec7 (patch) | |
tree | 892bd90740b5d7e1b252de2fd3145746bbee7171 /lib/generate/site/index.js | |
parent | ca94055adf2d0519105b587116d5d56b559a2c3a (diff) | |
download | gitbook-6a33ad9ef7a73faaeb8faa839b2004fbcd502ec7.zip gitbook-6a33ad9ef7a73faaeb8faa839b2004fbcd502ec7.tar.gz gitbook-6a33ad9ef7a73faaeb8faa839b2004fbcd502ec7.tar.bz2 |
Add base cache manifest
Diffstat (limited to 'lib/generate/site/index.js')
-rw-r--r-- | lib/generate/site/index.js | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js index 68328e7..f8986df 100644 --- a/lib/generate/site/index.js +++ b/lib/generate/site/index.js @@ -9,6 +9,7 @@ var parse = require("../../parse"); var BaseGenerator = require("../generator"); var indexer = require('./search_indexer'); +var Manifest = require('../manifest'); // Swig filter for returning the count of lines in a code section swig.setFilter('lines', function(content) { @@ -30,6 +31,10 @@ var Generator = function() { this.revision = Date.now(); this.indexer = indexer(); + this.manifest = new Manifest(Date.now()); + this.manifest.add("NETWORK", [ + '*' + ]); }; util.inherits(Generator, BaseGenerator); @@ -119,6 +124,8 @@ Generator.prototype.convertFile = function(content, _input) { }); }) .then(function(sections) { + that.manifest.add("CACHE", _output); + return that._writeTemplate(that.template, { progress: progress, @@ -157,11 +164,22 @@ Generator.prototype.copyAssets = function() { path.join(that.options.theme, "assets"), path.join(that.options.output, "gitbook") ) + + // Add to cach 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) { - return plugin.copyAssets(path.join(that.options.output, "gitbook/plugins/", plugin.name)) + var pluginAssets = path.join(that.options.output, "gitbook/plugins/", plugin.name); + + return plugin.copyAssets(pluginAssets) + .then(function() { + return that.manifest.addFolder(pluginAssets, "gitbook/plugins/"+plugin.name); + }); }) ); }) @@ -175,9 +193,19 @@ 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() { return this.copyAssets() - .then(this.writeSearchIndex); + .then(this.writeSearchIndex) + .then(this.writeCacheManifest); }; module.exports = Generator; |