From c1b0a4195a7b37217b90065e50fc94b2ec89d99f Mon Sep 17 00:00:00 2001 From: moanos Date: Mon, 15 Apr 2024 23:08:39 +0200 Subject: [PATCH] feat: Allow styling of RSS feed --- src/fellchensammlung/feeds.py | 22 ++- src/fellchensammlung/static/rss.xsl | 222 ++++++++++++++++++++++++++++ 2 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 src/fellchensammlung/static/rss.xsl diff --git a/src/fellchensammlung/feeds.py b/src/fellchensammlung/feeds.py index 578434a..7293291 100644 --- a/src/fellchensammlung/feeds.py +++ b/src/fellchensammlung/feeds.py @@ -1,10 +1,31 @@ from django.contrib.syndication.views import Feed +from django.utils.feedgenerator import Rss201rev2Feed from django.urls import reverse +from django.utils.xmlutils import SimplerXMLGenerator + from .models import AdoptionNotice +class FormattedFeed(Rss201rev2Feed): + """ + + """ + content_type = "text/xml; charset=utf-8" + def write(self, outfile, encoding): + handler = SimplerXMLGenerator(outfile, encoding, short_empty_elements=True) + handler.startDocument() + handler._write('') + handler.startElement("rss", self.rss_attributes()) + handler.startElement("channel", self.root_attributes()) + self.add_root_elements(handler) + self.write_items(handler) + self.endChannelElement(handler) + handler.endElement("rss") + + class LatestAdoptionNoticesFeed(Feed): + feed_type = FormattedFeed title = "Notfellchen" link = "/rss/" description = "Updates zu neuen Vermittlungen." @@ -17,4 +38,3 @@ class LatestAdoptionNoticesFeed(Feed): def item_description(self, item): return item.description - diff --git a/src/fellchensammlung/static/rss.xsl b/src/fellchensammlung/static/rss.xsl new file mode 100644 index 0000000..46bda80 --- /dev/null +++ b/src/fellchensammlung/static/rss.xsl @@ -0,0 +1,222 @@ + + + + + + + + RSS Feed | + <xsl:value-of select="/atom:feed/atom:title"/> + + + + + + + +
+ + This is an RSS feed. Subscribe by copying + the URL from the address bar into your newsreader. Visit About Feeds + to learn more and get started. It’s free. + +
+

+ RSS Feed Preview + + + + + + + + + + + + + + + + + + + + + + + + + + +

+

+

+ +

+ + + + + Visit Website → + + +

Recent blog posts

+ +
+

+ + + + + + +

+ +
+ Published on + +
+
+
+
+
+ + +
+