From c8530f6f125c07827844ea92e726a556d609ed4c Mon Sep 17 00:00:00 2001 From: Hannu Pelkonen Date: Wed, 14 Jan 2015 12:42:54 +0200 Subject: [PATCH] Create 404 page. Use ui-sref to generate internal links --- lib/app/js/app.js | 7 +++++-- lib/app/views/main.html | 4 ++-- lib/app/views/partials/section.html | 6 +++--- test/angular/unit/controllers/element.test.js | 1 + test/angular/unit/controllers/main.test.js | 1 + test/angular/unit/controllers/sections.test.js | 1 + 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/app/js/app.js b/lib/app/js/app.js index da01be45..c4eb86fa 100644 --- a/lib/app/js/app.js +++ b/lib/app/js/app.js @@ -39,7 +39,7 @@ angular.module('sgApp', [ } }) .state('app.index.section', { - url: '/:section', + url: '/section/:section', templateUrl: 'views/sections.html', controller: 'SectionsCtrl', resolve: { @@ -63,7 +63,7 @@ angular.module('sgApp', [ } }) .state('app.fullscreen', { - url: '/:section/fullscreen', + url: '/section/:section/fullscreen', templateUrl: 'views/element-fullscreen.html', controller: 'ElementCtrl', resolve: { @@ -73,6 +73,9 @@ angular.module('sgApp', [ } } } + }).state('app.index.404', { + url: '/:all', + templateUrl: 'views/404.html' }); $locationProvider.html5Mode(true); diff --git a/lib/app/views/main.html b/lib/app/views/main.html index 1c762059..89e2db22 100644 --- a/lib/app/views/main.html +++ b/lib/app/views/main.html @@ -43,14 +43,14 @@

Error: {{status.error.name}}

+ ui-sref="app.index.section({section: {{section.reference}}})"> {{ section.reference }} {{ section.header }}
  • + ui-sref="app.index.section({section: all})"> Show all sections
  • diff --git a/lib/app/views/partials/section.html b/lib/app/views/partials/section.html index 876f978d..ee143381 100644 --- a/lib/app/views/partials/section.html +++ b/lib/app/views/partials/section.html @@ -1,7 +1,7 @@
    - +

    {{ section.reference }} @@ -21,7 +21,7 @@

    @@ -32,7 +32,7 @@

    class="sg section-partial" ng-if="!section.modifiers.length && section.markup"> diff --git a/test/angular/unit/controllers/element.test.js b/test/angular/unit/controllers/element.test.js index 65356738..353b53ff 100644 --- a/test/angular/unit/controllers/element.test.js +++ b/test/angular/unit/controllers/element.test.js @@ -58,6 +58,7 @@ describe('ElementCtrl', function() { httpBackend.whenGET('views/main.html').respond(''); httpBackend.whenGET('views/sections.html').respond(''); + httpBackend.whenGET('views/404.html').respond(''); ctrl = $controller('ElementCtrl', { $scope: scope, $stateParams: stateParams diff --git a/test/angular/unit/controllers/main.test.js b/test/angular/unit/controllers/main.test.js index ada74428..7fa5b405 100644 --- a/test/angular/unit/controllers/main.test.js +++ b/test/angular/unit/controllers/main.test.js @@ -53,6 +53,7 @@ describe('Controller: MainCtrl', function() { httpBackend.whenGET('views/main.html').respond(''); httpBackend.whenGET('views/sections.html').respond(''); + httpBackend.whenGET('views/404.html').respond(''); httpBackend.flush(); localStorageService.clearAll(); })); diff --git a/test/angular/unit/controllers/sections.test.js b/test/angular/unit/controllers/sections.test.js index 16f79f45..b04a3cad 100644 --- a/test/angular/unit/controllers/sections.test.js +++ b/test/angular/unit/controllers/sections.test.js @@ -51,6 +51,7 @@ describe('SectionsCtrl', function() { httpBackend.whenGET('views/main.html').respond(''); httpBackend.whenGET('views/sections.html').respond(''); + httpBackend.whenGET('views/404.html').respond(''); ctrl = $controller('SectionsCtrl', { $scope: scope, $stateParams: stateParams