kopia lustrzana https://github.com/wagtail/wagtail
Added 404 page
rodzic
6570cf1a76
commit
a649e632b7
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="430" height="537" viewBox="0 0 430 537"><path d="M341 77.4c.2 0 .4 0 .5-.3l.6-.6.5-.6.4-1s.2 0 .4-.3c0-.3.4-.5.6-.8 0-.2.4-.5.7-.7l.7-.4c.4 0 .5-.4 1-.6l.6-.4c.2 0 .3-.2.5-.3l.7-.4.5-.4.7-.4.7-.5.8-.4.5-.3c.3-.3.5-.3 1-.5l.6-.4.6-.2s.4 0 .7-.3l.7-.3c.4 0 .7-.2 1-.4h.7l.5-.3h.6l.7-.4h.6l.7-.2h4.5c.4.2.7.2 1 .2h.8c.3 0 .4 0 .6.2h1l.5.2h.5c.3 0 .5.4.7.4h.7c0 .2.4.2 1 .4l.7.3h.8l.7.4h.5" stroke-opacity="null" stroke-width="12" stroke="#231F20" fill="none"/></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="430" height="537" viewBox="0 0 430 537"><path d="M343 77.2c14-16 33.8-7 33.8-7" fill="none" stroke="#231f20" stroke-width="12"/></svg>
|
||||
|
|
Przed Szerokość: | Wysokość: | Rozmiar: 511 B Po Szerokość: | Wysokość: | Rozmiar: 182 B |
|
@ -65,7 +65,8 @@
|
|||
display: block;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 60px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
transition: inherit;
|
||||
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
@import 'wagtailadmin/scss/variables';
|
||||
@import 'wagtailadmin/scss/mixins';
|
||||
@import 'wagtailadmin/scss/grid';
|
||||
|
||||
.page404__bg {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: $color-teal-darker;
|
||||
font-family: $font-sans;
|
||||
color: $color-white;
|
||||
}
|
||||
|
||||
.page404__wrapper {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.wagtail-logo-container__desktop {
|
||||
float: left;
|
||||
width: 400px;
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
.page404__text-container {
|
||||
float: right;
|
||||
width: 600px;
|
||||
height: 500px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.page404__header {
|
||||
font-size: 6.8em;
|
||||
margin-bottom: 0.2em;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.page404__text {
|
||||
font-size: 2.25em;
|
||||
line-height: 1.25em;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
a.button.page404__button { // more specific to override standard button styles
|
||||
font-size: 1.5em;
|
||||
line-height: 2em;
|
||||
height: 2.5em;
|
||||
padding: 0 0.5em;
|
||||
background-color: $color-teal-darker;
|
||||
border: 4px solid $color-teal;
|
||||
color: inherit;
|
||||
|
||||
&:hover {
|
||||
background-color: $color-teal;
|
||||
}
|
||||
}
|
||||
|
||||
// SMALL DESKTOP CHANGES:
|
||||
@media screen and (max-width: $breakpoint-desktop-small) { // 900px
|
||||
.wagtail-logo-container__desktop {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
// MOBILE CHANGES:
|
||||
@media screen and (max-width: $breakpoint-mobile) { // 800px
|
||||
.page404__text-container {
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
.page404__header {
|
||||
font-size: 5em;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
{% extends "wagtailadmin/admin_base.html" %}
|
||||
{% load wagtailadmin_tags wagtailcore_tags staticfiles i18n %}
|
||||
{% block titletag %}{% trans "Error 404: Page not found" %}{% endblock %}
|
||||
|
||||
|
||||
{% block extra_css %}
|
||||
{{ block.super }}
|
||||
|
||||
<link rel="stylesheet" href="{% static 'wagtailadmin/css/layouts/404.css' %}" />
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block furniture %}
|
||||
<div class="page404__bg">
|
||||
<div class="page404__wrapper">
|
||||
{% include "wagtailadmin/shared/animated_logo.html" %}
|
||||
|
||||
<div class="page404__text-container">
|
||||
<h1 class="page404__header">
|
||||
{% trans "Error 404" %}
|
||||
</h1>
|
||||
|
||||
<p class="page404__text">
|
||||
{% trans "The requested page could not be found." %}
|
||||
</p>
|
||||
|
||||
<a class="page404__button button" href="/admin/">{% trans "Go to Wagtail admin" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -12,12 +12,7 @@
|
|||
</div>
|
||||
|
||||
{# Desktop logo (animated): #}
|
||||
<div class="wagtail-logo-container__desktop u-hidden@small">
|
||||
<img class="wagtail-logo wagtail-logo__body" src="{% static 'wagtailadmin/images/logo-body.svg' %}" alt=""/>
|
||||
<img class="wagtail-logo wagtail-logo__tail" src="{% static 'wagtailadmin/images/logo-tail.svg' %}" alt="" />
|
||||
<img class="wagtail-logo wagtail-logo__eye--open" src="{% static 'wagtailadmin/images/logo-eyeopen.svg' %}" alt="" />
|
||||
<img class="wagtail-logo wagtail-logo__eye--closed" src="{% static 'wagtailadmin/images/logo-eyeclosed.svg' %}" alt="" />
|
||||
</div>
|
||||
{% include "wagtailadmin/shared/animated_logo.html" %}
|
||||
{% endblock %}
|
||||
<span class="u-hidden@medium">{% trans "Dashboard" %}</span>
|
||||
</a>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{% load wagtailadmin_tags staticfiles %}
|
||||
|
||||
<div class="wagtail-logo-container__desktop u-hidden@small">
|
||||
<img class="wagtail-logo wagtail-logo__body" src="{% static 'wagtailadmin/images/logo-body.svg' %}" alt=""/>
|
||||
<img class="wagtail-logo wagtail-logo__tail" src="{% static 'wagtailadmin/images/logo-tail.svg' %}" alt="" />
|
||||
<img class="wagtail-logo wagtail-logo__eye--open" src="{% static 'wagtailadmin/images/logo-eyeopen.svg' %}" alt="" />
|
||||
<img class="wagtail-logo wagtail-logo__eye--closed" src="{% static 'wagtailadmin/images/logo-eyeclosed.svg' %}" alt="" />
|
||||
</div>
|
|
@ -1,5 +1,10 @@
|
|||
import functools
|
||||
|
||||
from django.conf.urls import url, include
|
||||
from django.views.decorators.cache import cache_control
|
||||
from django.views.generic import TemplateView
|
||||
from django.http import Http404
|
||||
from django.views.defaults import page_not_found
|
||||
|
||||
from wagtail.wagtailadmin.urls import pages as wagtailadmin_pages_urls
|
||||
from wagtail.wagtailadmin.urls import collections as wagtailadmin_collections_urls
|
||||
|
@ -14,6 +19,8 @@ from wagtail.wagtailadmin.decorators import require_admin_access
|
|||
urlpatterns = [
|
||||
url(r'^$', home.home, name='wagtailadmin_home'),
|
||||
|
||||
url(r'^test404/$', TemplateView.as_view(template_name='wagtailadmin/404.html')),
|
||||
|
||||
url(r'api/', include(api_urls)),
|
||||
|
||||
url(r'^failwhale/$', home.error_test, name='wagtailadmin_error_test'),
|
||||
|
@ -73,8 +80,28 @@ urlpatterns += [
|
|||
|
||||
# Password reset
|
||||
url(r'^password_reset/', include(wagtailadmin_password_reset_urls)),
|
||||
|
||||
# Default view (will show 404 page)
|
||||
# This must be the last URL in this file!
|
||||
url(r'^', home.default),
|
||||
]
|
||||
|
||||
|
||||
# Hook in our own 404 handler
|
||||
def display_custom_404(view_func):
|
||||
@functools.wraps(view_func)
|
||||
def wrapper(request, *args, **kwargs):
|
||||
try:
|
||||
return view_func(request, *args, **kwargs)
|
||||
except Http404:
|
||||
return page_not_found(request, '', template_name='wagtailadmin/404.html')
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
urlpatterns = decorate_urlpatterns(urlpatterns, display_custom_404)
|
||||
|
||||
|
||||
# Decorate all views with cache settings to prevent caching
|
||||
urlpatterns = decorate_urlpatterns(
|
||||
urlpatterns,
|
||||
|
|
|
@ -2,8 +2,10 @@ from __future__ import absolute_import, unicode_literals
|
|||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
from django.db import connection
|
||||
from django.db.models import Max
|
||||
from django.http import Http404
|
||||
from django.shortcuts import render
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
|
@ -12,7 +14,6 @@ from wagtail.wagtailadmin.site_summary import SiteSummaryPanel
|
|||
from wagtail.wagtailcore import hooks
|
||||
from wagtail.wagtailcore.models import Page, PageRevision, UserPagePermissionsProxy
|
||||
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
|
@ -123,3 +124,15 @@ def home(request):
|
|||
|
||||
def error_test(request):
|
||||
raise Exception("This is a test of the emergency broadcast system.")
|
||||
|
||||
|
||||
@permission_required('wagtailadmin.access_admin', login_url='wagtailadmin_login')
|
||||
def default(request):
|
||||
"""
|
||||
Called whenever a request comes in with the correct prefix (eg /admin/) but
|
||||
doesn't actually correspond to a Wagtail view.
|
||||
|
||||
For authenticated users, it'll raise a 404 error. Anonymous users will be
|
||||
redirected to the login page.
|
||||
"""
|
||||
raise Http404
|
||||
|
|
Ładowanie…
Reference in New Issue