From 1e8448b9e50878cc23d736be66116b49c90bd7f9 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 30 Jun 2011 00:49:44 -0700 Subject: fix:docs: properly distinguish between being offline and 404 --- docs/src/templates/docs.js | 38 +++++++++++++------------------------- docs/src/templates/offline.html | 2 +- 2 files changed, 14 insertions(+), 26 deletions(-) (limited to 'docs/src') 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 = '
Sorry this page has not been found.
'; - - if (suggestion) - HTML_404 += 'Looks like you are using an old link. Please update your bookmark to: ' + suggestion + '
'; - - 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 @@This page if unavailable because your are offline.
+This page is currently unavailable because your are offline.
Please connect to the Internet and reload the page.
-- cgit v1.2.3