From c8098e2ca69df24e3ee327ccd6f13ecc78f0b273 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 30 Mar 2011 09:52:55 -0500 Subject: [PATCH] rfe #618: Syndicated Content Asset: Make images in the downloaded RSS-feeds available in the template. --- docs/changelog/7.x.x.txt | 2 ++ docs/gotcha.txt | 4 ++++ lib/WebGUI/Asset/Wobject/SyndicatedContent.pm | 4 +++- lib/WebGUI/Help/Asset_SyndicatedContent.pm | 1 + .../i18n/English/Asset_SyndicatedContent.pm | 5 +++++ sbin/testEnvironment.pl | 1 + t/Asset/Wobject/SyndicatedContent.t | 18 ++++++++++++++++-- 7 files changed, 32 insertions(+), 3 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 6eb0053e7..c9ff0da9d 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -3,6 +3,8 @@ - fixed #12065: "Data error" in AssetManager if URL is Cyrillic - fixed #12075: Underground Style - Search does not search - fixed #12084: Greenportal links are sometimes white on white + - rfe #618: Syndicated Content Asset: Make images in the downloaded + RSS-feeds available in the template. 7.10.12 - fixed #12072: Product, related and accessory assets diff --git a/docs/gotcha.txt b/docs/gotcha.txt index 868f57f11..077093ad7 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -7,6 +7,10 @@ upgrading from one version to the next, or even between multiple versions. Be sure to heed the warnings contained herein as they will save you many hours of grief. +7.10.13 +-------------------------------------------------------------------- + * WebGUI now depends on XML::FeedPP::MediaRSS. + 7.10.12 -------------------------------------------------------------------- * The Dashboard has been extended to include Asset Dashlets. This gives diff --git a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm index f8625e439..6ac468f2f 100644 --- a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm @@ -21,7 +21,7 @@ use Class::C3; use base qw(WebGUI::AssetAspect::RssFeed WebGUI::Asset::Wobject); use WebGUI::Macro; use XML::FeedPP; - +use XML::FeedPP::MediaRSS; =head1 NAME @@ -279,6 +279,7 @@ A reference to an XML::FeedPP object. sub getTemplateVariables { my ($self, $feed) = @_; + my $media = XML::FeedPP::MediaRSS->new($feed); my @items = $feed->get_item; my %var; $var{channel_title} = WebGUI::HTML::filter(scalar $feed->title, 'javascript'); @@ -295,6 +296,7 @@ sub getTemplateVariables { $var{channel_image_height} = WebGUI::HTML::filter($image[5], 'javascript'); foreach my $object (@items) { my %item; + $item{media} = [ $media->for_item($object) ]; $item{title} = WebGUI::HTML::filter(scalar $object->title, 'javascript'); $item{date} = WebGUI::HTML::filter(scalar $object->get_pubDate_epoch, 'javascript'); $item{category} = WebGUI::HTML::filter(scalar $object->category, 'javascript'); diff --git a/lib/WebGUI/Help/Asset_SyndicatedContent.pm b/lib/WebGUI/Help/Asset_SyndicatedContent.pm index 82a3dd2d5..bc8d827d3 100644 --- a/lib/WebGUI/Help/Asset_SyndicatedContent.pm +++ b/lib/WebGUI/Help/Asset_SyndicatedContent.pm @@ -39,6 +39,7 @@ our $HELP = { { 'name' => 'category' }, { 'name' => 'author' }, { 'name' => 'guid' }, + { 'name' => 'media' }, { 'name' => 'description' }, { 'name' => 'descriptionFirst100words' }, { 'name' => 'descriptionFirst75words' }, diff --git a/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm b/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm index 0dcbdacee..c1b5b9724 100644 --- a/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm +++ b/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm @@ -51,6 +51,11 @@ our $I18N = { lastUpdated => 0, }, + 'media' => { + message => q|Any MediaRSS entries for this item: structure is directly copied from XML::FeedPP::MediaRSS|, + lastUpdated => 1301495766, + }, + 'channel_description' => { message => q|A description of the content available through this channel. This variable will be populated by the first feed in a multi-feed list.|, lastUpdated => 0, diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index d6d2df0bf..0c7a314cb 100755 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -102,6 +102,7 @@ checkModule("HTML::Template", 2.9 ); checkModule("HTML::Template::Expr", 0.07, 2 ); checkModule("Template", 2.20, 2 ); checkModule("XML::FeedPP", 0.40 ); +checkModule("XML::FeedPP::MediaRSS", 0.02 ); checkModule("JSON", 2.12 ); checkModule("Config::JSON", "1.3.1" ); checkModule("Text::CSV_XS", "0.64" ); diff --git a/t/Asset/Wobject/SyndicatedContent.t b/t/Asset/Wobject/SyndicatedContent.t index 4a3857af1..c6b164635 100644 --- a/t/Asset/Wobject/SyndicatedContent.t +++ b/t/Asset/Wobject/SyndicatedContent.t @@ -20,7 +20,7 @@ use Data::Dumper; use WebGUI::Test; use WebGUI::Session; -use Test::More tests => 29; # increment this value for each test you create +use Test::More tests => 30; # increment this value for each test you create use Test::Deep; use WebGUI::Asset::Wobject::SyndicatedContent; use XML::FeedPP; @@ -144,7 +144,7 @@ ok( defined $vars->{item_loop}->[0]->{description}, 'getTemplateVariables: descr ##Construct a feed with a wrapped description, to check for paragraph handling. $feed = XML::FeedPP->new(< - + The WebGUI buglist /tbb @@ -165,6 +165,11 @@ character, creating invalid markup.</p> <p>No more text is shown of the first paragraph beyond the bold characters of the first line.</p> <p>Third paragraph, for completeness.</p> + @@ -185,6 +190,15 @@ is $vars->{item_loop}->[0]->{descriptionFirstSentence}, Rich Text editor in the first sentence of the description.", '... first sentence, with HTML stripped'; +is_deeply $vars->{item_loop}->[0]->{media}, [ + { + url => 'http://www.plainblack.com/wg_btn.jpg', + type => 'image/jpeg', + medium => 'image', + filesize => 1415, + } +], 'MediaRSS'; + #################################################################### # # generateFeed, hasTerms