add: syndicated content wobject now has additional ways to show the description.

This commit is contained in:
Doug Bell 2007-05-28 23:12:13 +00:00
parent 3c52f21923
commit a4f56ff9ef
4 changed files with 120 additions and 3 deletions

View file

@ -11,6 +11,8 @@
- add: Calendar events now allow setting view permissions - add: Calendar events now allow setting view permissions
- add: WebGUI::Paginator now capable of more efficient SQL paginations using - add: WebGUI::Paginator now capable of more efficient SQL paginations using
LIMIT clauses. LIMIT clauses.
- add: SyndicatedContent wobject now has more ways of representing the long
description from the RSS feed.

View file

@ -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 ) =head2 definition ( definition )
Defines the properties of this asset. Defines the properties of this asset.
@ -290,6 +326,7 @@ sub _normalize_items {
# IE doesn't recognize ' # IE doesn't recognize '
$item->{title} =~ s/'/\'/g; $item->{title} =~ s/'/\'/g;
$item->{description} =~ 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'); $rss->{items} = [ $rss->{items} ] unless (ref $rss->{items} eq 'ARRAY');
_normalize_items($rss->{items}); _normalize_items($rss->{items});
#Assign dates "globally" rather than when seen in a viewed feed. #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 #This is important because we can "filter" now and want to ensure we keep order
#correctly as new items appear. #correctly as new items appear.
@ -633,6 +669,7 @@ sub view {
$var{'channel.link'} = $rss_feeds->[0]->{channel}->{link}; $var{'channel.link'} = $rss_feeds->[0]->{channel}->{link};
$var{'channel.description'} = $rss_feeds->[0]->{channel}->{description}; $var{'channel.description'} = $rss_feeds->[0]->{channel}->{description};
} }
$self->_createRSSURLs(\%var); $self->_createRSSURLs(\%var);
$var{item_loop} = $item_loop; $var{item_loop} = $item_loop;

View file

@ -114,12 +114,45 @@ our $HELP = {
{ {
'name' => 'title' 'name' => 'title'
}, },
{
'name' => 'link'
},
{ {
'name' => 'description' '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'
},
] ]
} }
], ],

View file

@ -276,6 +276,51 @@ be useful, others may not.|,
lastUpdated => 1164841201 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; 1;