Skip to content

Commit

Permalink
ENH: Add partial caching to RSS feed
Browse files Browse the repository at this point in the history
MINOR: Replay keywords with iTunes category field
  • Loading branch information
Luke Edwards committed Nov 19, 2016
1 parent 1f651c2 commit 1b9ed1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
5 changes: 3 additions & 2 deletions code/pagetypes/PodcastPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PodcastPage extends Page implements PermissionProvider
,'Complete' => 'Boolean'
,'Block' => 'Boolean'
,'Explicit' => 'enum("No, Clean, Yes");'
,'Keywords' => 'Text'
,'Categories' => 'Text'
);

private static $has_one = array(
Expand Down Expand Up @@ -161,7 +161,7 @@ public function getCMSFields()
,$completeField
,$blockField
,$explicitField
,TextAreaField::create('Keywords')
,TextAreaField::create('Categories')
,$podcastImage
));

Expand Down Expand Up @@ -231,6 +231,7 @@ public function init()
*/
public function rss()
{
$this->response->addHeader("Content-Type", "application/xml");
return $this->renderWith("PodcastRSSFeed");
}

Expand Down
28 changes: 12 additions & 16 deletions templates/RSS/PodcastRSSFeed.ss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="{$AbsoluteLink}rss" rel="self" type="application/rss+xml" />

Expand All @@ -9,37 +9,33 @@
<% if $Copyright %><copyright>$Copyright.XML</copyright><% end_if %>
<% if $Subtitle %><itunes:subtitle>$Subtitle.XML</itunes:subtitle><% end_if %>
<% if $Author %><itunes:author>$Author.XML</itunes:author><% end_if %>
<% if $Summary %>
<itunes:summary>$Summary.NoHTML.XML</itunes:summary>
<description>$Summary.NoHTML.XML</description>
<% end_if %>
<% if $OwnerName || $OwnerEmail %>
<itunes:owner>
<% if $Summary %><itunes:summary>$Summary.NoHTML.XML</itunes:summary>
<description>$Summary.NoHTML.XML</description><% end_if %>
<% if $Categories %>$Categories.RAW<% end_if %>
<% if $OwnerName || $OwnerEmail %><itunes:owner>
<% if $OwnerName %><itunes:name>$OwnerName.XML</itunes:name><% end_if %>
<% if $OwnerEmail %><itunes:email>$OwnerEmail.XML</itunes:email><% end_if %>
</itunes:owner>
<% end_if %>
</itunes:owner><% end_if %>
<% if $PodcastImage %><itunes:image href="$PodcastImage.getAbsoluteURL" /><% end_if %>
<% if $Block %><itunes:block>yes</itunes:block><% end_if %>
<% if $Explicit %><itunes:explicit>$Explicit</itunes:explicit><% end_if %>

<% cached 'Podcast', $List('PodcastEpisode').max('LastEdited'), $List('PodcastEpisode').count() %>
<% if $podcastEpisodes %><% loop $podcastEpisodes %>
<item>
<% if $EpisodeTitle %><title>$EpisodeTitle.XML</title><% end_if %>
<% if $EpisodeAuthor %><itunes:author>$EpisodeAuthor.XML</itunes:author><% end_if %>
<% if $EpisodeSubtitle %><itunes:subtitle>$EpisodeSubtitle.XML</itunes:subtitle><% end_if %>
<% if $EpisodeSummary %>
<itunes:summary>$EpisodeSummary.NoHTML.XML</itunes:summary>
<description>$EpisodeSummary.NoHTML.XML</description>
<% end_if %>
<% if $EpisodeSummary %><itunes:summary>$EpisodeSummary.NoHTML.XML</itunes:summary>
<description>$EpisodeSummary.NoHTML.XML</description><% end_if %>
<% if $EpisodeImage %><itunes:image href="$EpisodeImage.getAbsoluteURL" /><% end_if %>
<% if $EpisodeFile %><enclosure url="$EpisodeFile.getAbsoluteURL" length="$EpisodeFile.getAbsoluteSize" type="$getMime" />
<guid>$EpisodeLink</guid><%end_if %>
<guid>$EpisodeLink</guid><% end_if %>
<% if $EpisodeDate %><pubDate>$EpisodeDate.Rfc822</pubDate><% else %><pubDate>$Created.Rfc822</pubDate><% end_if %>
<% if $EpisodeDuration %><itunes:duration>$EpisodeDuration</itunes:duration><% end_if %>
<% if $BlockEpisode %><itunes:block>yes</itunes:block><% end_if %>
<% if $ExplicitEpisode %><itunes:explicit>$ExplicitEpisode</itunes:explicit><% end_if %>
</item>
<% end_loop %><% end_if %>
<% end_cached %>
</channel>
</rss>
</rss>

0 comments on commit 1b9ed1b

Please sign in to comment.