diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 2e5126a0a..dfce0d8e1 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -11,6 +11,8 @@ - add: Calendar events now allow setting view permissions - add: WebGUI::Paginator now capable of more efficient SQL paginations using LIMIT clauses. + - add: SyndicatedContent wobject now has more ways of representing the long + description from the RSS feed. diff --git a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm index e2c85f96a..3813333f7 100644 --- a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm @@ -100,6 +100,42 @@ sub _getValidatedUrls { #------------------------------------------------------------------- +=head2 appendChoppedTemplateDescriptionVars ( var ) + +Appends shorter versions of the feeds description field to template vars returned. + +=cut + +sub appendChoppedDescriptionTemplateVars { + my $item = shift; + + $item->{"descriptionFull"} = $item->{description}; + $item->{"descriptionFirst100words"} = $item->{"descriptionFull"}; + $item->{"descriptionFirst100words"} =~ s/(((\S+)\s+){100}).*/$1/s; + $item->{"descriptionFirst75words"} = $item->{"descriptionFirst100words"}; + $item->{"descriptionFirst75words"} =~ s/(((\S+)\s+){75}).*/$1/s; + $item->{"descriptionFirst50words"} = $item->{"descriptionFirst75words"}; + $item->{"descriptionFirst50words"} =~ s/(((\S+)\s+){50}).*/$1/s; + $item->{"descriptionFirst25words"} = $item->{"descriptionFirst50words"}; + $item->{"descriptionFirst25words"} =~ s/(((\S+)\s+){25}).*/$1/s; + $item->{"descriptionFirst10words"} = $item->{"descriptionFirst25words"}; + $item->{"descriptionFirst10words"} =~ s/(((\S+)\s+){10}).*/$1/s; + $item->{"descriptionFirst2paragraphs"} = $item->{"descriptionFull"}; + $item->{"descriptionFirst2paragraphs"} =~ s/^((.*?\n){2}).*/$1/s; + $item->{"descriptionFirstParagraph"} = $item->{"descriptionFirst2paragraphs"}; + $item->{"descriptionFirstParagraph"} =~ s/^(.*?\n).*/$1/s; + $item->{"descriptionFirst4sentences"} = $item->{"descriptionFull"}; + $item->{"descriptionFirst4sentences"} =~ s/^((.*?\.){4}).*/$1/s; + $item->{"descriptionFirst3sentences"} = $item->{"descriptionFirst4sentences"}; + $item->{"descriptionFirst3sentences"} =~ s/^((.*?\.){3}).*/$1/s; + $item->{"descriptionFirst2sentences"} = $item->{"descriptionFirst3sentences"}; + $item->{"descriptionFirst2sentences"} =~ s/^((.*?\.){2}).*/$1/s; + $item->{"descriptionFirstSentence"} = $item->{"descriptionFirst2sentences"}; + $item->{"descriptionFirstSentence"} =~ s/^(.*?\.).*/$1/s; +} + +#------------------------------------------------------------------- + =head2 definition ( definition ) Defines the properties of this asset. @@ -290,6 +326,7 @@ sub _normalize_items { # IE doesn't recognize ' $item->{title} =~ s/'/\'/g; $item->{description} =~ s/'/\'/g; + appendChoppedDescriptionTemplateVars($item); } } @@ -364,7 +401,6 @@ sub _get_rss_data { $rss->{items} = [ $rss->{items} ] unless (ref $rss->{items} eq 'ARRAY'); _normalize_items($rss->{items}); - #Assign dates "globally" rather than when seen in a viewed feed. #This is important because we can "filter" now and want to ensure we keep order #correctly as new items appear. @@ -633,6 +669,7 @@ sub view { $var{'channel.link'} = $rss_feeds->[0]->{channel}->{link}; $var{'channel.description'} = $rss_feeds->[0]->{channel}->{description}; } + $self->_createRSSURLs(\%var); $var{item_loop} = $item_loop; diff --git a/lib/WebGUI/Help/Asset_SyndicatedContent.pm b/lib/WebGUI/Help/Asset_SyndicatedContent.pm index 69b2d166c..22e9049ac 100644 --- a/lib/WebGUI/Help/Asset_SyndicatedContent.pm +++ b/lib/WebGUI/Help/Asset_SyndicatedContent.pm @@ -114,12 +114,45 @@ our $HELP = { { 'name' => 'title' }, + { + 'name' => 'link' + }, { 'name' => 'description' }, { - 'name' => 'link' - } + 'name' => 'descriptionFirst100words' + }, + { + 'name' => 'descriptionFirst75words' + }, + { + 'name' => 'descriptionFirst50words' + }, + { + 'name' => 'descriptionFirst25words' + }, + { + 'name' => 'descriptionFirst10words' + }, + { + 'name' => 'descriptionFirst2paragraphs' + }, + { + 'name' => 'descriptionFirstParagraph' + }, + { + 'name' => 'descriptionFirst4sentences' + }, + { + 'name' => 'descriptionFirst3sentences' + }, + { + 'name' => 'descriptionFirst2sentences' + }, + { + 'name' => 'descriptionFirstSentence' + }, ] } ], diff --git a/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm b/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm index 7a700c413..eb45a7f1b 100644 --- a/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm +++ b/lib/WebGUI/i18n/English/Asset_SyndicatedContent.pm @@ -276,6 +276,51 @@ be useful, others may not.|, lastUpdated => 1164841201 }, + 'descriptionFirst100words' => { + message => q{The first 100 words of the description.}, + lastUpdated => 0, + }, + 'descriptionFirst75words' => { + message => q{The first 75 words of the description.}, + lastUpdated => 0, + }, + 'descriptionFirst50words' => { + message => q{The first 50 words of the description.}, + lastUpdated => 0, + }, + 'descriptionFirst25words' => { + message => q{The first 25 words of the description.}, + lastUpdated => 0, + }, + 'descriptionFirst10words' => { + message => q{The first 10 words of the description.}, + lastUpdated => 0, + }, + 'descriptionFirst2paragraphs' => { + message => q{The first 2 paragraphs of the description.}, + lastUpdated => 0, + }, + 'descriptionFirstParagraph' => { + message => q{The first paragraph of the description.}, + lastUpdated => 0, + }, + 'descriptionFirst4sentences' => { + message => q{The first 4 sentences of the description.}, + lastUpdated => 0, + }, + 'descriptionFirst3sentences' => { + message => q{The first 3 sentences of the description.}, + lastUpdated => 0, + }, + 'descriptionFirst2sentences' => { + message => q{The first 2 sentences of the description.}, + lastUpdated => 0, + }, + 'descriptionFirstSentence' => { + message => q{The first sentence of the description.}, + lastUpdated => 0, + }, + }; 1;