aboutsummaryrefslogtreecommitdiffstats
path: root/docs/src
diff options
context:
space:
mode:
authorDi Peng2011-06-24 18:09:59 -0700
committerIgor Minar2011-07-20 17:09:40 -0700
commite90b741c9492a65e159c842afe49383f1868308e (patch)
tree3f0b16574e27ffa4878dab76389a15e9a7f4b477 /docs/src
parent3af1e7ca2ee8c2acd69e5bcbb3ffc1bf51239285 (diff)
downloadangular.js-e90b741c9492a65e159c842afe49383f1868308e.tar.bz2
feat(gen-docs): enable caching the whole site
Generate a manifest file automatically by reading the directories.
Diffstat (limited to 'docs/src')
-rw-r--r--docs/src/appCache.js50
-rwxr-xr-xdocs/src/gen-docs.js12
2 files changed, 56 insertions, 6 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
diff --git a/docs/src/gen-docs.js b/docs/src/gen-docs.js
index dfdbdf45..8ed0c563 100755
--- a/docs/src/gen-docs.js
+++ b/docs/src/gen-docs.js
@@ -4,7 +4,8 @@ var reader = require('reader.js'),
ngdoc = require('ngdoc.js'),
writer = require('writer.js'),
callback = require('callback.js'),
- SiteMap = require('SiteMap.js').SiteMap;
+ SiteMap = require('SiteMap.js').SiteMap,
+ appCache = require('appCache.js');
var docs = [];
var start;
@@ -31,9 +32,9 @@ var writes = callback.chain(function(){
writer.copy('docs/src/templates/index.html', 'build/docs/index-jq.html', writes.waitFor(),
'<-- jquery place holder -->', '<script src=\"jquery.min.js\"><\/script>');
writer.copyTpl('offline.html', writes.waitFor());
- writer.output('app-cache.manifest',
- appCacheTemplate().replace(/%TIMESTAMP%/, (new Date()).toISOString()),
- writes.waitFor());
+ //writer.output('app-cache.manifest',
+ // appCacheTemplate().replace(/%TIMESTAMP%/, (new Date()).toISOString()),
+ // writes.waitFor());
writer.merge(['docs.js',
'doc_widgets.js'],
'docs-combined.js',
@@ -56,6 +57,7 @@ var writes = callback.chain(function(){
'syntaxhighlighter/syntaxhighlighter-combined.css',
writes.waitFor());
writer.copyTpl('jquery.min.js', writes.waitFor());
+ writer.output('app-cache.manifest', appCache('build/docs/'), writes.waitFor());
});
writes.onDone(function(){
console.log('DONE. Generated ' + docs.length + ' pages in ' +
@@ -80,8 +82,6 @@ function appCacheTemplate() {
"docs-keywords.js",
"docs-combined.css",
"syntaxhighlighter/syntaxhighlighter-combined.css",
- "img/texture_1.png",
- "img/yellow_bkgnd.jpg",
"",
"FALLBACK:",
"/ offline.html",