diff --git a/main/blocks.py b/main/blocks.py index 5c4e6890601322cde0a7c6c58f4411ea5c180d6a..9499387afc21f98817d31d9a70f48de442c80267 100644 --- a/main/blocks.py +++ b/main/blocks.py @@ -1,4 +1,5 @@ from django.utils.text import slugify +from django.template.loader import render_to_string from wagtail.core.blocks import ( CharBlock, ListBlock, diff --git a/main/feeds.py b/main/feeds.py index 018371859a9f98d4c1a695cbf9cc44bbf1329afb..9d8986a761e1546637e9b1492002797708e72fe1 100644 --- a/main/feeds.py +++ b/main/feeds.py @@ -1,3 +1,5 @@ +import typing + from datetime import datetime from django.contrib.syndication.views import Feed @@ -92,3 +94,20 @@ class LatestArticlesFeed(Feed): item: MainArticlePage ) -> str: return item.get_full_url() + + def item_enclosure_url( + self, + item: MainArticlePage + ) -> typing.Union[None, str]: + if item.image is None: + return None + + return item.image.get_rendition("format-webp").full_url + + item_enclosure_mime_type = "image/webp" + + def item_enclosure_length( + self, + item: MainArticlePage + ) -> int: + return item.image.file_size diff --git a/main/templates/main/feed_item_description.html b/main/templates/main/feed_item_description.html index e01e314b9b46f64db02e3bdfa6d0a98fe84ddfd0..c84b96824e9d5a12180b6b040712cda922a892ef 100644 --- a/main/templates/main/feed_item_description.html +++ b/main/templates/main/feed_item_description.html @@ -1,5 +1,24 @@ {% load wagtailcore_tags %} +<p>{{ item.perex }}</p> + {% for block in item.content %} - {% include_block block %} + {% if block.block_type == "text" %} + {% comment %} + No need to wrap this in a <p>, as the value already does this + {% endcomment %} + {{ block.value }} + {% elif block.block_type == "quote" %} + <blockquote>„{{ block.value.quote }}“</blockquote> + <p>— {{ block.value.autor_name }}</p> + {% elif block.block_type == "download" %} + <p> + Soubor „{{ block.value.file }}“ ke stažení: <a href="{{ block.value.file.url }}">{{ block.value.file.url }}</a> + </p> + {% elif block.block_type == "image" %} + <a href="{{ block.value.href }}"> + <img src="{{ block.value.image.url }}"> + </a> + <p>{{ block.value.text }}</p> + {% endif %} {% endfor %}