From dd7a69aa5098c01aaccb51271d3159238bf4227b Mon Sep 17 00:00:00 2001 From: zero Date: Wed, 17 Aug 2022 16:42:06 +0200 Subject: [PATCH] 42CTF/website#72 |42CTF/website#36 sitemap and titles fixed --- src/ctfs/sitemaps.py | 26 +++++++++ src/ctfs/templates/ctfs/ctf_info.html | 2 +- src/ctfs/templates/ctfs/ctfs_list.html | 4 +- src/ctfs/urls.py | 10 +++- src/events/sitemaps.py | 24 ++++++++ src/events/templates/events/ctf_info.html | 2 +- src/events/templates/events/event_info.html | 2 +- src/events/templates/events/events_list.html | 4 +- src/events/urls.py | 8 +++ src/home/sitemaps.py | 12 ++++ src/home/templates/cgu.html | 2 +- src/home/urls.py | 7 +++ src/home/views.py | 7 ++- src/project/settings.py | 1 + src/resources/sitemaps.py | 12 ++++ src/resources/templates/resources/about.html | 58 +++++++++---------- .../templates/resources/becomeMember.html | 5 +- .../templates/resources/contribute.html | 3 + .../templates/resources/create_challenge.html | 4 +- src/resources/templates/resources/edit.html | 6 +- .../templates/resources/howToStart.html | 4 ++ src/resources/templates/resources/tools.html | 4 +- src/resources/urls.py | 7 ++- .../templates/scoreboard/scoreboard.html | 4 +- src/statics/css/style.css | 7 ++- src/templates/base.html | 2 +- 26 files changed, 175 insertions(+), 52 deletions(-) create mode 100644 src/ctfs/sitemaps.py create mode 100644 src/events/sitemaps.py create mode 100644 src/home/sitemaps.py create mode 100644 src/resources/sitemaps.py diff --git a/src/ctfs/sitemaps.py b/src/ctfs/sitemaps.py new file mode 100644 index 0000000..8ba0136 --- /dev/null +++ b/src/ctfs/sitemaps.py @@ -0,0 +1,26 @@ +from django.contrib import sitemaps +from django.urls import reverse +from .models import Category, CTF +from .views import category, ctf + +class CategorySitemap(sitemaps.Sitemap): + changefreq = "weekly" + priority = 0.7 + i18n = True + + def items(self): + return Category.objects.all() + + def location(self, obj): + return reverse(category, kwargs={'cat_slug': obj.slug}) + +class CTFSitemap(sitemaps.Sitemap): + changefreq = "weekly" + priority = 0.7 + i18n = True + + def items(self): + return CTF.objects.all() + + def location(self, obj): + return reverse(ctf, kwargs={'cat_slug': obj.category.slug, 'ctf_slug': obj.slug}) \ No newline at end of file diff --git a/src/ctfs/templates/ctfs/ctf_info.html b/src/ctfs/templates/ctfs/ctf_info.html index 453697f..18eca46 100644 --- a/src/ctfs/templates/ctfs/ctf_info.html +++ b/src/ctfs/templates/ctfs/ctf_info.html @@ -8,7 +8,7 @@
-

{{ ctf.name }}

+

{{ ctf.name }}

{% trans "Published date" %} : {{ ctf.pub_date }}
{% if date < ctf.pub_date %} diff --git a/src/ctfs/templates/ctfs/ctfs_list.html b/src/ctfs/templates/ctfs/ctfs_list.html index 68d1982..9bcd50f 100755 --- a/src/ctfs/templates/ctfs/ctfs_list.html +++ b/src/ctfs/templates/ctfs/ctfs_list.html @@ -2,8 +2,10 @@ {% block content %} {% load i18n %}
+
+

{{ cat.name }}

+
-

{{ cat.name }}

