Skip to content
Snippets Groups Projects
Commit 2354a751 authored by Tomáš's avatar Tomáš
Browse files

improve RSS feed - enclosures, RSS-specific blocks

parent f5b68219
No related branches found
No related tags found
2 merge requests!704Release,!703Improve RSS feeds
Pipeline #11299 passed
from django.utils.text import slugify
from django.template.loader import render_to_string
from wagtail.core.blocks import (
CharBlock,
ListBlock,
......
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
{% 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 %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment