Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
panikweb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
panikweb
Commits
3dc5e1ec
Commit
3dc5e1ec
authored
Sep 18, 2013
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change podcast feed to use contrib.syndication
parent
60d49798
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
35 deletions
+42
-35
panikweb/views.py
panikweb/views.py
+36
-13
panikweb_templates/templates/feed/newsitem.html
panikweb_templates/templates/feed/newsitem.html
+0
-0
panikweb_templates/templates/feed/soundfile.html
panikweb_templates/templates/feed/soundfile.html
+6
-0
panikweb_templates/templates/podcasts.html
panikweb_templates/templates/podcasts.html
+0
-22
No files found.
panikweb/views.py
View file @
3dc5e1ec
from
datetime
import
datetime
,
timedelta
import
time
import
math
import
os
import
stat
import
time
from
django.views.decorators.cache
import
cache_control
from
django.views.generic.base
import
TemplateView
...
...
@@ -542,18 +544,40 @@ class NewsItemDetailView(DetailView):
newsitem
=
NewsItemDetailView
.
as_view
()
class
PodcastsFeedView
(
TemplateView
):
template_name
=
'podcasts.html'
content_type
=
'application/rss+xml'
class
PodcastsFeed
(
Feed
):
title
=
'Radio Panik - Podcasts'
link
=
'/'
description_template
=
'feed/soundfile.html'
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
def
items
(
self
):
return
SoundFile
.
objects
.
select_related
().
filter
(
podcastable
=
True
).
order_by
(
'-creation_timestamp'
)[:
5
]
def
item_title
(
self
,
item
):
if
item
.
fragment
:
return
'%s - %s'
%
(
item
.
title
,
item
.
episode
.
title
)
return
item
.
episode
.
title
podcasts_feed
=
PodcastsFeedView
.
as_view
()
def
item_link
(
self
,
item
):
return
item
.
episode
.
get_absolute_url
()
def
item_enclosure_url
(
self
,
item
):
return
item
.
get_format_url
(
'mp3'
)
def
item_enclosure_length
(
self
,
item
):
sound_path
=
item
.
get_format_path
(
'mp3'
)
try
:
return
os
.
stat
(
sound_path
)[
stat
.
ST_SIZE
]
except
OSError
:
return
0
def
item_enclosure_mimetype
(
self
,
item
):
return
'audio/mpeg'
def
item_pubdate
(
self
,
item
):
return
item
.
creation_timestamp
podcasts_feed
=
PodcastsFeed
()
class
FiberPageView
(
fiber
.
views
.
FiberTemplateView
):
...
...
@@ -567,7 +591,7 @@ fiber_page = FiberPageView.as_view()
class
RssNewsFeed
(
Feed
):
title
=
'Radio Panik'
link
=
'/news/'
description_template
=
'
news/feed
.html'
description_template
=
'
feed/newsitem
.html'
def
items
(
self
):
return
NewsItem
.
objects
.
order_by
(
'-date'
)[:
10
]
...
...
@@ -577,5 +601,4 @@ rss_news_feed = RssNewsFeed()
class
AtomNewsFeed
(
RssNewsFeed
):
feed_type
=
Atom1Feed
atom_news_feed
=
AtomNewsFeed
()
panikweb_templates/templates/
news/feed
.html
→
panikweb_templates/templates/
feed/newsitem
.html
View file @
3dc5e1ec
File moved
panikweb_templates/templates/feed/soundfile.html
0 → 100644
View file @
3dc5e1ec
{% load thumbnails %}
{% if obj.episode.image %}
<img
src=
"{{ obj.episode.image|thumbnail:'320x240' }}"
/>
{% endif %}
{{ obj.episode.text }}
panikweb_templates/templates/podcasts.html
deleted
100644 → 0
View file @
60d49798
{% 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/"
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|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' }}"
length=
"{{ soundfile|format_length:'mp3' }}"
type=
"audio/mpeg"
/>
<guid>
{{ base_url }}{{ soundfile.episode.get_absolute_url }}#{{ soundfile.id }}
</guid>
<pubDate>
{{ soundfile.episode.creation_timestamp|rfc822 }}
</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