mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-28 15:28:15 +00:00
add appcache for docs site - caches only css/js/img resources
This commit is contained in:
parent
f21b9214e6
commit
25b3438fd7
5 changed files with 52 additions and 2 deletions
7
Rakefile
7
Rakefile
|
|
@ -241,6 +241,13 @@ task :package => [:clean, :compile, :docs] do
|
||||||
f.write text.sub('angular-scenario.js', "angular-scenario-#{version}.js")
|
f.write text.sub('angular-scenario.js', "angular-scenario-#{version}.js")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
File.open("#{pkg_dir}/docs-#{version}/app-cache.manifest", File::RDWR) do |f|
|
||||||
|
text = f.read
|
||||||
|
f.rewind
|
||||||
|
f.write text.sub('angular.min.js', "angular-#{version}.min.js")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
%x(tar -czf #{path_to(tarball)} -C #{path_to('pkg')} .)
|
%x(tar -czf #{path_to(tarball)} -C #{path_to('pkg')} .)
|
||||||
|
|
||||||
puts "Package created: #{path_to(tarball)}"
|
puts "Package created: #{path_to(tarball)}"
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ var writes = callback.chain(function(){
|
||||||
writer.copyDir('img', writes.waitFor());
|
writer.copyDir('img', writes.waitFor());
|
||||||
writer.copyDir('examples', writes.waitFor());
|
writer.copyDir('examples', writes.waitFor());
|
||||||
writer.copyTpl('index.html', writes.waitFor());
|
writer.copyTpl('index.html', writes.waitFor());
|
||||||
|
writer.copyTpl('offline.html', writes.waitFor());
|
||||||
|
writer.output('app-cache.manifest',
|
||||||
|
appCacheTemplate().replace(/%TIMESTAMP%/, (new Date()).toISOString()),
|
||||||
|
writes.waitFor());
|
||||||
writer.merge(['docs.js',
|
writer.merge(['docs.js',
|
||||||
'doc_widgets.js'],
|
'doc_widgets.js'],
|
||||||
'docs-combined.js',
|
'docs-combined.js',
|
||||||
|
|
@ -59,3 +63,28 @@ writer.makeDir('build/docs/syntaxhighlighter', work);
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
function now(){ return new Date().getTime(); }
|
function now(){ return new Date().getTime(); }
|
||||||
|
|
||||||
|
|
||||||
|
function appCacheTemplate() {
|
||||||
|
return ["CACHE MANIFEST",
|
||||||
|
"# %TIMESTAMP%",
|
||||||
|
"",
|
||||||
|
"# cache all of these",
|
||||||
|
"CACHE:",
|
||||||
|
"jquery.min.js",
|
||||||
|
"syntaxhighlighter/syntaxhighlighter-combined.js",
|
||||||
|
"../angular.min.js",
|
||||||
|
"docs-combined.js",
|
||||||
|
"docs-keywords.js",
|
||||||
|
"docs-combined.css",
|
||||||
|
"syntaxhighlighter/syntaxhighlighter-combined.css",
|
||||||
|
"img/texture_1.png",
|
||||||
|
"img/yellow_bkgnd.jpg",
|
||||||
|
"",
|
||||||
|
"FALLBACK:",
|
||||||
|
"/ offline.html",
|
||||||
|
"",
|
||||||
|
"# allow access to google analytics and twitter when we are online",
|
||||||
|
"NETWORK:",
|
||||||
|
"*"].join('\n');
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html xmlns:ng="http://angularjs.org/"
|
<html xmlns:ng="http://angularjs.org/"
|
||||||
xmlns:doc="http://docs.angularjs.org/"
|
xmlns:doc="http://docs.angularjs.org/"
|
||||||
ng:controller="DocsController">
|
ng:controller="DocsController"
|
||||||
|
manifest="app-cache.manifest">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<title ng:bind-template="<angular/>: {{partialTitle}}"><angular/></title>
|
<title ng:bind-template="<angular/>: {{partialTitle}}"><angular/></title>
|
||||||
|
|
@ -20,6 +21,14 @@
|
||||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// force page reload when new update is available
|
||||||
|
window.applicationCache && window.applicationCache.addEventListener('updateready', function(e) {
|
||||||
|
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
|
||||||
|
window.applicationCache.swapCache();
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
||||||
4
docs/src/templates/offline.html
Normal file
4
docs/src/templates/offline.html
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<h2>OFFLINE</h2>
|
||||||
|
|
||||||
|
<p>This page if unavailable because your are offline.</p>
|
||||||
|
<p>Please connect to the Internet and reload the page.</p>
|
||||||
|
|
@ -79,7 +79,8 @@ StaticServlet.MimeMap = {
|
||||||
'jpg': 'image/jpeg',
|
'jpg': 'image/jpeg',
|
||||||
'jpeg': 'image/jpeg',
|
'jpeg': 'image/jpeg',
|
||||||
'gif': 'image/gif',
|
'gif': 'image/gif',
|
||||||
'png': 'image/png'
|
'png': 'image/png',
|
||||||
|
'manifest': 'text/cache-manifest'
|
||||||
};
|
};
|
||||||
|
|
||||||
StaticServlet.prototype.handleRequest = function(req, res) {
|
StaticServlet.prototype.handleRequest = function(req, res) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue