Commit 607b44cb authored by fred's avatar fred

fix datetime formatting in rss feed

parent 7741a377
import email.utils
import datetime
import re
import time
import urllib2
import uuid
......@@ -185,3 +188,10 @@ class FormatSearchResultNode(template.Node):
@register.inclusion_tag('includes/piwik.html')
def piwik():
return {'enabled': settings.ENABLE_PIWIK}
@register.filter
def rfc822(datetime):
if datetime is None:
return ''
return email.utils.formatdate(time.mktime(datetime.timetuple()))
{% load soundfiles %}<?xml version="1.0" encoding="UTF-8"?>
{% load paniktags %}{% 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/"
......@@ -7,15 +7,15 @@
<title>Radio Panik{% if title %} - {{ title }}{% endif %}</title>
<link>{{ base_url }}</link>
<description></description>
<lastBuildDate>{{ soundfiles.0.creation_timestamp|date:"r" }}</lastBuildDate>
<lastBuildDate>{{ soundfiles.0.creation_timestamp|rfc822 }}</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>
<guid>{{ base_url }}{{ soundfile.episode.get_absolute_url }}#{{ soundfile.id }}</guid>
<pubDate>{{ soundfile.episode.creation_timestamp|rfc822 }} GMT</pubDate>
</item>
{% endfor %}
</channel>
......
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