Added custom HTTP error pages

Added custom HTTP error pages
This commit is contained in:
cp6 2022-09-22 13:29:12 +10:00
parent df9411e1bf
commit 5ef21ec63f
9 changed files with 108 additions and 50 deletions

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Unauthorized'))
@section('code', '401')
@section('message', __('Unauthorized'))

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Forbidden'))
@section('code', '403')
@section('message', __($exception->getMessage() ?: 'Forbidden'))

View File

@ -1,51 +1,5 @@
@section('title') {{'Error'}}
@if(isset($status))
{{$status}}
@else
404
@endif
@endsection
@section('style')
<style>
.page-not-found-div {
height: 100vh;
}
@extends('errors::minimal')
.page-not-found-div h1 {
font-size: 8rem;
color: #e73974;
}
.page-not-found-div h3 {
font-size: 2.5rem;
}
.page-not-found-div .center-div {
width: 100%;
padding: 0.2rem;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
@endsection
<x-app-layout>
<div class="page-not-found-div">
<div class="center-div">
@if(isset($status))
<h1>{{$status}}</h1>
@else
<h1>Error</h1>
@endif
@if(isset($title))
<h3 class="mt-2">{{$title}}</h3>
@endif
@if(isset($message))
<p class="mt-4">{{$message}}</p>
@endif
<p class="mt-4"><a href="{{route('/')}}" class="text-decoration-none">Go home</a></p>
</div>
</div>
</x-app-layout>
@section('title', __('Not Found'))
@section('code', '404')
@section('message', __('Page not Found'))

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Page Expired'))
@section('code', '419')
@section('message', __('Page Expired'))

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Too Many Requests'))
@section('code', '429')
@section('message', __('Too Many Requests'))

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Server Error'))
@section('code', '500')
@section('message', __('Server Error'))

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Service Unavailable'))
@section('code', '503')
@section('message', __('Service Unavailable'))

View File

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@yield('title')</title>
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #636b6f;
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-weight: 100;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.content {
text-align: center;
}
.title {
font-size: 36px;
padding: 20px;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title">
@yield('message')
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@yield('title')</title>
<style>
@charset "UTF-8";h1,p{margin-top:0}.container,.row{--bs-gutter-x:1.5rem;--bs-gutter-y:0}.row,body{display:flex}.main,.sub{text-align:center!important}:root{--bs-body-color-rgb:33,37,41;--bs-body-bg-rgb:255,255,255;--bs-font-sans-serif:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue","Noto Sans","Liberation Sans",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--bs-font-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--bs-gradient:linear-gradient(180deg,rgba(255, 255, 255, 0.15),rgba(255, 255, 255, 0));--bs-body-font-family:var(--bs-font-sans-serif);--bs-body-font-size:1rem;--bs-body-font-weight:400;--bs-body-line-height:1.5;--bs-body-color:#212529;--bs-body-bg:#fff;--bs-border-width:1px;--bs-border-style:solid;--bs-border-color:#dee2e6;--bs-border-color-translucent:rgba(0, 0, 0, 0.175);--bs-border-radius:0.375rem;--bs-border-radius-sm:0.25rem;--bs-border-radius-lg:0.5rem;--bs-border-radius-xl:1rem;--bs-border-radius-2xl:2rem;--bs-border-radius-pill:50rem;--bs-link-color:#0d6efd;--bs-link-hover-color:#0a58ca;--bs-code-color:#d63384;--bs-highlight-bg:#fff3cd}*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}.main,h1{font-weight:500;line-height:1.2}h1{margin-bottom:.5rem;font-size:calc(1.375rem + 1.5vw)}p{margin-bottom:1rem}a{color:var(--bs-link-color);color:#277dfd;text-decoration:none}a:hover{color:var(--bs-link-hover-color)}.container,.row>*{width:100%;padding-right:calc(var(--bs-gutter-x) * .5);padding-left:calc(var(--bs-gutter-x) * .5)}.container{margin-right:auto;margin-left:auto}@media (min-width:576px){.container{max-width:540px}}@media (min-width:768px){.container{max-width:720px}}@media (min-width:992px){.container{max-width:960px}}@media (min-width:1200px){h1{font-size:2.5rem}.container{max-width:1140px}}@media (min-width:1400px){.container{max-width:1320px}}.row{flex-wrap:wrap;margin-top:calc(-1 * var(--bs-gutter-y));margin-right:calc(-.5 * var(--bs-gutter-x));margin-left:calc(-.5 * var(--bs-gutter-x))}.row>*{flex-shrink:0;max-width:100%;margin-top:var(--bs-gutter-y)}.visually-hidden-focusable:not(:focus):not(:focus-within){position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}.w-100{width:100%!important}.justify-content-center{justify-content:center!important}.m-auto{margin:auto!important}body,html{height:100%}body{align-items:center;background-color:#fbfbfb}.main{font-size:2.1rem;padding-bottom:.8rem!important;margin-bottom:0;padding-top:.2rem!important}.sub{font-size:1rem;font-weight:300;color:#000000a8}
</style>
</head>
<body>
<main class="w-100 m-auto">
<div class="container">
<div class="row justify-content-center">
<h1 class="main">@yield('code')</h1>
<p class="sub">@yield('message'). <a href="{{route('/')}}">Go home</a></p>
</div>
</div>
</main>
</body>
</html>