From 1b9ed1b6f1331c11df10ab9611909d4fb2bbf1d3 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Sun, 20 Nov 2016 00:24:02 +1300 Subject: [PATCH] ENH: Add partial caching to RSS feed MINOR: Replay keywords with iTunes category field --- code/pagetypes/PodcastPage.php | 5 +++-- templates/RSS/PodcastRSSFeed.ss | 28 ++++++++++++---------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/code/pagetypes/PodcastPage.php b/code/pagetypes/PodcastPage.php index 9c2e2ca..5ca0d76 100644 --- a/code/pagetypes/PodcastPage.php +++ b/code/pagetypes/PodcastPage.php @@ -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( @@ -161,7 +161,7 @@ public function getCMSFields() ,$completeField ,$blockField ,$explicitField - ,TextAreaField::create('Keywords') + ,TextAreaField::create('Categories') ,$podcastImage )); @@ -231,6 +231,7 @@ public function init() */ public function rss() { + $this->response->addHeader("Content-Type", "application/xml"); return $this->renderWith("PodcastRSSFeed"); } diff --git a/templates/RSS/PodcastRSSFeed.ss b/templates/RSS/PodcastRSSFeed.ss index 833d6f3..0152cfe 100644 --- a/templates/RSS/PodcastRSSFeed.ss +++ b/templates/RSS/PodcastRSSFeed.ss @@ -1,5 +1,5 @@ - + @@ -9,37 +9,33 @@ <% if $Copyright %>$Copyright.XML<% end_if %> <% if $Subtitle %>$Subtitle.XML<% end_if %> <% if $Author %>$Author.XML<% end_if %> -<% if $Summary %> -$Summary.NoHTML.XML -$Summary.NoHTML.XML -<% end_if %> -<% if $OwnerName || $OwnerEmail %> - +<% if $Summary %>$Summary.NoHTML.XML +$Summary.NoHTML.XML<% end_if %> +<% if $Categories %>$Categories.RAW<% end_if %> +<% if $OwnerName || $OwnerEmail %> <% if $OwnerName %>$OwnerName.XML<% end_if %> <% if $OwnerEmail %>$OwnerEmail.XML<% end_if %> - -<% end_if %> +<% end_if %> <% if $PodcastImage %><% end_if %> <% if $Block %>yes<% end_if %> <% if $Explicit %>$Explicit<% end_if %> - +<% cached 'Podcast', $List('PodcastEpisode').max('LastEdited'), $List('PodcastEpisode').count() %> <% if $podcastEpisodes %><% loop $podcastEpisodes %> <% if $EpisodeTitle %>$EpisodeTitle.XML<% end_if %> <% if $EpisodeAuthor %>$EpisodeAuthor.XML<% end_if %> <% if $EpisodeSubtitle %>$EpisodeSubtitle.XML<% end_if %> - <% if $EpisodeSummary %> - $EpisodeSummary.NoHTML.XML - $EpisodeSummary.NoHTML.XML - <% end_if %> + <% if $EpisodeSummary %>$EpisodeSummary.NoHTML.XML + $EpisodeSummary.NoHTML.XML<% end_if %> <% if $EpisodeImage %><% end_if %> <% if $EpisodeFile %> - $EpisodeLink<%end_if %> + $EpisodeLink<% end_if %> <% if $EpisodeDate %>$EpisodeDate.Rfc822<% else %>$Created.Rfc822<% end_if %> <% if $EpisodeDuration %>$EpisodeDuration<% end_if %> <% if $BlockEpisode %>yes<% end_if %> <% if $ExplicitEpisode %>$ExplicitEpisode<% end_if %> <% end_loop %><% end_if %> +<% end_cached %> - \ No newline at end of file +