{% if ctfs %} diff --git a/src/ctfs/urls.py b/src/ctfs/urls.py index 94e774e..7d39b8f 100644 --- a/src/ctfs/urls.py +++ b/src/ctfs/urls.py @@ -1,7 +1,15 @@ +from django.contrib.sitemaps.views import sitemap from django.urls import path +from .sitemaps import CategorySitemap, CTFSitemap from . import views +sitemaps = { + 'categories': CategorySitemap(), + 'challenges': CTFSitemap(), +} + urlpatterns = [ path('/', views.category, name='category'), - path('/', views.ctf, name='ctf') + path('/', views.ctf, name='ctf'), + path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), ] diff --git a/src/events/sitemaps.py b/src/events/sitemaps.py new file mode 100644 index 0000000..563c395 --- /dev/null +++ b/src/events/sitemaps.py @@ -0,0 +1,24 @@ +from django.contrib import sitemaps +from django.urls import reverse +from .models import Event + +class EventsSitemap(sitemaps.Sitemap): + changefreq = "daily" + priority = 0.7 + i18n = True + + def items(self): + return Event.objects.all() + + def location(self, obj): + return reverse('events:event_info', kwargs={'event_slug': obj.slug}) + +class StaticViewSitemap(sitemaps.Sitemap): + priority = 0.7 + changefreq = 'daily' + i18n = True + def items(self): + return ['events:events'] + + def location(self, item): + return reverse(item) \ No newline at end of file diff --git a/src/events/templates/events/ctf_info.html b/src/events/templates/events/ctf_info.html index 65a2c5f..aca18ef 100644 --- a/src/events/templates/events/ctf_info.html +++ b/src/events/templates/events/ctf_info.html @@ -7,7 +7,7 @@
< Back to event
-

{% trans "Event" %} - {{ event.name }}

+

{% trans "Event" %} - {{ event.name }}

{{ ctf.name }}

{% trans "Published date" %} : {{ ctf.pub_date }}
diff --git a/src/events/templates/events/event_info.html b/src/events/templates/events/event_info.html index 81a1bf2..d1ed50e 100644 --- a/src/events/templates/events/event_info.html +++ b/src/events/templates/events/event_info.html @@ -13,7 +13,7 @@ {% endif %}
-

{{ event.name }}

+

{{ event.name }}

{% if ended == True %} {% trans "This event is over." %} {% else %} diff --git a/src/events/templates/events/events_list.html b/src/events/templates/events/events_list.html index 99051dd..96a66f4 100755 --- a/src/events/templates/events/events_list.html +++ b/src/events/templates/events/events_list.html @@ -2,8 +2,8 @@ {% block content %} {% load i18n %}
-
-

{% trans "Events" %}

+
+

{% trans "Events" %}

{% if events %} {% for ev in events %} diff --git a/src/events/urls.py b/src/events/urls.py index 80a3b78..303b1dd 100644 --- a/src/events/urls.py +++ b/src/events/urls.py @@ -1,10 +1,18 @@ +from django.contrib.sitemaps.views import sitemap from django.urls import path +from .sitemaps import StaticViewSitemap, EventsSitemap from . import views app_name = "events" +sitemaps = { + 'events': EventsSitemap(), + 'static': StaticViewSitemap(), +} + urlpatterns = [ path('', views.events, name='events'), + path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), path('', views.event, name='event_info'), path('/challenge/', views.chall_event_info, name='event_chall_info'), path('pwd/', views.submit_pwd, name='submit_pwd'), diff --git a/src/home/sitemaps.py b/src/home/sitemaps.py new file mode 100644 index 0000000..1815c03 --- /dev/null +++ b/src/home/sitemaps.py @@ -0,0 +1,12 @@ +from django.contrib import sitemaps +from django.urls import reverse + +class StaticViewSitemap(sitemaps.Sitemap): + priority = 0.5 + changefreq = 'monthly' + i18n = True + def items(self): + return ['home', 'cgu'] + + def location(self, item): + return reverse(item) \ No newline at end of file diff --git a/src/home/templates/cgu.html b/src/home/templates/cgu.html index 20170b3..6ad98e6 100644 --- a/src/home/templates/cgu.html +++ b/src/home/templates/cgu.html @@ -4,7 +4,7 @@ {% get_current_language as lang %}
-

Conditions générales d'utilisation du site 42CTF

+

Conditions générales d'utilisation du site 42CTF

