From e03e606d0be392063a8eb40e80da715b597899a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com> Date: Mon, 30 May 2022 21:42:00 +0200 Subject: [PATCH] majak: Public sites list --- majak/urls.py | 2 + tuning/templates/tuning/sites_list.html | 135 ++++++++++++++++++++++++ tuning/views.py | 21 ++++ 3 files changed, 158 insertions(+) create mode 100644 tuning/templates/tuning/sites_list.html create mode 100644 tuning/views.py diff --git a/majak/urls.py b/majak/urls.py index 52ab7140..c17f0171 100644 --- a/majak/urls.py +++ b/majak/urls.py @@ -9,6 +9,7 @@ from wagtail.documents import urls as wagtaildocs_urls from elections2021 import views as elections2021_views from maps_utils import urls as maps_utils_urls +from tuning.views import SitesListView handler404 = "shared.views.page_not_found" @@ -23,6 +24,7 @@ urlpatterns = [ ), path("maps/", include(maps_utils_urls)), path("captcha/", include(captcha.urls)), + path("seznam-webu/", SitesListView.as_view()), ] + pirates_urlpatterns diff --git a/tuning/templates/tuning/sites_list.html b/tuning/templates/tuning/sites_list.html new file mode 100644 index 00000000..c3fd57e5 --- /dev/null +++ b/tuning/templates/tuning/sites_list.html @@ -0,0 +1,135 @@ +{% load static %} +<!doctype html> +<html lang="cs"> +<head> + <!-- Meta --> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width" /> + <meta name="robots" content="noindex, nofollow"> + + <title>Seznam webů v Majáku</title> + + <!-- Favicon --> + {% include "shared/favicon_snippet.html" %} + + <!-- Styles --> + <link href="https://styleguide.pirati.cz/2.3.x/css/styles.css" rel="stylesheet" media="all" /> + <link href="https://styleguide.pirati.cz/2.3.x/css/pattern-scaffolding.css" rel="stylesheet" media="all" /> + + <style type="text/css"> + .head-alt-md, .head-alt-lg { + line-height: 1.25; + } + .ul-picture li:before { + content: none !important; + } + .ul-picture li { + background-repeat: no-repeat; + background-position: 0 0; + padding: 0 0 1em 35px !important; + } + .content-block a { + color: #004958; + } + .text-white a { + color: #FFFFFF; + } + </style> +</head> + +<body> + + <nav class="navbar navbar--simple __js-root"> + <ui-app inline-template> + <ui-navbar inline-template> + <div> + <div class="container container--default navbar__content" :class="{'navbar__content--initialized': true}"> + <div class="navbar__brand my-4 flex items-center lg:pr-8 lg:my-0"> + <img src="{% static "majak/img/majak-pruhledny.svg" %}" class="w-8" /> + <span class="pl-4 font-bold text-xl lg:border-r lg:border-grey-300 lg:pr-8">Seznam webů v Majáku</span> + </div> + <div class="navbar__menutoggle my-4 flex justify-end lg:hidden"> + <a href="#" @click="show = !show" class="no-underline hover:no-underline"> + <i class="ico--menu text-3xl"></i> + </a> + </div> + <div v-if="show || isLgScreenSize" class="navbar__main navbar__section navbar__section--expandable container-padding--zero lg:container-padding--auto"> + <ul class="navbar-menu text-white"> + <li class="navbar-menu__item"> + <a href="https://majak.pirati.cz" data-href="https://majak.pirati.cz" class="navbar-menu__link">do Majáku</a> + </li> + </ul> + </div> + </div> + </div> + </ui-navbar> + </ui-app> + </nav> + + <div class="container container--default py-8 lg:py-16"> + <main> + + <div class="lg:flex clearfix"> + <div class="content-block lg:w-1/3 lg:pr-5 px-4 py-2"> + <div class="content-block"> + <ul> + {% for site in sites_first %} + <li><a href="{{ site.root_url }}">{{ site.root_page.title }}</a></li> + {% endfor %} + </ul> + </div> + </div> + <div class="content-block lg:w-1/3 lg:pl-5 px-4 py-2"> + <div class="content-block"> + <ul> + {% for site in sites_second %} + <li><a href="{{ site.root_url }}">{{ site.root_page.title }}</a></li> + {% endfor %} + </ul> + </div> + </div> + <div class="content-block lg:w-1/3 lg:pl-5 px-4 py-2"> + <div class="content-block"> + <ul> + {% for site in sites_third %} + <li><a href="{{ site.root_url }}">{{ site.root_page.title }}</a></li> + {% endfor %} + </ul> + </div> + </div> + </div> + + </main> + </div> + + <footer class="footer bg-grey-700 text-white __js-root"> + <ui-app inline-template> + <div> + <div class="footer__main py-4 lg:py-16 container container--default"> + <section class="footer__brand"> + {% if page.root_page.show_logo %} + <a href="https://www.pirati.cz"> + <img src="https://styleguide.pirati.cz/2.3.x/images/logo-full-white.svg" alt="logo pirátské strany" class="w-32 md:w-40 pb-6" /> + </a> + {% endif %} + <p class="para hidden md:block md:mb-4 lg:mb-0 text-grey-200"> + <span class="copyleft inline-block">©</span> {% now "Y" %} Piráti. Všechna práva vyhlazena. Sdílejte a nechte ostatní sdílet za stejných podmínek. + </p> + </section> + <section class="footer__social lg:text-right"> + <div class="mb-4"> + </div> + <div class="flex flex-col md:flex-row lg:flex-col lg:items-end space-y-2 md:space-y-0 md:space-x-2 lg:space-x-0 lg:space-y-2"> + </div> + </section> + </div> + </div> + </ui-app> + </footer> + + <script src="{% static "shared/vendor/vue/vue.2.6.11.js" %}"></script> + <script src="https://styleguide.pirati.cz/2.3.x/js/main.bundle.js"></script> + <script src="{% static "shared/vendor/jquery/jquery-3.4.1.min.js" %}"></script> + <script src="{% static "shared/vendor/lazysizes/lazysizes.min.js" %}"></script> +</body> +</html> diff --git a/tuning/views.py b/tuning/views.py new file mode 100644 index 00000000..5c438665 --- /dev/null +++ b/tuning/views.py @@ -0,0 +1,21 @@ +import math + +from django.views.generic.base import TemplateView +from wagtail.core.models import Site + + +class SitesListView(TemplateView): + template_name = "tuning/sites_list.html" + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + sites = list( + Site.objects.exclude(hostname__contains=".pir-test.eu") + .select_related("root_page") + .order_by("root_page__title") + ) + third = math.ceil(len(sites) / 3) + context["sites_first"] = sites[:third] + context["sites_second"] = sites[third : third * 2] + context["sites_third"] = sites[third * 2 :] + return context -- GitLab