Compare commits

...

21 commits

Author SHA1 Message Date
Nico Schottelius
64e4c3813d + new picture
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
2019-02-05 15:44:37 +01:00
Nico Schottelius
23674cc061 Update view, remove debug printing 2019-02-05 15:25:15 +01:00
Nico Schottelius
926c59276b ++format 2019-02-05 15:18:38 +01:00
Nico Schottelius
ce6f4c5ff5 Reformat again :-) 2019-02-05 15:17:04 +01:00
Nico Schottelius
32ac399c7f Reduce re.match to official name only 2019-02-05 15:11:00 +01:00
Nico Schottelius
243e10d809 Update picture, update documentation 2019-02-05 15:10:21 +01:00
Nico Schottelius
daa48c907f Shrink down text / make it easier to understand 2019-02-05 14:59:46 +01:00
PCoder
29684a52e0 Add a hyperlink to the domain if back_to GET parameter is passed 2019-02-02 22:23:46 +01:00
PCoder
334043c832 Add CHANGELOG.md 2019-02-02 21:59:52 +01:00
PCoder
4c9079e025 Fix bug: the way we get the string env 2019-02-02 21:47:31 +01:00
PCoder
23c35162ac Add STATIC_ROOT path 2019-02-02 21:41:50 +01:00
PCoder
b9b1a07eeb Improve some styles 2019-02-02 21:35:21 +01:00
PCoder
c6517f091a Add url for favicon.ico 2019-02-02 21:35:07 +01:00
PCoder
0733925af0 Add content of the page 2019-02-02 21:15:15 +01:00
PCoder
37e90729c0 Add favicon.ico 2019-02-02 20:47:52 +01:00
PCoder
559c2c9170 Remove STATIC_ROOT config 2019-01-30 00:43:58 +01:00
PCoder
678f6f424e Add a case when back_to is not set 2019-01-30 00:38:09 +01:00
PCoder
bed453a208 Put text below the image 2019-01-30 00:13:34 +01:00
PCoder
b590f3c497 Add STATIC_ROOT 2019-01-30 00:04:02 +01:00
PCoder
e2202ae53d Add a basic index.html with deadend image 2019-01-29 23:56:51 +01:00
PCoder
047ce05375 Remove .env.sample 2019-01-29 20:43:54 +01:00
8 changed files with 124 additions and 26 deletions

View file

@ -1,3 +0,0 @@
DEBUG=False
SECRET_KEY=phaxiz3uqu4eiD4gaipoSh3Ao2Aim9jie6aS2liec1yi0ogi
ALLOWED_HOSTS=*,

8
CHANGELOG.md Normal file
View file

@ -0,0 +1,8 @@
# The no-ipv4-here project
## [Unreleased]
- Add a hyperlink to the domain if `back_to` GET parameter is passed
## [1.0.0] - 2019-02-02
### Added
- The first basic version of the project

View file

@ -0,0 +1,74 @@
{% 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;
}
.content-margin {
margin: 20px 10%;
}
body {
font-family: Helvetica, sans-serif;
font-size: 15pt;
color: black;
}
.para-title{
font-weight: 600;
}
footer{
margin: 50px 0 25px;
}
</style>
<title>{{ domain|default:"This part of the Internet" }} is not
reachable by IPv4</title>
<meta name="keywords" content="IPv6, IPv4, End of IPv4, IPv6 only">
<meta name="description" content="The end of the IPv4 Internet">
</head>
<body>
<img src="{% static 'img/ipv6onlyhosting-ungleich-deadend.jpg' %}"
alt="ipv6onlyhosting-ungleich-deadend"
class="responsive" width="600" height="400">
<div class="center content-margin">
<p>
You have reached the end of the IPv4 Internet.
{% if back_to_url != "" %}
<br>
The site {{ domain }} is not reachable by IPv4.
To access
<a href="{{ back_to_url }}" target="_blank">{{ domain }}</a>,
you need to enable IPv6 on your computer.
{% endif %}
<br>
Find out
<a href="https://ungleich.ch/en-us/cms/blog/2019/02/05/how-to-get-ipv6/">
how to enable IPv6</a>.
<br>
<a href="https://redmine.ungleich.ch/projects/open-infrastructure/wiki/How_to_disable_IPv4_on_your_website">How
to use this service</a> for your IPv6 only service.
</p>
</div>
<footer class="center">
This service is provided to you by <a href="https://ungleich.ch" target="_blank">ungleich</a>.
</footer>
</body>
</html>

View file

@ -1,23 +1,28 @@
from django.http import HttpResponse from urllib.parse import urlsplit
from django.views.generic import TemplateView
import re
# Create your views here. # Create your views here.
def index(request): class IndexView(TemplateView):
back_to_url = "" template_name = 'no_ipv4_here/index.html'
if "back_to" in request.GET:
back_to_url = request.GET["back_to"] def get_context_data(self, **kwargs):
elif 'HTTP_HOST' in request.META: context = super(IndexView, self).get_context_data(**kwargs)
back_to_url = request.META['HTTP_HOST'] back_to_url = ""
if back_to_url != "":
return HttpResponse( if "back_to" in self.request.GET:
"""Sorry, <a href="{domain}">this part of domain</a> is not reachable by IPv4. back_to_url = self.request.GET["back_to"]
Please upgrade to IPv6 and try to reach {domain} again.""".format( elif 'HTTP_HOST' in self.request.META:
domain=back_to_url # Exclude ourselves
) if not re.match("^(no-ipv4-here.ungleich.ch|localhost)", self.request.META['HTTP_HOST']):
) back_to_url = "http://{}".format(self.request.META['HTTP_HOST'])
else:
return HttpResponse(
"""Sorry, this part of domain is not reachable by IPv4. context['back_to_url'] = back_to_url
Please upgrade to IPv6 and try to reach the domain again.""" if back_to_url != "":
) context['domain'] = (urlsplit(back_to_url)).netloc
return context

BIN
static/img/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

View file

@ -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,10 @@ 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'),
)
STATIC_ROOT = env.str('STATIC_ROOT', os.path.join(BASE_DIR, '/staticfiles/'))

View file

@ -13,12 +13,19 @@ 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 django.views.generic import RedirectView
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),
url(r'^favicon\.ico$',
RedirectView.as_view(url='/static/img/favicon.ico')),
] ]
urlpatterns += staticfiles_urlpatterns()