Add customized 404 page

This commit is contained in:
DariusIII
2017-08-10 13:44:06 +02:00
parent 66f1e54971
commit 7789c08515
4 changed files with 54 additions and 18 deletions
+1
View File
@@ -1,4 +1,5 @@
2017-08-10 DariusIII
* Chg: Add customized 404 page
* Chg: Handle 500 errors in production properly
* Chg: Further improve maintenance mode
2017-08-09 DariusIII
+6
View File
@@ -6,6 +6,7 @@ use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Handler extends ExceptionHandler
{
@@ -50,6 +51,11 @@ class Handler extends ExceptionHandler
return response()->view('errors.404', [], 404);
}
if ($exception instanceof NotFoundHttpException)
{
return response()->view('errors.404', [], 404);
}
if ($this->isHttpException($exception)) {
return $this->renderHttpException($exception);
}
+4 -18
View File
@@ -241,25 +241,10 @@ class BasePage
/**
* Show 404 page.
*/
public function show404()
public function show404(): void
{
header('HTTP/1.1 404 Not Found');
exit(
sprintf('
<html>
<head>
<title>404 - File not found.</title>
</head>
<body>
<h1>404 - File not found.</h1>
<p>%s%s</p>
<p>We could not find the above page or file on our servers.</p>
</body>
</html>',
$this->serverurl,
$this->page
)
);
die(view('errors.404'));
}
/**
@@ -306,7 +291,7 @@ class BasePage
* Show maintenance page.
*
*/
public function showMaintenance()
public function showMaintenance(): void
{
header('HTTP/1.1 503 Service Temporarily Unavailable');
die(view('errors.503'));
@@ -337,6 +322,7 @@ class BasePage
die();
}
public function render()
{
$this->smarty->display($this->page_template);
+43
View File
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<title>HTTP/1.1 404 Not Found</title>
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
<style>
html, body {
height: 100%;
}
body {
margin: 0;
padding: 0;
width: 100%;
color: #B0BEC5;
display: table;
font-weight: 100;
font-family: \'Lato\', sans-serif;
}
.container {
text-align: center;
display: table-cell;
vertical-align: middle;
}
.content {
text-align: center;
display: inline-block;
}
.title {
font-size: 72px;
margin-bottom: 40px;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<div class="title">We could not find page you are looking for. <br> Monkeys are hard at work to find it for you! <br> Or you could try on your own. </div>
</div>
</div>
</body>
</html>