Skip to content
Snippets Groups Projects
Commit 840e0c7b authored by jan.bednarik's avatar jan.bednarik
Browse files

uniweb: Simplify content blocks

parent b1404a27
No related branches found
No related tags found
2 merge requests!105merge test,!104Uniweb
Pipeline #1216 passed
# Generated by Django 3.1.1 on 2020-09-10 22:22
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("uniweb", "0003_auto_20200909_2354"),
]
operations = [
migrations.AlterField(
model_name="uniwebflexiblepage",
name="content",
field=wagtail.core.fields.StreamField(
[
(
"title",
wagtail.core.blocks.CharBlock(icon="title", label="nadpis"),
),
("text", wagtail.core.blocks.RichTextBlock(label="text")),
(
"text_columns",
wagtail.core.blocks.StructBlock(
[
(
"left_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="levý sloupec",
),
),
(
"right_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="pravý sloupec",
),
),
]
),
),
(
"gallery",
wagtail.core.blocks.ListBlock(
wagtail.images.blocks.ImageChooserBlock(label="obrázek"),
icon="image",
label="galerie",
),
),
(
"text_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="text",
),
),
]
),
),
(
"columns_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"left_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="levý sloupec",
),
),
(
"right_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="pravý sloupec",
),
),
]
),
),
(
"gallery_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"images",
wagtail.core.blocks.ListBlock(
wagtail.images.blocks.ImageChooserBlock(
label="obrázek"
)
),
),
]
),
),
],
blank=True,
verbose_name="obsah stránky",
),
),
migrations.AlterField(
model_name="uniwebhomepage",
name="content",
field=wagtail.core.fields.StreamField(
[
(
"title",
wagtail.core.blocks.CharBlock(icon="title", label="nadpis"),
),
("text", wagtail.core.blocks.RichTextBlock(label="text")),
(
"text_columns",
wagtail.core.blocks.StructBlock(
[
(
"left_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="levý sloupec",
),
),
(
"right_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="pravý sloupec",
),
),
]
),
),
(
"gallery",
wagtail.core.blocks.ListBlock(
wagtail.images.blocks.ImageChooserBlock(label="obrázek"),
icon="image",
label="galerie",
),
),
(
"text_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="text",
),
),
]
),
),
(
"columns_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"left_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="levý sloupec",
),
),
(
"right_text",
wagtail.core.blocks.RichTextBlock(
features=[
"h2",
"h3",
"h4",
"h5",
"bold",
"italic",
"ol",
"ul",
"hr",
"link",
"document-link",
"image",
"superscript",
"subscript",
"strikethrough",
"blockquote",
],
label="pravý sloupec",
),
),
]
),
),
(
"gallery_section",
wagtail.core.blocks.StructBlock(
[
(
"title",
wagtail.core.blocks.CharBlock(
label="nadpis", required=False
),
),
(
"images",
wagtail.core.blocks.ListBlock(
wagtail.images.blocks.ImageChooserBlock(
label="obrázek"
)
),
),
]
),
),
],
blank=True,
verbose_name="obsah stránky",
),
),
]
...@@ -35,14 +35,16 @@ RICH_TEXT_FEATURES = [ ...@@ -35,14 +35,16 @@ RICH_TEXT_FEATURES = [
] ]
# TODO remove
class TextSectionBlock(blocks.StructBlock): class TextSectionBlock(blocks.StructBlock):
title = blocks.CharBlock(label="nadpis", required=False) title = blocks.CharBlock(label="nadpis", required=False)
text = blocks.RichTextBlock(label="text", features=RICH_TEXT_FEATURES) text = blocks.RichTextBlock(label="text", features=RICH_TEXT_FEATURES)
class Meta: class Meta:
label = "textová sekce" label = "(deprecated) textová sekce"
# TODO remove
class ColumnsSectionBlock(blocks.StructBlock): class ColumnsSectionBlock(blocks.StructBlock):
title = blocks.CharBlock(label="nadpis", required=False) title = blocks.CharBlock(label="nadpis", required=False)
left_text = blocks.RichTextBlock(label="levý sloupec", features=RICH_TEXT_FEATURES) left_text = blocks.RichTextBlock(label="levý sloupec", features=RICH_TEXT_FEATURES)
...@@ -51,15 +53,27 @@ class ColumnsSectionBlock(blocks.StructBlock): ...@@ -51,15 +53,27 @@ class ColumnsSectionBlock(blocks.StructBlock):
) )
class Meta: class Meta:
label = "dvousloupcová textová sekce" label = "(deprecated) dvousloupcová textová sekce"
class ColumnsTextBlock(blocks.StructBlock):
left_text = blocks.RichTextBlock(label="levý sloupec", features=RICH_TEXT_FEATURES)
right_text = blocks.RichTextBlock(
label="pravý sloupec", features=RICH_TEXT_FEATURES
)
class Meta:
label = "text dva sloupce"
icon = "doc-full"
# TODO remove
class GallerySectionBlock(blocks.StructBlock): class GallerySectionBlock(blocks.StructBlock):
title = blocks.CharBlock(label="nadpis", required=False) title = blocks.CharBlock(label="nadpis", required=False)
images = blocks.ListBlock(ImageChooserBlock(label="obrázek")) images = blocks.ListBlock(ImageChooserBlock(label="obrázek"))
class Meta: class Meta:
label = "galerie obrázků" label = "(deprecated) galerie obrázků"
class MenuItemBlock(blocks.StructBlock): class MenuItemBlock(blocks.StructBlock):
...@@ -91,6 +105,15 @@ class UniwebHomePage(MetadataPageMixin, Page): ...@@ -91,6 +105,15 @@ class UniwebHomePage(MetadataPageMixin, Page):
content = StreamField( content = StreamField(
[ [
("title", blocks.CharBlock(label="nadpis", icon="title")),
("text", blocks.RichTextBlock(label="text")),
("text_columns", ColumnsTextBlock()),
(
"gallery",
blocks.ListBlock(
ImageChooserBlock(label="obrázek"), label="galerie", icon="image"
),
),
("text_section", TextSectionBlock()), ("text_section", TextSectionBlock()),
("columns_section", ColumnsSectionBlock()), ("columns_section", ColumnsSectionBlock()),
("gallery_section", GallerySectionBlock()), ("gallery_section", GallerySectionBlock()),
...@@ -150,6 +173,15 @@ class UniwebFlexiblePage(Page, SubpageMixin, MetadataPageMixin): ...@@ -150,6 +173,15 @@ class UniwebFlexiblePage(Page, SubpageMixin, MetadataPageMixin):
content = StreamField( content = StreamField(
[ [
("title", blocks.CharBlock(label="nadpis", icon="title")),
("text", blocks.RichTextBlock(label="text")),
("text_columns", ColumnsTextBlock()),
(
"gallery",
blocks.ListBlock(
ImageChooserBlock(label="obrázek"), label="galerie", icon="image"
),
),
("text_section", TextSectionBlock()), ("text_section", TextSectionBlock()),
("columns_section", ColumnsSectionBlock()), ("columns_section", ColumnsSectionBlock()),
("gallery_section", GallerySectionBlock()), ("gallery_section", GallerySectionBlock()),
......
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
} }
.copyleft {
display:inline-block;
transform: rotate(180deg);
}
</style> </style>
{% if page.matomo_id %} {% if page.matomo_id %}
...@@ -81,7 +85,7 @@ ...@@ -81,7 +85,7 @@
</ui-app> </ui-app>
</nav> </nav>
<div class="container container--default py-4 lg:py-12"> <div class="container container--default lg:py-4">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
...@@ -94,7 +98,7 @@ ...@@ -94,7 +98,7 @@
<img src="{% static "uniweb/assets/images/logo.svg" %}" alt="logo pirátské strany" class="w-32 md:w-40 pb-6" /> <img src="{% static "uniweb/assets/images/logo.svg" %}" alt="logo pirátské strany" class="w-32 md:w-40 pb-6" />
</a> </a>
<p class="para hidden md:block md:mb-4 lg:mb-0 text-grey-200"> <p class="para hidden md:block md:mb-4 lg:mb-0 text-grey-200">
{% now "Y" %} Piráti. Všechna práva vyhlazena. Sdílejte a nechte ostatní sdílet za stejných podmínek. <span class="copyleft">&copy;</span> {% now "Y" %} Piráti. Všechna práva vyhlazena. Sdílejte a nechte ostatní sdílet za stejných podmínek.
</p> </p>
</section> </section>
<section class="footer__social lg:text-right"> <section class="footer__social lg:text-right">
......
{% load wagtailcore_tags wagtailimages_tags %} {% load wagtailcore_tags wagtailimages_tags %}
{% for section in page.content %} <section class="mb-8 lg:mb-16">
<section class="mb-8 lg:mb-16 clearfix"> {% for block in page.content %}
{% if section.value.title %} {% if block.block_type == "title" %}
<h1 class="head-alt-md md:head-alt-lg max-w-5xl mt-4 mb-6">{{ section.value.title }}</h1> <h1 class="head-alt-md md:head-alt-lg max-w-5xl my-6 lg:mt-16">{{ block.value }}</h1>
{% endif %} {% endif %}
{% if section.block_type == "text_section" %} {% if block.block_type == "text" %}
<div class="content-block w-full my-4"> <div class="content-block w-full my-4 clearfix{% if forloop.first %} mt-8 lg:mt-12{% endif %}">
{{ section.value.text|richtext }} {{ block.value|richtext }}
</div> </div>
{% endif %} {% endif %}
{% if section.block_type == "columns_section" %} {% if block.block_type == "text_columns" %}
<div class="lg:flex"> <div class="lg:flex clearfix">
<div class="content-block lg:w-1/2 lg:pr-5 my-4"> <div class="content-block lg:w-1/2 lg:pr-5 my-4{% if forloop.first %} mt-8 lg:mt-12{% endif %}">
{{ section.value.left_text|richtext }} {{ block.value.left_text|richtext }}
</div> </div>
<div class="content-block lg:w-1/2 lg:pl-5 my-4"> <div class="content-block lg:w-1/2 lg:pl-5 my-4{% if forloop.first %} mt-8 lg:mt-12{% endif %}">
{{ section.value.right_text|richtext }} {{ block.value.right_text|richtext }}
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% if section.block_type == "gallery_section" %} {% if block.block_type == "gallery" %}
<div class="content-block w-full my-6 grid grid-cols-4 gap-4"> <div class="content-block w-full my-6 grid grid-cols-4 gap-4{% if forloop.first %} mt-8 lg:mt-12{% endif %}">
{% for picture in section.value.images %} {% for picture in block.value %}
{% image picture width-2000 as img %} {% image picture width-2000 as img %}
{% image picture fill-300x200 as thumb %} {% image picture fill-300x200 as thumb %}
<div> <div>
...@@ -36,5 +36,5 @@ ...@@ -36,5 +36,5 @@
</div> </div>
{% endif %} {% endif %}
</section>
{% endfor %} {% endfor %}
</section>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment