aboutsummaryrefslogtreecommitdiffstats
path: root/docs/src/templates/docs.js
diff options
context:
space:
mode:
authorVojta Jina2011-08-30 11:47:24 +0200
committerIgor Minar2011-09-26 23:51:53 +0200
commit13f92de6246a0af8450fde84b209211a56397fda (patch)
tree2e277d50a67f32dddcb1e7674ed8b1476881e014 /docs/src/templates/docs.js
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 'docs/src/templates/docs.js')
-rw-r--r--docs/src/templates/docs.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/docs/src/templates/docs.js b/docs/src/templates/docs.js
index d1069a77..505aed60 100644
--- a/docs/src/templates/docs.js
+++ b/docs/src/templates/docs.js
@@ -4,7 +4,8 @@ function DocsController($location, $browser, $window, $cookies) {
var self = this,
OFFLINE_COOKIE_NAME = 'ng-offline',
- DOCS_PATH = /^\/(api)|(guide)|(cookbook)|(misc)|(tutorial)/;
+ DOCS_PATH = /^\/(api)|(guide)|(cookbook)|(misc)|(tutorial)/,
+ INDEX_PATH = /^(\/|\/index[^\.]*.html)$/;
this.$location = $location;
@@ -13,7 +14,7 @@ function DocsController($location, $browser, $window, $cookies) {
self.subpage = false;
self.offlineEnabled = ($cookies[OFFLINE_COOKIE_NAME] == angular.version.full);
- if (!$location.path()) {
+ if (!$location.path() || INDEX_PATH.test($location.path())) {
$location.path('/api').replace();
}
@@ -40,11 +41,11 @@ function DocsController($location, $browser, $window, $cookies) {
});
this.getUrl = function(page){
- return '#!/' + page.section + '/' + page.id;
+ return page.section + '/' + page.id;
};
this.getCurrentPartial = function(){
- return this.partialId ? ('./' + this.sectionId + '/' + this.partialId + '.html') : '';
+ return this.partialId ? ('./partials/' + this.sectionId + '/' + this.partialId + '.html') : '';
};
this.getClass = function(page) {
@@ -127,7 +128,7 @@ function TutorialInstructionsCtrl($cookieStore) {
angular.service('$locationConfig', function() {
return {
- html5Mode: false,
+ html5Mode: true,
hashPrefix: '!'
};
});