Commit 607b44cb authored by fred's avatar fred
Browse files

fix datetime formatting in rss feed

parent 7741a377
import email.utils
import datetime
import re import re
import time
import urllib2 import urllib2
import uuid import uuid
...@@ -185,3 +188,10 @@ class FormatSearchResultNode(template.Node): ...@@ -185,3 +188,10 @@ class FormatSearchResultNode(template.Node):
@register.inclusion_tag('includes/piwik.html') @register.inclusion_tag('includes/piwik.html')
def piwik(): def piwik():
return {'enabled': settings.ENABLE_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" <rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
...@@ -7,15 +7,15 @@ ...@@ -7,15 +7,15 @@
<title>Radio Panik{% if title %} - {{ title }}{% endif %}</title> <title>Radio Panik{% if title %} - {{ title }}{% endif %}</title>
<link>{{ base_url }}</link> <link>{{ base_url }}</link>
<description></description> <description></description>
<lastBuildDate>{{ soundfiles.0.creation_timestamp|date:"r" }}</lastBuildDate> <lastBuildDate>{{ soundfiles.0.creation_timestamp|rfc822 }}</lastBuildDate>
{% for soundfile in soundfiles|slice:":20" %}<item> {% for soundfile in soundfiles|slice:":20" %}<item>
<title>{% if soundfile.fragment %}{{ soundfile.title }} - {% endif %}{{ soundfile.episode.title }}</title> <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> <link>{{ base_url }}{% url 'episode-view' slug=soundfile.episode.slug emission_slug=soundfile.episode.emission.slug %}</link>
<description>{{ soundfile.episode.text|striptags }}</description> <description>{{ soundfile.episode.text|striptags }}</description>
<enclosure url="{{ base_url }}{{ soundfile|format_url:'mp3' }}" type="audio/mpeg"/> <enclosure url="{{ base_url }}{{ soundfile|format_url:'mp3' }}" type="audio/mpeg"/>
<guid>{{ soundfile.episode.get_absolute_url }}-{{ soundfile.id }}</guid> <guid>{{ base_url }}{{ soundfile.episode.get_absolute_url }}#{{ soundfile.id }}</guid>
<pubDate>{{ soundfile.episode.creation_timestamp|date:"r" }} GMT</pubDate> <pubDate>{{ soundfile.episode.creation_timestamp|rfc822 }} GMT</pubDate>
</item> </item>
{% endfor %} {% endfor %}
</channel> </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