aboutsummaryrefslogtreecommitdiffstats
path: root/docs/src/templates
diff options
context:
space:
mode:
Diffstat (limited to 'docs/src/templates')
-rw-r--r--docs/src/templates/.htaccess6
-rw-r--r--docs/src/templates/docs.js11
-rw-r--r--docs/src/templates/index.html86
3 files changed, 74 insertions, 29 deletions
diff --git a/docs/src/templates/.htaccess b/docs/src/templates/.htaccess
index 87487e9e..9f9a152c 100644
--- a/docs/src/templates/.htaccess
+++ b/docs/src/templates/.htaccess
@@ -8,4 +8,8 @@
RewriteEngine on
RewriteCond %{HTTP_COOKIE} ng-offline="NG_VERSION_FULL"
-RewriteRule appcache.manifest appcache-offline.manifest \ No newline at end of file
+RewriteRule appcache.manifest appcache-offline.manifest
+
+
+## HTML5 URL Support ##
+RewriteRule ^(guide|api|cookbook|misc|tutorial)(/.*)?$ index.html
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: '!'
};
});
diff --git a/docs/src/templates/index.html b/docs/src/templates/index.html
index d5cfaed2..a2def7a6 100644
--- a/docs/src/templates/index.html
+++ b/docs/src/templates/index.html
@@ -5,23 +5,57 @@
doc:manifest>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title ng:bind-template="AngularJS: {{partialTitle}}">AngularJS</title>
<meta name="fragment" content="!">
- <link rel="stylesheet" href="docs-combined.css" type="text/css"/>
- <link rel="stylesheet" href="syntaxhighlighter/syntaxhighlighter-combined.css" type="text/css"/>
+ <title ng:bind-template="AngularJS: {{partialTitle}}">AngularJS</title>
+ <script type="text/javascript">
+ // dynamically add base tag as well as css and javascript files.
+ // we can't add css/js the usual way, because some browsers (FF) eagerly prefetch resources
+ // before the base attribute is added, causing 404 and terribly slow loading of the docs app.
+ (function() {
+ var indexFile = (location.pathname.match(/\/(index[^\.]*\.html)/) || ['', 'index.html'])[1],
+ rUrl = /(api|guide|misc|tutorial|cookbook|index[^\.]*\.html).*$/,
+ baseUrl = location.href.replace(rUrl, indexFile),
+ jQuery = /index-jq[^\.]*\.html$/.test(baseUrl),
+ debug = /index[^\.]*-debug\.html$/.test(baseUrl),
+ angularPath = debug ? '../angular.js' : '../angular.min.js',
+ headEl = document.getElementsByTagName('head')[0],
+ sync = true;
- <script>
- // GA asynchronous tracker
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', 'UA-8594346-3']);
- _gaq.push(['_setDomainName', '.angularjs.org']);
+ addTag('base', {href: baseUrl});
+ addTag('link', {rel: 'stylesheet', href: 'docs-combined.css', type: 'text/css'});
+ addTag('link', {rel: 'stylesheet', href: 'syntaxhighlighter/syntaxhighlighter-combined.css',
+ type: 'text/css'});
+ addTag('script', {src: 'syntaxhighlighter/syntaxhighlighter-combined.js'}, sync);
+ if (jQuery) addTag('script', {src: 'jquery.min.js'});
+ addTag('script', {src: angularPath, 'ng:autobind':''}, sync);
+ addTag('script', {src: 'docs-combined.js'}, sync);
+ addTag('script', {src: 'docs-keywords.js'}, sync);
- (function() {
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
- 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);
+ function addTag(name, attributes, sync) {
+ var el = document.createElement(name),
+ attrName;
+
+ for (attrName in attributes) {
+ el.setAttribute(attrName, attributes[attrName]);
+ }
+
+ sync ? document.write(outerHTML(el)) : headEl.appendChild(el);
+ }
+
+ function outerHTML(node){
+ // if IE, Chrome take the internal method otherwise build one
+ return node.outerHTML || (
+ function(n){
+ var div = document.createElement('div'), h;
+ div.appendChild(n);
+ h = div.innerHTML;
+ div = null;
+ return h;
+ })(node);
+ }
})();
+
// force page reload when new update is available
window.applicationCache && window.applicationCache.addEventListener('updateready', function(e) {
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
@@ -29,6 +63,18 @@
window.location.reload();
}
}, false);
+
+
+ // GA asynchronous tracker
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-8594346-3']);
+ _gaq.push(['_setDomainName', '.angularjs.org']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ 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);
+ })();
</script>
</head>
@@ -45,11 +91,11 @@
<ul id="navbar">
<li><a href="http://angularjs.org/">AngularJS</a></li>
- <li><a href="#!/misc/started" ng:class="selectedSection('misc')">Getting Started</a></li>
- <li><a href="#!/tutorial" ng:class="selectedSection('tutorial')">Tutorial</a></li>
- <li><a href="#!/api" ng:class="selectedSection('api')">API Reference</a></li>
- <li><a href="#!/cookbook" ng:class="selectedSection('cookbook')">Examples</a></li>
- <li><a href="#!/guide" ng:class="selectedSection('guide')">Developer Guide</a></li>
+ <li><a href="misc/started" ng:class="selectedSection('misc')">Getting Started</a></li>
+ <li><a href="tutorial" ng:class="selectedSection('tutorial')">Tutorial</a></li>
+ <li><a href="api" ng:class="selectedSection('api')">API Reference</a></li>
+ <li><a href="cookbook" ng:class="selectedSection('cookbook')">Examples</a></li>
+ <li><a href="guide" ng:class="selectedSection('guide')">Developer Guide</a></li>
</ul>
<div id="sidebar">
@@ -100,11 +146,5 @@
<button id="cacheButton" ng:click="enableOffline()">Let me have them all!</button>
</div>
</div>
-
- <script src="syntaxhighlighter/syntaxhighlighter-combined.js"></script>
- <!-- jquery place holder -->
- <!-- angular script place holder -->
- <script src="docs-combined.js"></script>
- <script src="docs-keywords.js"></script>
</body>
</html>