Skip to content

Commit c7519ce

Browse files
add not-found route
1 parent f909e64 commit c7519ce

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed

app/router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ AppRouter.map(function () {
8989
this.route('module', { path: '/modules/:module' });
9090
this.route('data-class', { path: '/data/classes/:class' });
9191
this.route('data-module', { path: '/data/modules/:module' });
92+
this.route('not-found', { path: '/*' });
9293
});
9394

9495
/*

app/routes/not-found.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
3+
4+
export default class NotFoundRoute extends Route {
5+
@service fastboot;
6+
7+
beforeModel() {
8+
if (!this.fastboot.isFastBoot) {
9+
return;
10+
}
11+
12+
this.fastboot.response.statusCode = 404;
13+
}
14+
}

app/styles/components/_whoops.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
.whoops {
22
width: 100%;
3+
display: flex;
4+
flex-direction: column;
5+
justify-content: center;
6+
margin-left: 20%;
7+
8+
@media (max-width: $mobile-portrait-screen){
9+
margin-left: 15px;
10+
}
11+
12+
img {
13+
width: 40%;
14+
@media (max-width: $mobile-portrait-screen){
15+
width: 80%;
16+
}
17+
}
318

419
&__title {
520
text-transform: uppercase;

app/templates/not-found.hbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{page-title "Page Not Found"}}
2+
3+
<div class="whoops">
4+
<img src="/assets/images/stinky-fish.png" alt="tomster stinky fish"/>
5+
<h2 class="whoops__title">Ack! 404 friend, you're in the wrong place</h2>
6+
<span>
7+
<LinkTo @route='index' class="whoops__message">Click here to go home</LinkTo>
8+
</span>
9+
</div>

public/assets/images/stinky-fish.png

70.8 KB
Loading

tests/unit/routes/not-found-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { module, test } from 'qunit';
2+
import { setupTest } from 'ember-qunit';
3+
4+
module('Unit | Route | not-found', function (hooks) {
5+
setupTest(hooks);
6+
7+
test('it exists', function (assert) {
8+
let route = this.owner.lookup('route:not-found');
9+
assert.ok(route);
10+
});
11+
});

0 commit comments

Comments
 (0)