aboutsummaryrefslogtreecommitdiffstats
path: root/docs/src/appCache.js
diff options
context:
space:
mode:
Diffstat (limited to 'docs/src/appCache.js')
-rw-r--r--docs/src/appCache.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/docs/src/appCache.js b/docs/src/appCache.js
new file mode 100644
index 00000000..994054c2
--- /dev/null
+++ b/docs/src/appCache.js
@@ -0,0 +1,50 @@
+/**
+* Generate appCache Manifest file here
+*/
+
+exports.appCache = appCache;
+var fs = require('fs');
+
+function appCache(path) {
+ var blackList = [ "offline.html",
+ "sitemap.xml",
+ "robots.txt",
+ "docs-scenario.html",
+ "docs-scenario.js",
+ "app-cache.manifest"
+ ];
+
+ var result = ["CACHE MANIFEST",
+ "# %TIMESTAMP%",
+ "",
+ "# cache all of these",
+ "CACHE:",
+ "../angular.min.js"];
+
+ var resultPostfix = [ "",
+ "FALLBACK:",
+ "/offline.html",
+ "",
+ "# allow access to google analytics and twitter when we are online",
+ "NETWORK:",
+ "*"];
+ walk(path,result,blackList);
+ return result.join('\n').replace(/%TIMESTAMP%/, (new Date()).toISOString()) + '\n' + resultPostfix.join('\n');
+}
+
+function walk(path, array, blackList) {
+ var temp = fs.readdirSync(path);
+ for (var i=0; i< temp.length; i++) {
+ if(blackList.indexOf(temp[i]) < 0) {
+ var currentPath = path + '/' + temp[i];
+ var stat = fs.statSync(currentPath);
+
+ if (stat.isDirectory()) {
+ walk(currentPath, array, blackList);
+ }
+ else {
+ array.push(currentPath.replace('build/docs/',''));
+ }
+ }
+ }
+} \ No newline at end of file