diff --git a/src/app/app.php b/src/app/app.php index 195880b..74d75a5 100644 --- a/src/app/app.php +++ b/src/app/app.php @@ -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; diff --git a/src/app/views/error.twig b/src/app/views/error.twig new file mode 100644 index 0000000..fdaa5f8 --- /dev/null +++ b/src/app/views/error.twig @@ -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
yourself first to access this page', + 403 : 'sorry, I cannot show you a page
you have not been granted access to', + 404 : "sorry, that page doesn't
exist or has been moved", + 500 : 'sorry,
the server failed to process this page' + } +%} + +
+ +
+ +
+ +

{{ number[ code[0:1] ] }}

+

{{ number[ code[1:1] ] }}

+

{{ number[ code[2:1] ] }}

+ +
+ +
{{ description[ code ] | raw }}
+
+
+ Get in touch with us
if you think this is a mistake +
+ +
+ +
+ +{% endblock %} diff --git a/src/web/css/level2.css b/src/web/css/level2.css index 4cc6885..059413d 100755 --- a/src/web/css/level2.css +++ b/src/web/css/level2.css @@ -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; +}