diff options
Diffstat (limited to 'docs/src/templates')
| -rw-r--r-- | docs/src/templates/doc_widgets.js | 6 | ||||
| -rw-r--r-- | docs/src/templates/docs.js | 25 |
2 files changed, 27 insertions, 4 deletions
diff --git a/docs/src/templates/doc_widgets.js b/docs/src/templates/doc_widgets.js index 2bcbbfed..0e12fee8 100644 --- a/docs/src/templates/doc_widgets.js +++ b/docs/src/templates/doc_widgets.js @@ -169,7 +169,7 @@ }); - angular.directive('doc:tutorial-nav', function(step) { + angular.directive('doc:tutorial-nav', function(step) { return function(element) { var prevStep, codeDiff, nextStep, content; @@ -185,7 +185,7 @@ nextStep = 'the_end'; codeDiff = 'step-10...step-11'; } else { - prevStep = 'step_' + pad(step - 1) + prevStep = 'step_' + pad(step - 1); nextStep = 'step_' + pad(step + 1); codeDiff = 'step-' + step + '...step-' + step; } @@ -199,7 +199,7 @@ element.attr('id', 'tutorial-nav'); element.append(content); - } + }; function pad(step) { return (step < 10) ? ('0' + step) : step; diff --git a/docs/src/templates/docs.js b/docs/src/templates/docs.js index b6da7b97..99ca0599 100644 --- a/docs/src/templates/docs.js +++ b/docs/src/templates/docs.js @@ -15,7 +15,7 @@ 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; + self.partialTitle = (angular.Array.filter(self.pages, function(doc){return doc.id == self.partialId;})[0]||{}).name || 'Error: Page Not Found!'; } }); @@ -84,3 +84,26 @@ 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); + }; +}); |
