aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVojta Jina2011-08-30 11:47:24 +0200
committerIgor Minar2011-09-26 23:51:53 +0200
commit13f92de6246a0af8450fde84b209211a56397fda (patch)
tree2e277d50a67f32dddcb1e7674ed8b1476881e014 /lib
parent2bc39bb0b4f81b77597bb52f8572d231cf4f83e2 (diff)
downloadangular.js-13f92de6246a0af8450fde84b209211a56397fda.tar.bz2
feat(docs): use html5 history api for all routing in the docs app
- Configure our docs app to use new $location with html5 history api! - Update simple node web server to serve index.html for all links (rewritting). - Update .htaccess file to serve index.html for all links (rewritting). - At runtime determine the base href path and attach it to the DOM. We needed the absolute URL to get all browsers to work well. - Because of the above, we also need to dynamically determine all needed js/css resources and add them to the DOM. This was needed because FF6 would eagerly fetch resources with wrong URL since the base element is added to the dom at runtime. - All content html files were moved to the partials directory, because with the new html5 urls it was impossible to tell if request for http://domain/api/angular.filter.html was an html5 url for the html filter doc page, or an xhr/appcache request for the content html file for the html filter. f
Diffstat (limited to 'lib')
-rw-r--r--lib/nodeserver/server.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/nodeserver/server.js b/lib/nodeserver/server.js
index 471bba94..54ae78fc 100644
--- a/lib/nodeserver/server.js
+++ b/lib/nodeserver/server.js
@@ -91,6 +91,18 @@ StaticServlet.prototype.handleRequest = function(req, res) {
var parts = path.split('/');
if (parts[parts.length-1].charAt(0) === '.')
return self.sendForbidden_(req, res, path);
+
+ // docs rewriting
+ var REWRITE = /\/(guide|api|cookbook|misc|tutorial)\/.*$/,
+ IGNORED = /(\.(css|js|png|jpg)$|partials\/.*\.html$)/,
+ match;
+
+ if (!IGNORED.test(path) && (match = path.match(REWRITE))) {
+ path = path.replace(match[0], '/index.html');
+ sys.puts('Rewrite to ' + path);
+ }
+ // end of docs rewriting
+
fs.stat(path, function(err, stat) {
if (err)
return self.sendMissing_(req, res, path);