added an error page for SEO

master
Thierry Degeling 2015-08-11 12:28:58 +02:00
parent 2153aae193
commit 45fca6f62f
3 changed files with 78 additions and 4 deletions

View File

@ -35,10 +35,18 @@
$app->mount( '/press', new level2\PressControllerProvider() );
$app->error(function (\Exception $e, $code) use ( $app ) {
if ( $code == 404 ) {
return $app->redirect('/');
}
$app->error(function (\Exception $e, $code) use($app) {
$message = $app['twig']->render(
'error.twig',
array(
'code' => $code,
'level2' => level2\Level2::getStatus( $app ),
'page' => 'Error ' . $code
)
);
return new Response( $message, $code );
});
return $app;

36
src/app/views/error.twig Normal file
View File

@ -0,0 +1,36 @@
{% extends "base.twig" %}
{% block container %}
{% set number = ['oh!', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'] %}
{% set description = {
401 : 'sorry, you need to authenticate<br />yourself first to access this page',
403 : 'sorry, I cannot show you a page<br />you have not been granted access to',
404 : "sorry, that page doesn't<br />exist or has been moved",
500 : 'sorry,<br />the server failed to process this page'
}
%}
<div class="row">
<div class="col-md-8 col-md-offset-2 error">
<div class="code">
<p>{{ number[ code[0:1] ] }}</p>
<p {% if code[2:1] != 0 %}class="small"{% endif %}>{{ number[ code[1:1] ] }}</p>
<p {% if code[2:1] == 0 %}class="small"{% endif %}>{{ number[ code[2:1] ] }}</p>
</div>
<div class="description light">{{ description[ code ] | raw }}</div>
<div class="line"></div>
<div class="description light">
<a target="_blank" href="https://twitter.com/Level2lu">Get in touch with us</a><br />if you think this is a mistake
</div>
</div>
</div>
{% endblock %}

View File

@ -208,3 +208,33 @@ a.permaLink:hover {
color: #777777;
text-decoration: underline;
}
.error {
text-transform: uppercase;
display: block;
width: 620px;
height: 400px;
position: absolute;
top: 50%;
left: 50%;
margin: -200px 0 0 -310px;
text-align: center;
}
.code {
line-height: 1;
font-size: 6em;
margin-bottom: 0.2em;
font-weight: 800;
}
.code p {
line-height: 1em;
}
.small {
font-size: 0.5em;
}
.line {
margin: 2em;
height: 2px;
width: 100px;
background-color: #111;
display: inline-block;
}