From 1d2da4a0a01db5157c051919cf8bc51272f4eaa2 Mon Sep 17 00:00:00 2001 From: OndraRehounek <ondra.rehounek@seznam.cz> Date: Thu, 4 Aug 2022 16:34:21 +0200 Subject: [PATCH] main: Init --- main/__init__.py | 0 main/apps.py | 5 ++ main/blocks.py | 12 ++++ main/migrations/__init__.py | 0 main/models.py | 58 +++++++++++++++++++ main/templates/main/404.html | 22 +++++++ main/templates/main/base.html | 30 ++++++++++ .../main/includes/newsletter_block.html | 0 8 files changed, 127 insertions(+) create mode 100644 main/__init__.py create mode 100644 main/apps.py create mode 100644 main/blocks.py create mode 100644 main/migrations/__init__.py create mode 100644 main/models.py create mode 100644 main/templates/main/404.html create mode 100644 main/templates/main/base.html create mode 100644 main/templates/main/includes/newsletter_block.html diff --git a/main/__init__.py b/main/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/main/apps.py b/main/apps.py new file mode 100644 index 00000000..d6512d13 --- /dev/null +++ b/main/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class DistrictConfig(AppConfig): + name = "main" diff --git a/main/blocks.py b/main/blocks.py new file mode 100644 index 00000000..9ed29dac --- /dev/null +++ b/main/blocks.py @@ -0,0 +1,12 @@ +# HomePageCarouselBlock +# RecentWork/TweetsBlock +# NewsBlock +# PeopleOverviewBlock +# RegionOverviewBlock +# LinkBoxBlock (mozna hardcoded do homepage?) +# WorkTimelineBlock +# ArticleLinkBlock +# ProgramBlock +# PersonBlock +# TwitterCarouselBlock +# ContactBlock diff --git a/main/migrations/__init__.py b/main/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/main/models.py b/main/models.py new file mode 100644 index 00000000..2cd88595 --- /dev/null +++ b/main/models.py @@ -0,0 +1,58 @@ +from django.db import models +from django.shortcuts import render +from wagtail.admin.edit_handlers import FieldPanel, ObjectList, TabbedInterface +from wagtail.core.models import Page +from wagtailmetadata.models import MetadataPageMixin + +from shared.models import ( # ArticleMixin,; ExtendedMetadataPageMixin,; SubpageMixin, + ExtendedMetadataHomePageMixin, + MenuMixin, +) + +# from . import blocks + + +class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin, Page): + + # settings + matomo_id = models.IntegerField( + "Matomo ID pro sledování návštěvnosti", blank=True, null=True + ) + + # header - fb, twitter, insta, youtube, dary, nalodeni + # footer - stream field loadovany pres page.root_page? + + settings_panels = [FieldPanel("matomo_id")] + + ### EDIT HANDLERS + + edit_handler = TabbedInterface( + [ + ObjectList(settings_panels, heading="Nastavení"), + ObjectList(MenuMixin.menu_panels, heading="Menu"), + ] + ) + + ### RELATIONS + + subpage_types = [ + # MainWorkTimelinePage + # MainArticlePage + # MainProgramPage + # MainPeoplePage + # MainPersonPage + # MainContactPage + ] + + ### OTHERS + + class Meta: + verbose_name = "HomePage pirati.cz" + + @staticmethod + def get_404_response(request): + return render(request, "main/404.html", status=404) + + @property + def root_page(self): + return self diff --git a/main/templates/main/404.html b/main/templates/main/404.html new file mode 100644 index 00000000..0f449876 --- /dev/null +++ b/main/templates/main/404.html @@ -0,0 +1,22 @@ +{% load static %} + +<html lang="cs"> +<head> + <link rel="stylesheet" href="{% static 'styleguide234/assets/css/styles.css' %}">{# TODO some custom 404 in future #} + <title>404</title> +</head> +<body> +<div class="flex flex-col my-40 items-center"> + <h1 class="head-alt-lg mb-8"> + 404 + </h1> + <img src="{% static 'shared/img/logo_black.svg' %}" alt class="mb-8"/> + <h1 class="head-alt-md mb-8"> + Narazili jsme na mělčinu... + </h1> + <a href="/"> + Zpět do přístavu + </a> +</div> +</body> +</html> diff --git a/main/templates/main/base.html b/main/templates/main/base.html new file mode 100644 index 00000000..13356618 --- /dev/null +++ b/main/templates/main/base.html @@ -0,0 +1,30 @@ +{% load static wagtailcore_tags wagtailimages_tags wagtailmetadata_tags %} +<!doctype html> +<html lang="cs"> +<head> + <!-- Meta --> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width" /> + {% meta_tags %} + {% if settings.MAJAK_ENV == "test" %} + <meta name="robots" content="noindex, nofollow"> + {% endif %} + + <!-- Favicon --> + {% include "shared/favicon_snippet.html" %} + + <!-- Styles --> + <script src="https://cdn.tailwindcss.com"></script> + + {% block styles %}{% endblock styles %} + + {% if page.root_page.matomo_id %} + {% include "shared/matomo_snippet.html" with matomo_id=page.root_page.matomo_id %} + {% endif %} +</head> + +<body> + {% block content %}{% endblock content %} + {% block scripts %}{% endblock scripts %} +</body> +</html> diff --git a/main/templates/main/includes/newsletter_block.html b/main/templates/main/includes/newsletter_block.html new file mode 100644 index 00000000..e69de29b -- GitLab