Commit 7741a377 authored by fred's avatar fred

add pretty basic podcast rss feed

parent 2041e2ca
...@@ -25,6 +25,8 @@ urlpatterns = patterns('', ...@@ -25,6 +25,8 @@ urlpatterns = patterns('',
url(r'^search/', 'panikweb.search.view', name='search'), url(r'^search/', 'panikweb.search.view', name='search'),
url(r'^podcasts.rss', 'panikweb.views.podcasts_feed', name='podcasts-feed'),
(r'^api/v2/', include('fiber.rest_api.urls')), (r'^api/v2/', include('fiber.rest_api.urls')),
(r'^admin/fiber/', include('fiber.admin_urls')), (r'^admin/fiber/', include('fiber.admin_urls')),
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', {'packages': ('fiber',),}), (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', {'packages': ('fiber',),}),
......
...@@ -466,3 +466,17 @@ class NewsItemDetailView(DetailView): ...@@ -466,3 +466,17 @@ class NewsItemDetailView(DetailView):
model = NewsItem model = NewsItem
newsitem = NewsItemDetailView.as_view() newsitem = NewsItemDetailView.as_view()
class PodcastsFeedView(TemplateView):
template_name = 'podcasts.html'
content_type = 'application/rss+xml'
def get_context_data(self, **kwargs):
context = super(PodcastsFeedView, self).get_context_data(**kwargs)
context['base_url'] = self.request.build_absolute_uri('/')[:-1]
context['soundfiles'] = SoundFile.objects.select_related().filter(
podcastable=True).order_by('-creation_timestamp')
return context
podcasts_feed = PodcastsFeedView.as_view()
{% load soundfiles %}<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<channel>
<title>Radio Panik{% if title %} - {{ title }}{% endif %}</title>
<link>{{ base_url }}</link>
<description></description>
<lastBuildDate>{{ soundfiles.0.creation_timestamp|date:"r" }}</lastBuildDate>
{% for soundfile in soundfiles|slice:":20" %}<item>
<title>{% if soundfile.fragment %}{{ soundfile.title }} - {% endif %}{{ soundfile.episode.title }}</title>
<link>{{ base_url }}{% url 'episode-view' slug=soundfile.episode.slug emission_slug=soundfile.episode.emission.slug %}</link>
<description>{{ soundfile.episode.text|striptags }}</description>
<enclosure url="{{ base_url }}{{ soundfile|format_url:'mp3' }}" type="audio/mpeg"/>
<guid>{{ soundfile.episode.get_absolute_url }}-{{ soundfile.id }}</guid>
<pubDate>{{ soundfile.episode.creation_timestamp|date:"r" }} GMT</pubDate>
</item>
{% endfor %}
</channel>
</rss>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment