Skip to content

Commit 5aa900b

Browse files
committed
added page titles
1 parent 090d590 commit 5aa900b

File tree

11 files changed

+204
-11
lines changed

11 files changed

+204
-11
lines changed

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"mocha": "^3.1.2",
5252
"node-sass": "^4.0.0",
5353
"postcss-loader": "^1.0.0",
54+
"redux-thunk": "^2.2.0",
5455
"request": "^2.76.0",
5556
"resolve-url-loader": "^1.6.0",
5657
"sass-loader": "^4.0.2",

Diff for: src/modules/challenges/routes.jsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ export default [
55
{
66
path: '/challenges/',
77
name: 'challenges',
8-
component: Challenges
8+
component: Challenges,
9+
meta: {
10+
title: 'Challanges'
11+
}
912
},
1013
{
1114
path: '/challenges/:slug',
1215
name: 'challenge',
13-
component: Challenge
16+
component: Challenge,
17+
meta: {
18+
title: 'Challenge'
19+
}
1420
}
1521
];

Diff for: src/modules/core/components/error-page.jsx

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import LayoutStatic from '../../static/components/layout';
2+
3+
require('../styles/error-page.scss');
4+
5+
class ErrorPage extends React.Component {
6+
7+
constructor(props) {
8+
super(props);
9+
}
10+
11+
render() {
12+
return (
13+
<LayoutStatic className="error-page">
14+
<section className="details">
15+
<div className="container">
16+
<div className="row">
17+
<div className="col-xs-12">
18+
<div className="error-code">
19+
{this.props.error.code}
20+
</div>
21+
<div className="error-title">
22+
{this.props.error.title}
23+
</div>
24+
<div className="error-description">
25+
{this.props.error.description}
26+
</div>
27+
</div>
28+
</div>
29+
</div>
30+
</section>
31+
<div className="bg-graphic bg-graphic-right" />
32+
</LayoutStatic>
33+
);
34+
}
35+
}
36+
37+
ErrorPage.defaultProps = {
38+
error: {}
39+
};
40+
41+
export default ErrorPage;

Diff for: src/modules/core/containers/error-page.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import {compose} from 'react-komposer';
2+
3+
import component from '../components/error-page';
4+
5+
const composer = (props, onData) => {
6+
let error;
7+
8+
switch(props.errorCode) {
9+
case '403': {
10+
error = {
11+
code: 403,
12+
title: 'Forbidden :(',
13+
description: `Ups! Da ist etwas schief gelaufen.
14+
Du verfügst nicht über die Berechtigungen,
15+
um auf diese Seite zuzugreifen.`
16+
};
17+
}
18+
break;
19+
case '404': {
20+
error = {
21+
code: 404,
22+
title: 'Not Found :(',
23+
description: `Ups! Da ist etwas schief gelaufen.
24+
Diese Seite existiert (noch) nicht,
25+
bitte versuche es nochmal auf einem anderen Weg.`
26+
};
27+
}
28+
break;
29+
case '500': {
30+
error = {
31+
code: 500,
32+
title: 'Server Error :(',
33+
description: `Ups! Da ist etwas schief gelaufen.
34+
Aber unser Team kümmert sich wahrscheinlich gerade schon darum,
35+
dass die Schul-Cloud gleich wieder funktioniert.`
36+
};
37+
}
38+
break;
39+
default: {
40+
error = {
41+
code: props.errorCode,
42+
title: 'Unknown Error :(',
43+
description: `Ups! Da ist etwas schief gelaufen.`
44+
};
45+
}
46+
break;
47+
}
48+
49+
onData(null, {error});
50+
};
51+
52+
export default compose(composer)(component);
53+

Diff for: src/modules/core/helpers/app.js

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
import { applyRouterMiddleware, browserHistory, hashHistory, Router, Route, Link } from 'react-router';
22
import { useScroll } from 'react-router-scroll';
33

4-
import Layout from '../components/layout';
4+
import ErrorPage from '../containers/error-page';
5+
6+
const _forceTrailingSlash = (prevState, nextState, replace) => {
7+
const path = nextState.location.pathname;
8+
if (path.slice(-1) !== '/') {
9+
replace(Object.assign(nextState.location, {
10+
pathname: `${path}/`
11+
}));
12+
}
13+
};
14+
15+
const _getErrorPageUI = (errorCode) => {
16+
return (
17+
<ErrorPage errorCode={errorCode} />
18+
);
19+
};
20+
521

622
export default class App {
723
constructor(context) {
@@ -87,9 +103,22 @@ export default class App {
87103
delete route.path;
88104
}
89105

106+
route.onEnter = () => {
107+
const title = (route.meta || {}).title;
108+
document.title = title ? `${title} - Project Secure` : 'Project Secure';
109+
};
110+
90111
return route;
91112
});
92113

114+
// force trailing slashes with redirect or not found
115+
routes.push({
116+
path:'*',
117+
component: _getErrorPageUI.bind(this, '404'),
118+
onEnter: _forceTrailingSlash.bind(this, null),
119+
onUpdate: _forceTrailingSlash
120+
});
121+
93122
this.__initialized = true;
94123

95124
return (

Diff for: src/modules/core/styles/error-page.scss

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@import 'colors';
2+
3+
.error-page {
4+
background: #dac9b7 url(../../../static/images/bgtmp.png) center bottom no-repeat;
5+
background-size: 100% auto;
6+
width: 100%;
7+
height: 100%;
8+
color: #fff;
9+
10+
h3 {
11+
color: #123;
12+
float: left;
13+
width: 100%;
14+
text-align: center;
15+
font-weight: bold;
16+
margin: 100px 0px;
17+
}
18+
19+
20+
.details {
21+
padding: 100px 0px;
22+
width: 100%;
23+
24+
.error-code {
25+
font-size: 800%;
26+
font-weight: bold;
27+
}
28+
29+
.error-title {
30+
font-weight: bold;
31+
font-size: 500%;
32+
text-transform: uppercase;
33+
}
34+
35+
.error-description {
36+
margin-top: 50px;
37+
font-size: 200%;
38+
max-width: 500px;
39+
}
40+
}
41+
42+
}

Diff for: src/modules/dashboard/routes.jsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ export default [
44
{
55
path: '/dashboard/',
66
name: 'dashboard',
7-
component: Dashboard
7+
component: Dashboard,
8+
meta: {
9+
title: 'Dashboard'
10+
}
811
}
912
];

Diff for: src/modules/settings/routes.jsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ export default [
44
{
55
path: '/settings/',
66
name: 'settings',
7-
component: Settings
7+
component: Settings,
8+
meta: {
9+
title: 'Settings'
10+
}
811
}
912
];

Diff for: src/modules/static/routes.jsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,24 @@ export default [
1111
{
1212
path: '/partner/',
1313
name: 'partner',
14-
component: Partner
14+
component: Partner,
15+
meta: {
16+
title: 'Partner'
17+
}
1518
},
1619
{
1720
path: '/contact/',
1821
name: 'contact',
19-
component: Contact
22+
component: Contact,
23+
meta: {
24+
title: 'Contact'
25+
}
2026
},{
2127
path: '/imprint/',
2228
name: 'imprint',
23-
component: Imprint
29+
component: Imprint,
30+
meta: {
31+
title: 'Imprint'
32+
}
2433
}
2534
];

Diff for: src/modules/user/routes.jsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ export default [
55
{
66
path: '/login/',
77
name: 'login',
8-
component: Login
8+
component: Login,
9+
meta: {
10+
title: 'Login'
11+
}
912
},
1013
{
1114
path: '/signup/',
1215
name: 'signup',
13-
component: Signup
16+
component: Signup,
17+
meta: {
18+
title: 'Signup'
19+
}
1420
}
1521
];

Diff for: src/static/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<title>Project Secure Client</title>
5+
<title>Project Secure</title>
66
<link rel="stylesheet" type="text/css" href="/styles.css">
77
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
88
</head>

0 commit comments

Comments
 (0)