diff options
| author | Igor Minar | 2011-06-30 00:49:44 -0700 |
|---|---|---|
| committer | Igor Minar | 2011-06-30 00:49:44 -0700 |
| commit | 1e8448b9e50878cc23d736be66116b49c90bd7f9 (patch) | |
| tree | e0da29dc93fb3e13cdeb2499295568f4fb74c6ca | |
| parent | c5f3a413bc00acf9ac1046fb15b454096a8890c6 (diff) | |
| download | angular.js-1e8448b9e50878cc23d736be66116b49c90bd7f9.tar.bz2 | |
fix:docs: properly distinguish between being offline and 404
| -rw-r--r-- | docs/src/templates/docs.js | 38 | ||||
| -rw-r--r-- | docs/src/templates/offline.html | 2 |
2 files changed, 14 insertions, 26 deletions
diff --git a/docs/src/templates/docs.js b/docs/src/templates/docs.js index 99ca0599..1040f2c2 100644 --- a/docs/src/templates/docs.js +++ b/docs/src/templates/docs.js @@ -15,7 +15,18 @@ function DocsController($location, $browser, $window) { self.sectionId = parts[1]; self.partialId = parts[2] || 'index'; self.pages = angular.Array.filter(NG_PAGES, {section:self.sectionId}); - self.partialTitle = (angular.Array.filter(self.pages, function(doc){return doc.id == self.partialId;})[0]||{}).name || 'Error: Page Not Found!'; + + var i = self.pages.length; + while (i--) { + if (self.pages[i].id == self.partialId) { + self.partialTitle = self.pages[i].name + break; + } + } + if (i<0) { + self.partialTitle = 'Error: Page Not Found!'; + delete self.partialId; + } } }); @@ -24,7 +35,7 @@ function DocsController($location, $browser, $window) { }; this.getCurrentPartial = function(){ - return './' + this.sectionId + '/' + this.partialId + '.html'; + return this.partialId ? ('./' + this.sectionId + '/' + this.partialId + '.html') : ''; }; this.getClass = function(page) { @@ -84,26 +95,3 @@ function TutorialInstructionsCtrl($cookieStore) { $cookieStore.put('selEnv', id); }; } - -/** - * Display 404 page and suggest new link if possible - */ -angular.service('$xhr.error', function($location) { - function suggestLink(wrongLink) { - var link = wrongLink.replace(/^!\/?/, ''); - - if (link.match(/^angular/)) return 'api/' + link; - else if (link.match(/^cookbook/)) return link.replace('cookbook.', 'cookbook/'); - } - - return function(request, response) { - var suggestion = suggestLink($location.hashPath), - HTML_404 = '<h1>Error: Page Not Found</h1>' + - '<p>Sorry this page has not been found.</p>'; - - if (suggestion) - HTML_404 += '<p>Looks like you are using an old link. Please update your bookmark to: <a href="#!/' + suggestion + '">' + suggestion + '</a></p>'; - - request.callback(200, HTML_404); - }; -}); diff --git a/docs/src/templates/offline.html b/docs/src/templates/offline.html index 9996eb1c..f52ca6e5 100644 --- a/docs/src/templates/offline.html +++ b/docs/src/templates/offline.html @@ -1,4 +1,4 @@ <h2>OFFLINE</h2> -<p>This page if unavailable because your are offline.</p> +<p>This page is currently unavailable because your are offline.</p> <p>Please connect to the Internet and reload the page.</p> |
