diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 7a4d5df74..e54727d32 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -9,6 +9,7 @@ - fixed #11582: Registering with a .mobi email address - fixed #11580: Date not populated for Story Archive RSS feed - fixed #11587: Thingy, no fields and undefined statement handles + - fixed #11589: Syndicated Content: Return raw text for sentence and word template variables 7.9.5 - Asset->www_copy now has a progress bar diff --git a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm index adca46f13..493c0dbfb 100644 --- a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm @@ -305,17 +305,19 @@ sub getTemplateVariables { $item{guid} = WebGUI::HTML::filter(scalar $object->guid, 'javascript'); $item{link} = WebGUI::HTML::filter(scalar $object->link, 'javascript'); my $description = WebGUI::HTML::filter(scalar($object->description), 'javascript'); + my $raw_description = WebGUI::HTML::filter($description, 'all'); + $raw_description =~ s/^\s+//s; $item{description} = defined $description ? $description : ''; - $item{descriptionFirst100words} = $item{description}; - $item{descriptionFirst100words} =~ s/(((\S+)\s+){100}).*/$1/s; + $item{descriptionFirst100words} = $raw_description; + $item{descriptionFirst100words} =~ s/(((\S+)\s+){1,100}).*/$1/ms; $item{descriptionFirst75words} = $item{descriptionFirst100words}; - $item{descriptionFirst75words} =~ s/(((\S+)\s+){75}).*/$1/s; + $item{descriptionFirst75words} =~ s/(((\S+)\s+){1,75}).*/$1/ms; $item{descriptionFirst50words} = $item{descriptionFirst75words}; - $item{descriptionFirst50words} =~ s/(((\S+)\s+){50}).*/$1/s; + $item{descriptionFirst50words} =~ s/(((\S+)\s+){1,50}).*/$1/ms; $item{descriptionFirst25words} = $item{descriptionFirst50words}; - $item{descriptionFirst25words} =~ s/(((\S+)\s+){25}).*/$1/s; + $item{descriptionFirst25words} =~ s/(((\S+)\s+){1,25}).*/$1/ms; $item{descriptionFirst10words} = $item{descriptionFirst25words}; - $item{descriptionFirst10words} =~ s/(((\S+)\s+){10}).*/$1/s; + $item{descriptionFirst10words} =~ s/(((\S+)\s+){1,10}).*/$1/ms; if ($description =~ /

/) { my $html = $description; $html =~ tr/\n/ /s; @@ -329,12 +331,12 @@ sub getTemplateVariables { $item{descriptionFirstParagraph} = $item{descriptionFirst2paragraphs}; $item{descriptionFirstParagraph} =~ s/^(.*?\n).*/$1/s; } - $item{descriptionFirst4sentences} = $item{description}; - $item{descriptionFirst4sentences} =~ s/^((.*?\.){4}).*/$1/s; + $item{descriptionFirst4sentences} = $raw_description; + $item{descriptionFirst4sentences} =~ s/^((.*?\.){1,4}).*/$1/s; $item{descriptionFirst3sentences} = $item{descriptionFirst4sentences}; - $item{descriptionFirst3sentences} =~ s/^((.*?\.){3}).*/$1/s; + $item{descriptionFirst3sentences} =~ s/^((.*?\.){1,3}).*/$1/s; $item{descriptionFirst2sentences} = $item{descriptionFirst3sentences}; - $item{descriptionFirst2sentences} =~ s/^((.*?\.){2}).*/$1/s; + $item{descriptionFirst2sentences} =~ s/^((.*?\.){1,2}).*/$1/s; $item{descriptionFirstSentence} = $item{descriptionFirst2sentences}; $item{descriptionFirstSentence} =~ s/^(.*?\.).*/$1/s; push @{$var{item_loop}}, \%item; diff --git a/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm b/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm index 2633ce226..0dcbdacee 100644 --- a/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm +++ b/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm @@ -280,48 +280,48 @@ Feed Order: Items will be in the order they appeared in the feed} }, 'descriptionFirst100words' => { - message => q{The first 100 words of the description.}, - lastUpdated => 0, + message => q{The first 100 words of the description, with all HTML removed.}, + lastUpdated => 1274815483, }, 'descriptionFirst75words' => { - message => q{The first 75 words of the description.}, - lastUpdated => 0, + message => q{The first 75 words of the description, with all HTML removed.}, + lastUpdated => 1274815485, }, 'descriptionFirst50words' => { - message => q{The first 50 words of the description.}, - lastUpdated => 0, + message => q{The first 50 words of the description, with all HTML removed.}, + lastUpdated => 1274815486, }, 'descriptionFirst25words' => { - message => q{The first 25 words of the description.}, - lastUpdated => 0, + message => q{The first 25 words of the description, with all HTML removed.}, + lastUpdated => 1274815488, }, 'descriptionFirst10words' => { - message => q{The first 10 words of the description.}, - lastUpdated => 0, + message => q{The first 10 words of the description, with all HTML removed.}, + lastUpdated => 1274815490, }, 'descriptionFirst2paragraphs' => { - message => q{The first 2 paragraphs of the description.}, + message => q{The first 2 paragraphs of the description, with all HTML removed.}, lastUpdated => 0, }, 'descriptionFirstParagraph' => { - message => q{The first paragraph of the description.}, + message => q{The first paragraph of the description, with all HTML removed.}, lastUpdated => 0, }, 'descriptionFirst4sentences' => { - message => q{The first 4 sentences of the description.}, - lastUpdated => 0, + message => q{The first 4 sentences of the description, with all HTML removed.}, + lastUpdated => 1274816277, }, 'descriptionFirst3sentences' => { - message => q{The first 3 sentences of the description.}, - lastUpdated => 0, + message => q{The first 3 sentences of the description, with all HTML removed.}, + lastUpdated => 1274816276, }, 'descriptionFirst2sentences' => { - message => q{The first 2 sentences of the description.}, - lastUpdated => 0, + message => q{The first 2 sentences of the description, with all HTML removed.}, + lastUpdated => 1274816274, }, 'descriptionFirstSentence' => { - message => q{The first sentence of the description.}, - lastUpdated => 0, + message => q{The first sentence of the description, with all HTML removed.}, + lastUpdated => 1274816273, }, }; diff --git a/t/Asset/Wobject/SyndicatedContent.t b/t/Asset/Wobject/SyndicatedContent.t index ac29eff1a..828731897 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 => 27; # increment this value for each test you create +use Test::More tests => 29; # increment this value for each test you create use Test::Deep; use WebGUI::Asset::Wobject::SyndicatedContent; use XML::FeedPP; @@ -176,7 +176,14 @@ is $vars->{item_loop}->[0]->{descriptionFirstParagraph}, '... first paragraph, when HTML is used'; is $vars->{item_loop}->[0]->{descriptionFirst2paragraphs}, "

In the attached feed, there is a hidden return line character from the Rich Text editor in the first sentence of the description. When using a Syndicated Content for the feed, the variable descriptionFirstParagraph variable cuts off at this return line character, creating invalid markup.

No more text is shown of the first paragraph beyond the bold characters of the first line.

", -'... first paragraph, when HTML is used'; +'... first two paragraphs, when HTML is used'; +is $vars->{item_loop}->[0]->{descriptionFirst10words}, +"In the attached feed, there is a hidden return line ", +'... first 10 words, with HTML stripped'; +is $vars->{item_loop}->[0]->{descriptionFirstSentence}, +"In the attached feed, there is a hidden return line character from the +Rich Text editor in the first sentence of the description.", +'... first sentence, with HTML stripped'; #################################################################### #