Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
radiopanik
panikweb
Commits
7741a377
Commit
7741a377
authored
Sep 01, 2013
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add pretty basic podcast rss feed
parent
2041e2ca
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
panikweb/urls.py
panikweb/urls.py
+2
-0
panikweb/views.py
panikweb/views.py
+14
-0
panikweb_templates/templates/podcasts.html
panikweb_templates/templates/podcasts.html
+22
-0
No files found.
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