diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 6c882a420..d381e4d59 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -2,6 +2,7 @@ - fixed: Unable to template user profile viewing and editing screens. - fixed: Product Variants not saving SKU - fixed: Shop Payment Methods + - fixed: Syndicated Content asset makes template engine choke - fixed: Asset Manager breaks when an asset is locked - fixed: Asset Manager is slow to load - fixed: project management application unable to add or edit tasks. diff --git a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm index 3fffa51e5..5f6c102b3 100644 --- a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm @@ -283,6 +283,7 @@ sub _find_record { } #------------------------------------------------------------------- +# First, get rid of things we don't want. # Copy the guid field to the link field if the guid looks like a link. # This is a kludge that gets around the fact that some folks use the link # field as the link to the story while others use it as the link @@ -300,25 +301,29 @@ sub _normalize_items { my $max_words = 10; for my $item (@{$_[0]}) { - if ($item->{guid} && ($item->{guid} =~ /^http:\/\//i)) { - $item->{link} = $item->{guid}; - } - if (!$item->{title}) { - my @description_words = split(/\s/, $item->{description}); - if (@description_words <= $max_words) { - $item->{title} = $item->{description}; - } else { - $item->{title} = join(' ', @description_words[0..$max_words-1]) . - ' ...'; - } - } + # Get rid of any keys in the items that we do not want + my @wantedKeys = qw( title link description pubDate ); + %{ $item } = map { $_ => $item->{ $_ } } @wantedKeys; + + if ($item->{guid} && ($item->{guid} =~ /^http:\/\//i)) { + $item->{link} = $item->{guid}; + } + if (!$item->{title}) { + my @description_words = split(/\s/, $item->{description}); + if (@description_words <= $max_words) { + $item->{title} = $item->{description}; + } else { + $item->{title} = join(' ', @description_words[0..$max_words-1]) . + ' ...'; + } + } - # IE doesn't recognize ' - $item->{title} =~ s/'/\'/g; - $item->{description} =~ s/'/\'/g; - $item->{category} = [$item->{category}] - if ref $item->{category} ne 'ARRAY'; - appendChoppedDescriptionTemplateVars($item); + # IE doesn't recognize ' + $item->{title} =~ s/'/\'/g; + $item->{description} =~ s/'/\'/g; + $item->{category} = [$item->{category}] + if ref $item->{category} ne 'ARRAY'; + appendChoppedDescriptionTemplateVars($item); } } @@ -570,7 +575,7 @@ sub _get_items { #Sort feeds in order by channel title. #@rss_feeds=sort{$a->{channel}->{title} cmp $b->{channel}->{title}} @rss_feeds; - + if ($displayMode eq 'grouped') { _create_grouped_items($items,\@rss_feeds,$maxHeadlines,$hasTermsRegex); } else { diff --git a/t/Asset/Wobject/SyndicatedContent.t b/t/Asset/Wobject/SyndicatedContent.t index ceabfb279..dc6a788bd 100644 --- a/t/Asset/Wobject/SyndicatedContent.t +++ b/t/Asset/Wobject/SyndicatedContent.t @@ -49,8 +49,9 @@ isa_ok($syndicated_content, 'WebGUI::Asset::Wobject::SyndicatedContent'); my $newSyndicatedContentSettings = { cacheTimeout => 124, templateId => "PBtmpl0000000000000065", - rssUrl => "http://morningmonologue.wordpress.com/feed/", # broken + #rssUrl => "http://morningmonologue.wordpress.com/feed/", # broken #rssUrl => "http://motivationalmuse.wordpress.com/feed/", #working feed + rssUrl => 'https://svn.webgui.org/svnweb/plainblack/rss/WebGUI/', }; # update the new values for this instance @@ -96,7 +97,7 @@ my $hasTermsRegex = "" ; #$syndicated_content->_make_regex( $syndicated_content- my $rss_info = WebGUI::Asset::Wobject::SyndicatedContent::_get_rss_data($session,$newSyndicatedContentSettings->{'rssUrl'}); ok(ref($rss_info) eq 'HASH', "Hashref returned from _get_rss_data"); -push(@rss_feeds, $rss_info) ; +push(@rss_feeds, $rss_info); my $xml_list = WebGUI::Asset::Wobject::SyndicatedContent::_create_interleaved_items($items, \@rss_feeds , $max_headlines, $hasTermsRegex); ok($xml_list , "Got results back from XML " );