diff --git a/uniweb/models.py b/uniweb/models.py index 89e9992da4be4d30fde4cf555151e9a7f4b1bacd..ecc8812a472a09d4cebe9a8c961230b67e18c215 100644 --- a/uniweb/models.py +++ b/uniweb/models.py @@ -70,6 +70,7 @@ class ColumnsTextBlock(blocks.StructBlock): class Meta: label = "text dva sloupce" icon = "doc-full" + group = "texty" template = "uniweb/blocks/text_columns.html" @@ -82,6 +83,7 @@ class AdvancedColumnsTextBlock(ColorBlock, AlignBlock): class Meta: label = "text dva sloupce (pokroÄŤilĂ˝)" icon = "doc-full" + group = "texty" template = "uniweb/blocks/advanced_text_columns.html" @@ -91,15 +93,28 @@ class AdvancedTitleBlock(ColorBlock, AlignBlock): class Meta: label = "nadpis (pokroÄŤilĂ˝)" icon = "title" + group = "nadpisy" template = "uniweb/blocks/advanced_title.html" +class PictureTitleBlock(ColorBlock): + title = blocks.CharBlock(label="nadpis") + image = ImageChooserBlock(label="obrázek") + + class Meta: + label = "nadpis (s obrázkem)" + icon = "title" + group = "nadpisy" + template = "uniweb/blocks/picture_title.html" + + class AdvancedTextBlock(ColorBlock, AlignBlock): text = blocks.RichTextBlock(label="text", features=RICH_TEXT_FEATURES) class Meta: label = "text (pokroÄŤilĂ˝)" icon = "doc-full" + group = "texty" template = "uniweb/blocks/advanced_text.html" @@ -130,26 +145,51 @@ class SubpageMixin: class UniwebContentMixin(models.Model): content = StreamField( [ - ("title", blocks.CharBlock(label="nadpis", icon="title")), + ( + "title", + blocks.CharBlock( + label="nadpis", + icon="title", + group="nadpisy", + template="uniweb/blocks/title.html", + ), + ), ("advanced_title", AdvancedTitleBlock()), - ("text", blocks.RichTextBlock(label="text", features=RICH_TEXT_FEATURES)), + ("picture_title", PictureTitleBlock()), + ( + "text", + blocks.RichTextBlock( + label="text", + features=RICH_TEXT_FEATURES, + group="texty", + template="uniweb/blocks/text.html", + ), + ), ("advanced_text", AdvancedTextBlock()), ("text_columns", ColumnsTextBlock()), ("advanced_text_columns", AdvancedColumnsTextBlock()), ( "gallery", blocks.ListBlock( - ImageChooserBlock(label="obrázek"), label="galerie", icon="image" + ImageChooserBlock(label="obrázek"), + label="galerie", + icon="image", + group="ostatnĂ", + template="uniweb/blocks/gallery.html", ), ), ( "table", TableBlock( label="tabulka", - template="uniweb/snippet_table.html", + group="ostatnĂ", + template="uniweb/blocks/table.html", ), ), - ("jupyter", DocumentChooserBlock(label="Jupyter notebook")), + ( + "jupyter", + DocumentChooserBlock(label="Jupyter notebook", group="ostatnĂ"), + ), ], verbose_name="obsah stránky", blank=True, diff --git a/uniweb/templates/uniweb/base.html b/uniweb/templates/uniweb/base.html index f27f5fc069a1650cb4d6c68cff2c367ce2c7ef4e..cdb254e7edca84518716c33adeb7744a19cbd37f 100644 --- a/uniweb/templates/uniweb/base.html +++ b/uniweb/templates/uniweb/base.html @@ -22,7 +22,7 @@ .inline-block { display: inline-block; } - .leading-tight { + .head-alt-md, .head-alt-lg { line-height: 1.25; } </style> diff --git a/uniweb/templates/uniweb/blocks/advanced_title.html b/uniweb/templates/uniweb/blocks/advanced_title.html index 844e96f3e9b119d7318703791665ea1e7f40bc73..1a5fb116fd51ec044d55f9ba5bfcec702377faf4 100644 --- a/uniweb/templates/uniweb/blocks/advanced_title.html +++ b/uniweb/templates/uniweb/blocks/advanced_title.html @@ -1 +1 @@ -<h1 class="head-alt-md md:head-alt-lg px-4 pt-4 pb-2 lg:mt-16 leading-tight {{ css_class|join:" " }}">{{ block.value.title }}</h1> +<h1 class="head-alt-md md:head-alt-lg px-4 pt-4 pb-2 lg:mt-16 {{ css_class|join:" " }}">{{ block.value.title }}</h1> diff --git a/uniweb/templates/uniweb/blocks/gallery.html b/uniweb/templates/uniweb/blocks/gallery.html new file mode 100644 index 0000000000000000000000000000000000000000..3cf2f1aca4a1aeff2a736e4249764ce703071bc0 --- /dev/null +++ b/uniweb/templates/uniweb/blocks/gallery.html @@ -0,0 +1,10 @@ +{% load wagtailimages_tags %} +<div class="content-block w-full my-6 grid grid-cols-4 gap-4{% if first %} mt-8 lg:mt-12{% endif %}"> + {% for picture in block.value %} + {% image picture width-2000 as img %} + {% image picture fill-300x200 as thumb %} + <div> + <a data-fancybox="gallery" href="{{ img.url }}"><img data-src="{{ thumb.url }}" class="lazyload img-fluid" alt="{{ thumb.alt }}"></a> + </div> + {% endfor %} +</div> diff --git a/uniweb/templates/uniweb/snippet_table.html b/uniweb/templates/uniweb/blocks/table.html similarity index 93% rename from uniweb/templates/uniweb/snippet_table.html rename to uniweb/templates/uniweb/blocks/table.html index eb2061b7d0857160f7e9ad9ad3efbedcbefebf76..e2ccf4a656691e8185f40d6159cbf91252c99e2f 100644 --- a/uniweb/templates/uniweb/snippet_table.html +++ b/uniweb/templates/uniweb/blocks/table.html @@ -1,6 +1,7 @@ {% load table_block_tags %} -<table class="table table--bordered table--condensed mx-auto"> +<div class="my-6{% if first %} mt-8 lg:mt-12{% endif %}"> + <table class="table table--bordered table--condensed mx-auto"> {% if table_caption %} <caption class="head-heavy-sm my-4">{{ table_caption }}</caption> {% endif %} @@ -56,4 +57,5 @@ {% endwith %} {% endfor %} </tbody> -</table> + </table> +</div> diff --git a/uniweb/templates/uniweb/blocks/text.html b/uniweb/templates/uniweb/blocks/text.html new file mode 100644 index 0000000000000000000000000000000000000000..fe369c3a2721f8888f21c2b96825b68fe5b38659 --- /dev/null +++ b/uniweb/templates/uniweb/blocks/text.html @@ -0,0 +1,4 @@ +{% load wagtailcore_tags %} +<div class="content-block px-4 py-2 clearfix{% if first %} mt-8 lg:mt-12{% endif %}"> + {{ block.value|richtext }} +</div> diff --git a/uniweb/templates/uniweb/blocks/title.html b/uniweb/templates/uniweb/blocks/title.html new file mode 100644 index 0000000000000000000000000000000000000000..a09530cd4df8907886aa89e17981acb3c3c498dc --- /dev/null +++ b/uniweb/templates/uniweb/blocks/title.html @@ -0,0 +1 @@ +<h1 class="head-alt-md md:head-alt-lg px-4 pt-4 pb-2 lg:mt-16">{{ block.value }}</h1> diff --git a/uniweb/templates/uniweb/snippet_sections.html b/uniweb/templates/uniweb/snippet_sections.html index 5e8f817a349f8b57c3caffba9ef764014e135e4f..20fe13e6d94b5317e4e78f347834dd550f5ce355 100644 --- a/uniweb/templates/uniweb/snippet_sections.html +++ b/uniweb/templates/uniweb/snippet_sections.html @@ -3,54 +3,12 @@ <section class="mb-8 lg:mb-16"> {% for block in page.content %} - {% if block.block_type == "advanced_title" %} - {% include_block block %} - {% endif %} - - {% if block.block_type == "advanced_text" %} - {% include_block block with first=forloop.first %} - {% endif %} - - {% if block.block_type == "text_columns" %} - {% include_block block with first=forloop.first %} - {% endif %} - - {% if block.block_type == "advanced_text_columns" %} - {% include_block block with first=forloop.first %} - {% endif %} - - {% if block.block_type == "title" %} - <h1 class="head-alt-md md:head-alt-lg px-4 pt-4 pb-2 leading-tight lg:mt-16">{{ block.value }}</h1> - {% endif %} - - {% if block.block_type == "text" %} - <div class="content-block px-4 py-2 clearfix{% if forloop.first %} mt-8 lg:mt-12{% endif %}"> - {{ block.value|richtext }} - </div> - {% endif %} - - {% if block.block_type == "gallery" %} - <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 block.value %} - {% image picture width-2000 as img %} - {% image picture fill-300x200 as thumb %} - <div> - <a data-fancybox="gallery" href="{{ img.url }}"><img data-src="{{ thumb.url }}" class="lazyload img-fluid" alt="{{ thumb.alt }}"></a> - </div> - {% endfor %} - </div> - {% endif %} - - {% if block.block_type == "table" %} - <div class="my-6{% if forloop.first %} mt-8 lg:mt-12{% endif %}"> - {% include_block block %} - </div> - {% endif %} - {% if block.block_type == "jupyter" %} <div class="content-block my-4 clearfix{% if forloop.first %} mt-8 lg:mt-12{% endif %}"> {{ block|jupyterize }} </div> + {% else %} + {% include_block block with first=forloop.first %} {% endif %} {% endfor %}