Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
radiopanik
panikweb
Commits
7741a377
Commit
7741a377
authored
Sep 01, 2013
by
fred
Browse files
add pretty basic podcast rss feed
parent
2041e2ca
Changes
3
Hide whitespace changes
Inline
Side-by-side
panikweb/urls.py
View file @
7741a377
...
...
@@ -25,6 +25,8 @@ urlpatterns = patterns('',
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
'^admin/fiber/'
,
include
(
'fiber.admin_urls'
)),
(
r
'^jsi18n/$'
,
'django.views.i18n.javascript_catalog'
,
{
'packages'
:
(
'fiber'
,),}),
...
...
panikweb/views.py
View file @
7741a377
...
...
@@ -466,3 +466,17 @@ class NewsItemDetailView(DetailView):
model
=
NewsItem
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
()
panikweb_templates/templates/podcasts.html
0 → 100644
View file @
7741a377
{% 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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment