From ca32c61c7fdf58a97d250c34f9f26fcd12e59edf Mon Sep 17 00:00:00 2001 From: DerTyp187 Date: Fri, 19 Nov 2021 10:14:56 +0100 Subject: [PATCH] added sitemap and robots.txt --- TealCode/TealCode/urls.py | 5 ++++- TealCode/main/templates/base.html | 6 ++++-- TealCode/main/templates/robots.txt | 4 ++++ TealCode/main/templates/sitemap.xml | 22 ++++++++++++++++++++++ TealCode/main/views.py | 4 +++- 5 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 TealCode/main/templates/robots.txt create mode 100644 TealCode/main/templates/sitemap.xml diff --git a/TealCode/TealCode/urls.py b/TealCode/TealCode/urls.py index dd8007f..36ba2d2 100644 --- a/TealCode/TealCode/urls.py +++ b/TealCode/TealCode/urls.py @@ -15,9 +15,12 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, include +from django.views.generic.base import TemplateView urlpatterns = [ path('', include('main.urls')), path('analytics/', include('analytics.urls')), - path('SDGFOLKJASDNVASDFASDFSLAKDF/', admin.site.urls), + path("robots.txt", TemplateView.as_view(template_name="robots.txt", content_type="text/plain")), + path("sitemap.xml", TemplateView.as_view(template_name="sitemap.xml", content_type="text/xml")), + path('AD/SDGFOLKJASDNVASDFASDFSLAKDF/', admin.site.urls), ] diff --git a/TealCode/main/templates/base.html b/TealCode/main/templates/base.html index f5673df..5012c23 100644 --- a/TealCode/main/templates/base.html +++ b/TealCode/main/templates/base.html @@ -4,8 +4,10 @@ - - + + + + diff --git a/TealCode/main/templates/robots.txt b/TealCode/main/templates/robots.txt new file mode 100644 index 0000000..08f443f --- /dev/null +++ b/TealCode/main/templates/robots.txt @@ -0,0 +1,4 @@ +User-Agent: * +Disallow: /AD/ +Disallow: /AD/* +Disallow: /AD \ No newline at end of file diff --git a/TealCode/main/templates/sitemap.xml b/TealCode/main/templates/sitemap.xml new file mode 100644 index 0000000..6109335 --- /dev/null +++ b/TealCode/main/templates/sitemap.xml @@ -0,0 +1,22 @@ + + + + https://code.tealfire.de/ + 2021-11-19T20:00:06+00:00 + 1.00 + + + https://code.tealfire.de/about/ + 2021-11-19T20:00:06+00:00 + 0.70 + + + https://code.tealfire.de/privacy/ + 2021-11-19T20:00:06+00:00 + 0.70 + + + + + + \ No newline at end of file diff --git a/TealCode/main/views.py b/TealCode/main/views.py index 5dda026..9fb86d0 100644 --- a/TealCode/main/views.py +++ b/TealCode/main/views.py @@ -1,3 +1,4 @@ +from django.http.response import HttpResponse from django.shortcuts import render, redirect from .models import Category, Topic from analytics.models import View @@ -65,10 +66,11 @@ def about(req): def privacy(req): return render(req, "main/privacy.html") + def get_client_ip(req): x_forwarded_for = req.META.get("HTTP_X_FORWARDED_FOR") if x_forwarded_for: ip = x_forwarded_for.split[","][0] else: ip = req.META.get("REMOTE_ADDR") - return ip \ No newline at end of file + return ip