Article 1 : Objet
diff --git a/src/home/urls.py b/src/home/urls.py index 9de950d..7a96c88 100644 --- a/src/home/urls.py +++ b/src/home/urls.py @@ -1,7 +1,14 @@ +from django.contrib.sitemaps.views import sitemap from django.urls import path +from .sitemaps import StaticViewSitemap from . import views +sitemaps = { + 'static': StaticViewSitemap(), +} + urlpatterns = [ path('', views.home, name='home'), path('CGU', views.cgu, name='cgu'), + path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), ] diff --git a/src/home/views.py b/src/home/views.py index 275557b..6221457 100644 --- a/src/home/views.py +++ b/src/home/views.py @@ -9,12 +9,15 @@ from django.utils.translation import ( LANGUAGE_SESSION_KEY, check_for_language, get_language, ) from django.core.files.storage import default_storage -import datetime + +# import datetime +from django.utils import timezone + from collections import defaultdict import operator def get_weekly_top(): - week_ago = datetime.datetime.now() - datetime.timedelta(days=7) + week_ago = timezone.now() - timezone.timedelta(days=7) weekly_flags = CTF_flags.objects.filter(flag_date__gt=week_ago, ctf__disabled=False, ctf__event=None) scores = defaultdict(int) diff --git a/src/project/settings.py b/src/project/settings.py index 6fef4e4..c0d765e 100644 --- a/src/project/settings.py +++ b/src/project/settings.py @@ -39,6 +39,7 @@ INSTALLED_APPS = [ 'resources.apps.ResourcesConfig', 'django.contrib.sites', 'api.apps.ApiConfig', + 'django.contrib.sitemaps', ] MIDDLEWARE = [ diff --git a/src/resources/sitemaps.py b/src/resources/sitemaps.py new file mode 100644 index 0000000..003330b --- /dev/null +++ b/src/resources/sitemaps.py @@ -0,0 +1,12 @@ +from django.contrib import sitemaps +from django.urls import reverse + +class StaticViewSitemap(sitemaps.Sitemap): + priority = 0.5 + changefreq = 'monthly' + i18n = True + def items(self): + return ['resources:about', 'resources:howToStart', 'resources:contribute', 'resources:becomeMember'] + + def location(self, item): + return reverse(item) \ No newline at end of file diff --git a/src/resources/templates/resources/about.html b/src/resources/templates/resources/about.html index bd896cb..177b3ab 100644 --- a/src/resources/templates/resources/about.html +++ b/src/resources/templates/resources/about.html @@ -3,34 +3,34 @@ {% load i18n %} {% get_current_language as lang %}
- {% load i18n %} - {% get_current_language as lang %} -
-
-
-

{% trans "What is 42CTF ?" %}

-
-
-

{% trans "A short introduction to CTF" %}

- {% trans "CTF stands for Capture The Flag. It is a cybersecurity competition, where participants have to solve challenges of various categories to gain points and progress on the scoreboard." %} - {% blocktranslate %}The challenges require participants to find sort of passwords called "flags" and to submit them on the platform.{% endblocktranslate %} -

- -

{% trans "Functionment of 42CTF" %}

- {% trans "42CTF is what we call a permanent CTF." %}
- {% trans "Except from the" %} {% translate "events" %}, {% trans "challenges are available on the platform without time limitations." %} - {% trans "The registration on 42CTF is open to everyone, 42 students or not." %}
- {% trans "Events may or may not be open. If you would like to organize an event on 42CTF, feel free to contact us." %}
-

- -

{% trans "42CTF Team" %}

- {% trans "42CTF is managed by 42 students." %}
- {% trans "You can meet the team on" %} .
- {% trans "Challenges are created by various contributors, not necessarily 42 students."%}
- {% trans "Anyone is welcome to submit their own challenges, either on the permanent CTF or for a specific event." %} -
+
+

{% trans "About 42ctf" %}

+
+
+
+
+

{% trans "What is 42CTF ?" %}

+
+
+

{% trans "A short introduction to CTF" %}

+ {% trans "CTF stands for Capture The Flag. It is a cybersecurity competition, where participants have to solve challenges of various categories to gain points and progress on the scoreboard." %} + {% blocktranslate %}The challenges require participants to find sort of passwords called "flags" and to submit them on the platform.{% endblocktranslate %} +

+ +

{% trans "Functionment of 42CTF" %}

+ {% trans "42CTF is what we call a permanent CTF." %}
+ {% trans "Except from the" %} {% translate "events" %}, {% trans "challenges are available on the platform without time limitations." %} + {% trans "The registration on 42CTF is open to everyone, 42 students or not." %}
+ {% trans "Events may or may not be open. If you would like to organize an event on 42CTF, feel free to contact us." %}
+

+ +

{% trans "42CTF Team" %}

+ {% trans "42CTF is managed by 42 students." %}
+ {% trans "You can meet the team on" %} .
+ {% trans "Challenges are created by various contributors, not necessarily 42 students."%}
+ {% trans "Anyone is welcome to submit their own challenges, either on the permanent CTF or for a specific event." %}
- - {% endblock %} -
\ No newline at end of file +
+
+{% endblock %} \ No newline at end of file diff --git a/src/resources/templates/resources/becomeMember.html b/src/resources/templates/resources/becomeMember.html index c35d09b..1123ba3 100644 --- a/src/resources/templates/resources/becomeMember.html +++ b/src/resources/templates/resources/becomeMember.html @@ -4,8 +4,8 @@ {% load i18n %} {% get_current_language as lang %}
-
-

{% trans "Become a 42CTF member" %}

+
+

