SC should have OR based term matching on the title and description. Fixes bug #11121
This commit is contained in:
parent
4ebd4038a0
commit
c2fde74448
4 changed files with 86 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
40
t/supporting_collateral/tbb.rss
Normal file
40
t/supporting_collateral/tbb.rss
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>The Black Blog</title>
|
||||
<link>/tbb</link>
|
||||
<copyright /><pubDate>Mon, 12 Oct 2009 11:54:28 -0500</pubDate>
|
||||
<description /><item><title>Google Picasa Plugin for WebGUI Gallery</title>
|
||||
<link>http://www.plainblack.com/tbb/google-picasa-plugin-for-webgui-gallery</link>
|
||||
<author>JT</author>
|
||||
<epochDate>1254854387</epochDate>
|
||||
<guid isPermaLink="true">http://www.plainblack.com/tbb/google-picasa-plugin-for-webgui-gallery</guid>
|
||||
<pubDate>Tue, 06 Oct 2009 13:39:47 -0500</pubDate>
|
||||
<userDefined1 /><userDefined2 /><userDefined3 /><userDefined4 /><userDefined5 /><description>Today we unveil the Google Picasa plugin for WebGUI Gallery.</description>
|
||||
</item>
|
||||
<item><title>WebGUI Roadmap</title>
|
||||
<link>http://www.plainblack.com/tbb/webgui-roadmap</link>
|
||||
<author>JT</author>
|
||||
<epochDate>1254325377</epochDate>
|
||||
<guid isPermaLink="true">http://www.plainblack.com/tbb/webgui-roadmap</guid>
|
||||
<pubDate>Wed, 30 Sep 2009 10:42:57 -0500</pubDate>
|
||||
<userDefined1 /><userDefined2 /><userDefined3 /><userDefined4 /><userDefined5 /><description>The new roadmap is online.</description>
|
||||
</item>
|
||||
<item><title>WebGUI 8 Performance</title>
|
||||
<link>http://www.plainblack.com/tbb/webgui-8-performance</link>
|
||||
<author>JT</author>
|
||||
<epochDate>1254236976</epochDate>
|
||||
<guid isPermaLink="true">http://www.plainblack.com/tbb/webgui-8-performance</guid>
|
||||
<pubDate>Tue, 29 Sep 2009 10:09:36 -0500</pubDate>
|
||||
<userDefined1 /><userDefined2 /><userDefined3 /><userDefined4 /><userDefined5 /><description>WebGUI 8 is going to be the fastest version of WebGUI ever released.</description>
|
||||
</item>
|
||||
<item><title>I have arrived in Lisboa!</title>
|
||||
<link>http://www.plainblack.com/tbb/i-have-arrived-in-lisboa</link>
|
||||
<author>JT</author>
|
||||
<epochDate>1249140064</epochDate>
|
||||
<guid isPermaLink="true">http://www.plainblack.com/tbb/i-have-arrived-in-lisboa</guid>
|
||||
<pubDate>Sat, 01 Aug 2009 10:21:04 -0500</pubDate>
|
||||
<userDefined1 /><userDefined2 /><userDefined3 /><userDefined4 /><userDefined5 /><description>I'm in Lisbon, Portugal for YAPC::EU.</description>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
Loading…
Add table
Add a link
Reference in a new issue