Add a basic index.html with deadend image
This commit is contained in:
parent
047ce05375
commit
e2202ae53d
5 changed files with 68 additions and 23 deletions
37
no_ipv4_here/templates/no_ipv4_here/index.html
Normal file
37
no_ipv4_here/templates/no_ipv4_here/index.html
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{% load static from staticfiles %}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<style>
|
||||||
|
.responsive {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 496px;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="center">
|
||||||
|
<p>
|
||||||
|
Sorry, this part of {{ domain }} is not reachable by IPv4. Please
|
||||||
|
upgrade to IPv6 and try to reach <a
|
||||||
|
href="{{ back_to_url }}">{{ domain }}</a> again.</p>
|
||||||
|
</div>
|
||||||
|
<img src="{% static 'img/ipv6onlyhosting-ungleich-deadend.jpg' %}"
|
||||||
|
alt="ipv6onlyhosting-ungleich-deadend"
|
||||||
|
class="responsive" width="600" height="400">
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,23 +1,23 @@
|
||||||
from django.http import HttpResponse
|
from urllib.parse import urlsplit
|
||||||
|
|
||||||
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
def index(request):
|
class IndexView(TemplateView):
|
||||||
|
template_name = 'no_ipv4_here/index.html'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(IndexView, self).get_context_data(**kwargs)
|
||||||
back_to_url = ""
|
back_to_url = ""
|
||||||
if "back_to" in request.GET:
|
if "back_to" in self.request.GET:
|
||||||
back_to_url = request.GET["back_to"]
|
back_to_url = self.request.GET["back_to"]
|
||||||
elif 'HTTP_HOST' in request.META:
|
elif 'HTTP_HOST' in self.request.META:
|
||||||
back_to_url = request.META['HTTP_HOST']
|
back_to_url = self.request.META['HTTP_HOST']
|
||||||
|
context['back_to_url'] = back_to_url
|
||||||
if back_to_url != "":
|
if back_to_url != "":
|
||||||
return HttpResponse(
|
context['domain'] = (urlsplit(back_to_url)).netloc
|
||||||
"""Sorry, <a href="{domain}">this part of domain</a> is not reachable by IPv4.
|
|
||||||
Please upgrade to IPv6 and try to reach {domain} again.""".format(
|
|
||||||
domain=back_to_url
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
return HttpResponse(
|
context['domain'] = "the domain"
|
||||||
"""Sorry, this part of domain is not reachable by IPv4.
|
return context
|
||||||
Please upgrade to IPv6 and try to reach the domain again."""
|
|
||||||
)
|
|
||||||
|
|
BIN
static/img/ipv6onlyhosting-ungleich-deadend.jpg
Normal file
BIN
static/img/ipv6onlyhosting-ungleich-deadend.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 98 KiB |
|
@ -62,8 +62,8 @@ ROOT_URLCONF = 'ungleich_no_ipv4_here.urls'
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [os.path.join(BASE_DIR, 'templates')]
|
'DIRS': [os.path.join(BASE_DIR,
|
||||||
,
|
'no_ipv4_here/templates')],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
|
@ -123,3 +123,7 @@ USE_TZ = True
|
||||||
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
STATICFILES_DIRS = (
|
||||||
|
os.path.join(BASE_DIR, 'static'),
|
||||||
|
)
|
||||||
|
|
|
@ -13,12 +13,16 @@ Including another URLconf
|
||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
|
from django.conf.urls import url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from no_ipv4_here import views
|
from no_ipv4_here.views import IndexView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.index, name='index'),
|
url(r'^$', IndexView.as_view(), name='index'),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
urlpatterns += staticfiles_urlpatterns()
|
||||||
|
|
Loading…
Reference in a new issue