2011-06-25 01:09:59 +00:00
|
|
|
/**
|
|
|
|
|
* Generate appCache Manifest file here
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
exports.appCache = appCache;
|
2013-12-13 19:59:23 +00:00
|
|
|
var fs = require('q-io/fs');
|
2011-07-10 01:15:40 +00:00
|
|
|
var Q = require('qq');
|
|
|
|
|
function identity($) {return $;}
|
2011-06-25 01:09:59 +00:00
|
|
|
|
|
|
|
|
function appCache(path) {
|
2011-07-10 01:15:40 +00:00
|
|
|
if(!path) {
|
|
|
|
|
return appCacheTemplate();
|
|
|
|
|
}
|
2011-07-21 02:29:54 +00:00
|
|
|
var blackList = ["build/docs/offline.html",
|
|
|
|
|
"build/docs/sitemap.xml",
|
|
|
|
|
"build/docs/robots.txt",
|
|
|
|
|
"build/docs/docs-scenario.html",
|
|
|
|
|
"build/docs/docs-scenario.js",
|
|
|
|
|
"build/docs/appcache.manifest",
|
|
|
|
|
"build/docs/.htaccess"
|
2011-06-25 01:09:59 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
var result = ["CACHE MANIFEST",
|
2011-07-10 01:15:40 +00:00
|
|
|
"# " + new Date().toISOString(),
|
|
|
|
|
"",
|
|
|
|
|
"# cache all of these",
|
|
|
|
|
"CACHE:",
|
|
|
|
|
"../angular.min.js"];
|
|
|
|
|
|
|
|
|
|
var resultPostfix = ["",
|
|
|
|
|
"FALLBACK:",
|
2011-08-30 09:47:24 +00:00
|
|
|
"/ /build/docs/index.html",
|
2011-07-10 01:15:40 +00:00
|
|
|
"",
|
|
|
|
|
"# allow access to google analytics and twitter when we are online",
|
|
|
|
|
"NETWORK:",
|
|
|
|
|
"*"];
|
|
|
|
|
|
|
|
|
|
var promise = fs.listTree(path).then(function(files){
|
|
|
|
|
var fileFutures = [];
|
|
|
|
|
files.forEach(function(file){
|
|
|
|
|
fileFutures.push(fs.isFile(file).then(function(isFile){
|
|
|
|
|
if (isFile && blackList.indexOf(file) == -1) {
|
|
|
|
|
return file.replace('build/docs/','');
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
return Q.deep(fileFutures);
|
|
|
|
|
}).then(function(files){
|
|
|
|
|
return result.concat(files.filter(identity)).concat(resultPostfix).join('\n');
|
|
|
|
|
});
|
2011-06-25 01:09:59 +00:00
|
|
|
|
2011-07-10 01:15:40 +00:00
|
|
|
return promise;
|
2011-06-25 01:09:59 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-10 01:15:40 +00:00
|
|
|
function appCacheTemplate() {
|
|
|
|
|
return ["CACHE MANIFEST",
|
|
|
|
|
"# " + new Date().toISOString(),
|
|
|
|
|
"",
|
|
|
|
|
"# cache all of these",
|
|
|
|
|
"CACHE:",
|
|
|
|
|
"syntaxhighlighter/syntaxhighlighter-combined.js",
|
|
|
|
|
"../angular.min.js",
|
|
|
|
|
"docs-combined.js",
|
2013-06-14 02:37:13 +00:00
|
|
|
"docs-data.js",
|
2011-07-10 01:15:40 +00:00
|
|
|
"docs-combined.css",
|
|
|
|
|
"syntaxhighlighter/syntaxhighlighter-combined.css",
|
|
|
|
|
"img/texture_1.png",
|
|
|
|
|
"img/yellow_bkgnd.jpg",
|
|
|
|
|
"",
|
|
|
|
|
"FALLBACK:",
|
2011-08-30 09:47:24 +00:00
|
|
|
"/ /build/docs/offline.html",
|
2011-07-10 01:15:40 +00:00
|
|
|
"",
|
|
|
|
|
"# allow access to google analytics and twitter when we are online",
|
|
|
|
|
"NETWORK:",
|
|
|
|
|
"*"].join('\n');
|
|
|
|
|
}
|