{% trans "Become a 42CTF member" %}

@@ -43,6 +43,7 @@

{% trans "What do I get ?" %}

+

{% blocktranslate %} - A different color for your pseudo in the scoreboard, to let everyone know you're a member.
- The possibility to play past CTF, with challenges no longer available, in the form of private events with the people of your choice.
diff --git a/src/resources/templates/resources/contribute.html b/src/resources/templates/resources/contribute.html index fb8be97..56b50bd 100644 --- a/src/resources/templates/resources/contribute.html +++ b/src/resources/templates/resources/contribute.html @@ -3,6 +3,9 @@ {% load i18n %} {% get_current_language as lang %}
+
+

{% trans "Contribute to 42ctf" %}

+
{% block donate %} {% include "./donate.html" %} {% endblock %} diff --git a/src/resources/templates/resources/create_challenge.html b/src/resources/templates/resources/create_challenge.html index 875f3c3..b349e96 100644 --- a/src/resources/templates/resources/create_challenge.html +++ b/src/resources/templates/resources/create_challenge.html @@ -3,8 +3,8 @@ {% get_current_language as lang %}
-
-

{% trans "Create new challenges" %}

+
+

{% trans "Create new challenges" %}

{% trans "If you want to create new challenges for 42CTF, send us a message on " %} !

diff --git a/src/resources/templates/resources/edit.html b/src/resources/templates/resources/edit.html index 2a4f666..998b549 100644 --- a/src/resources/templates/resources/edit.html +++ b/src/resources/templates/resources/edit.html @@ -1,10 +1,10 @@ {% block content %} {% load i18n %} {% get_current_language as lang %} -
+
-
-

{% trans "Edit this page" %}

+
+

{% trans "Edit this page" %}


diff --git a/src/resources/templates/resources/howToStart.html b/src/resources/templates/resources/howToStart.html index fef277a..59e5cec 100644 --- a/src/resources/templates/resources/howToStart.html +++ b/src/resources/templates/resources/howToStart.html @@ -2,7 +2,11 @@ {% block content %} {% load i18n %} {% get_current_language as lang %} +
+
+

{% trans "Beginner guide" %}

+
{% block tools %} {% include "./tools.html" %} {% endblock %} diff --git a/src/resources/templates/resources/tools.html b/src/resources/templates/resources/tools.html index f943921..65e62c9 100644 --- a/src/resources/templates/resources/tools.html +++ b/src/resources/templates/resources/tools.html @@ -1,10 +1,10 @@ {% block content %} {% load i18n %} {% get_current_language as lang %} -
+
-

{% trans "Recommended Tools" %}

+

{% trans "Recommended Tools" %}

{% trans "To get you started, we built a VM that you can simply import in" %} Virtual Box {% trans "with a bunch of useful tools." %}
diff --git a/src/resources/urls.py b/src/resources/urls.py index 8cb1c68..485b388 100644 --- a/src/resources/urls.py +++ b/src/resources/urls.py @@ -1,11 +1,16 @@ +from django.contrib.sitemaps.views import sitemap from django.urls import path from . import views +from .sitemaps import StaticViewSitemap app_name = "resources" - +sitemaps = { + 'static': StaticViewSitemap(), +} urlpatterns = [ path('about', views.about, name='about'), path('how-to-start', views.howToStart, name='howToStart'), path('contribute', views.contribute, name='contribute'), path('become-member', views.becomeMember, name='becomeMember'), + path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), ] diff --git a/src/scoreboard/templates/scoreboard/scoreboard.html b/src/scoreboard/templates/scoreboard/scoreboard.html index 798b24b..a993320 100644 --- a/src/scoreboard/templates/scoreboard/scoreboard.html +++ b/src/scoreboard/templates/scoreboard/scoreboard.html @@ -3,9 +3,11 @@ {% block content %} {% load is_member %}
+
+

{% trans "Scoreboard" %}

+
-

Scoreboard

diff --git a/src/statics/css/style.css b/src/statics/css/style.css index 79f7bf5..a7f88d4 100644 --- a/src/statics/css/style.css +++ b/src/statics/css/style.css @@ -88,9 +88,14 @@ pre { border: none; } +.ctf-head h1 { + text-transform: uppercase; + font-size: 2em; +} + .ctf-block { background-color: #1d1d1d; - min-height: 30vh; + min-height: 35vh; padding: 30px; margin-bottom: 30px; } diff --git a/src/templates/base.html b/src/templates/base.html index aedcb11..9511b29 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -80,7 +80,7 @@ {% ismember request.user.userprofileinfo as is_member %} {% if not is_member %} {% endif %}