diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index e61b92b57..befaed975 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -11,6 +11,7 @@ - fixed #10956: Account, Profile system bad rendering with lots of - fixed #11112: story archive RSS feed - added Insurance estimator for the USPS shipping driver + - fixed #11121: Syndicated Content search terms require both title and description match 7.8.1 - mark $session->datetime->time as deprecated and remove its use from core code diff --git a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm index d11e31757..fc10a362f 100644 --- a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm @@ -165,15 +165,17 @@ sub generateFeed { if ($self->get('hasTerms') ne '') { my @terms = split /,\s*/, $self->get('hasTerms'); # get the list of terms my $termRegex = join("|", map quotemeta($_), @terms); # turn the terms into a regex string - my @items = $feed->match_item(title=>qr/$termRegex/msi, description=>qr/$termRegex/msi); + my @items = $feed->match_item(title => qr/$termRegex/msi); + push @items, $feed->match_item(description => qr/$termRegex/msi); $feed->clear_item; + $feed->uniq_item; foreach my $item (@items) { $feed->add_item($item); } } - # sort them by date - $feed->sort_item(); + # sort them by date and remove any duplicate from the OR based term matching above + $feed->normalize(); # limit the feed to the maximum number of headlines (or the feed generator limit). $feed->limit_item($limit); diff --git a/t/Asset/Wobject/SyndicatedContent.t b/t/Asset/Wobject/SyndicatedContent.t index d0845ad43..270d59d30 100644 --- a/t/Asset/Wobject/SyndicatedContent.t +++ b/t/Asset/Wobject/SyndicatedContent.t @@ -20,9 +20,11 @@ use Data::Dumper; use WebGUI::Test; use WebGUI::Session; -use Test::More tests => 20; # increment this value for each test you create +use Test::More tests => 21; # increment this value for each test you create +use Test::Deep; use WebGUI::Asset::Wobject::SyndicatedContent; use XML::FeedPP; +use WebGUI::Cache; my $session = WebGUI::Test->session; my %var; @@ -36,7 +38,7 @@ my $node = WebGUI::Asset->getImportNode($session); # Create a version tag to work in my $versionTag = WebGUI::VersionTag->getWorking($session); $versionTag->set({name=>"SyndicatedContent Test"}); -WebGUI::Test->tagsToRollback($versionTag); +addToCleanup($versionTag); my $syndicated_content = $node->addChild({className=>'WebGUI::Asset::Wobject::SyndicatedContent'}); ############################## @@ -138,3 +140,39 @@ EOFEED my $vars = $syndicated_content->getTemplateVariables($feed); ok( defined $vars->{item_loop}->[0]->{description}, 'getTemplateVariables: description is not undefined'); + +#################################################################### +# +# generateFeed, hasTerms +# +#################################################################### + +my $tbbUrl = 'http://www.plainblack.com/tbb.rss'; +$syndicated_content->update({ + rssUrl => $tbbUrl, + hasTerms => 'WebGUI', +}); + +my $cache = WebGUI::Cache->new($session, $tbbUrl, 'RSS'); +open my $rssFile, '<', WebGUI::Test->getTestCollateralPath('tbb.rss') + or die "Unable to get RSS file"; +my $rssContent = do { local $/; <$rssFile>; }; +close $rssFile; +$cache->set($rssContent, 60); + +my $filteredFeed = $syndicated_content->generateFeed(); + +use Data::Dumper; +diag Dumper($filteredFeed->get_item()); + +cmp_deeply( + [ map { $_->title } $filteredFeed->get_item() ], + [ + 'Google Picasa Plugin for WebGUI Gallery', + 'WebGUI Roadmap', + 'WebGUI 8 Performance', + ], + 'generateFeed: filters items based on the terms being in title, or description' +); + +$cache->delete; diff --git a/t/supporting_collateral/tbb.rss b/t/supporting_collateral/tbb.rss new file mode 100644 index 000000000..83af062e6 --- /dev/null +++ b/t/supporting_collateral/tbb.rss @@ -0,0 +1,40 @@ + + + +The Black Blog +/tbb +Mon, 12 Oct 2009 11:54:28 -0500 +Google Picasa Plugin for WebGUI Gallery +http://www.plainblack.com/tbb/google-picasa-plugin-for-webgui-gallery +JT +1254854387 +http://www.plainblack.com/tbb/google-picasa-plugin-for-webgui-gallery +Tue, 06 Oct 2009 13:39:47 -0500 +Today we unveil the Google Picasa plugin for WebGUI Gallery. + +WebGUI Roadmap +http://www.plainblack.com/tbb/webgui-roadmap +JT +1254325377 +http://www.plainblack.com/tbb/webgui-roadmap +Wed, 30 Sep 2009 10:42:57 -0500 +The new roadmap is online. + +WebGUI 8 Performance +http://www.plainblack.com/tbb/webgui-8-performance +JT +1254236976 +http://www.plainblack.com/tbb/webgui-8-performance +Tue, 29 Sep 2009 10:09:36 -0500 +WebGUI 8 is going to be the fastest version of WebGUI ever released. + +I have arrived in Lisboa! +http://www.plainblack.com/tbb/i-have-arrived-in-lisboa +JT +1249140064 +http://www.plainblack.com/tbb/i-have-arrived-in-lisboa +Sat, 01 Aug 2009 10:21:04 -0500 +I'm in Lisbon, Portugal for YAPC::EU. + + +