feat: ❌ improve error pages
This commit is contained in:
parent
d1c04619ba
commit
745a2d188b
5 changed files with 93 additions and 0 deletions
|
|
@ -23,6 +23,10 @@ from moku.views.user import (
|
||||||
UserJSONView,
|
UserJSONView,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
handler403 = "moku.views.error.forbidden"
|
||||||
|
handler404 = "moku.views.error.not_found"
|
||||||
|
handler500 = "moku.views.error.server_error"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("", FeedView.as_view(), name="feed"),
|
path("", FeedView.as_view(), name="feed"),
|
||||||
|
|
|
||||||
8
moku/templates/moku/error/403.jinja
Normal file
8
moku/templates/moku/error/403.jinja
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{% extends "moku/base.jinja" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="content block">
|
||||||
|
<h2>❌ {% trans %}it doesn't look like you should be there!{% endtrans %}</h2>
|
||||||
|
<p>{% trans %}take a look at the links at the top of the page to see if you can end up somewhere you're supposed to be. :){% endtrans %}</p>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
||||||
12
moku/templates/moku/error/404.jinja
Normal file
12
moku/templates/moku/error/404.jinja
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{% extends "moku/base.jinja" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="content block">
|
||||||
|
<h2>🧭 {% trans %}are you lost?{% endtrans %}</h2>
|
||||||
|
<p>{% trans %}it doesn't look like this is a page that exists, sorry.{% endtrans %}</p>
|
||||||
|
<p>{% trans %}the links at the top of the page should help you get back to where you want to be!{% endtrans%}</p>
|
||||||
|
<p class="mt subtle">{% trans email="m5ka@posteo.de" %}
|
||||||
|
do you think something might be wrong? send me an email at {{ email }}{% endtrans %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
||||||
56
moku/templates/moku/error/500.html
Normal file
56
moku/templates/moku/error/500.html
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>not found — moku.blog</title>
|
||||||
|
<style type="text/css">
|
||||||
|
@import url('https://fonts.googleapis.com/css2?family=Solway:wght@400;700&display=swap');
|
||||||
|
:root {
|
||||||
|
--tangerine: #F7A278;
|
||||||
|
--orange: #c94c10;
|
||||||
|
--champagne: #FDE4D8;
|
||||||
|
--dusty-champagne: #EFC6B8;
|
||||||
|
--charcoal: #626262;
|
||||||
|
--font-family: 'Solway', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||||
|
}
|
||||||
|
html {
|
||||||
|
font-size: 62.5%;
|
||||||
|
line-height: 1.5;
|
||||||
|
-webkit-text-size-adjust: 100%;
|
||||||
|
-ms-text-size-adjust: 100%;
|
||||||
|
text-size-adjust: 100%;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: var(--font-family);
|
||||||
|
font-size: 1.6rem;
|
||||||
|
line-height: 1.2;
|
||||||
|
background: var(--dusty-champagne);
|
||||||
|
max-width: 568px;
|
||||||
|
padding: 2.4rem 1.2rem;
|
||||||
|
margin-inline: auto;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--orange);
|
||||||
|
text-decoration-skip-ink: none;
|
||||||
|
text-underline-offset: 2px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: wavy underline;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>🍔 moku.blog</h1>
|
||||||
|
<h2>❌ server error</h2>
|
||||||
|
<p>oops! it looks like something's gone a bit wrong.</p>
|
||||||
|
<p>if the issue keeps happening, please get in touch: m5ka@posteo.de</p>
|
||||||
|
<h3>get back to where you need to be...</h3>
|
||||||
|
<ul>
|
||||||
|
<li><a href="/feed">feed</a></li>
|
||||||
|
<li><a href="/blog">change blog</a></li>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
13
moku/views/error.py
Normal file
13
moku/views/error.py
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
|
||||||
|
def forbidden(request, exception):
|
||||||
|
return render(request, "moku/error/403.jinja")
|
||||||
|
|
||||||
|
|
||||||
|
def not_found(request, exception):
|
||||||
|
return render(request, "moku/error/404.jinja")
|
||||||
|
|
||||||
|
|
||||||
|
def server_error(request):
|
||||||
|
return render(request, "moku/error/500.html")
|
||||||
Loading…
Reference in a new issue