added a new function to WebGUI::HTML to parse html text and extract a list of elements based on a tag

spec. used to extract paragraphs for the synopsis; convert FeedPP properties to scalar context so that
blank fields are rendered properly.
This commit is contained in:
David Delikat 2009-01-23 03:41:49 +00:00
parent 2893944837
commit 16ce54bf4f
4 changed files with 61 additions and 8 deletions

View file

@ -548,11 +548,15 @@ sub getSynopsisAndContent {
my $synopsis = shift;
my $body = shift;
unless ($synopsis) {
$body =~ s/\n/\^\-\;/ unless ($body =~ m/\^\-\;/);
my @content = split(/\^\-\;/,$body);
$synopsis = WebGUI::HTML::filter($content[0],"all");
my @content;
if( $body =~ /<p>/ ) {
@content = WebGUI::HTML::splitTag($body);
} else {
@content = split("\n",$body);
}
shift @content if $content[0] =~ /^\s*$/;
$synopsis = WebGUI::HTML::filter($content[0],"all");
}
$body =~ s/\^\-\;/\n/;
return ($synopsis,$body);
}

View file

@ -196,9 +196,9 @@ sub getTemplateVariables {
my @items = $feed->get_item;
my %var;
$var{channel_title} = WebGUI::HTML::filter($feed->title, 'javascript');
$var{channel_description} = WebGUI::HTML::filter($feed->description, 'javascript');
$var{channel_date} = WebGUI::HTML::filter($feed->get_pubDate_epoch, 'javascript');
$var{channel_copyright} = WebGUI::HTML::filter($feed->copyright, 'javascript');
$var{channel_description} = WebGUI::HTML::filter(scalar($feed->description), 'javascript');
$var{channel_date} = WebGUI::HTML::filter(scalar($feed->get_pubDate_epoch), 'javascript');
$var{channel_copyright} = WebGUI::HTML::filter(scalar($feed->copyright), 'javascript');
$var{channel_link} = WebGUI::HTML::filter($feed->link, 'javascript');
my @image = $feed->image;
$var{channel_image_url} = WebGUI::HTML::filter($image[0], 'javascript');
@ -215,7 +215,7 @@ sub getTemplateVariables {
$item{author} = WebGUI::HTML::filter($object->author, 'javascript');
$item{guid} = WebGUI::HTML::filter($object->guid, 'javascript');
$item{link} = WebGUI::HTML::filter($object->link, 'javascript');
$item{description} = WebGUI::HTML::filter($object->description, 'javascript');
$item{description} = WebGUI::HTML::filter(scalar($object->description), 'javascript');
$item{descriptionFirst100words} = $item{description};
$item{descriptionFirst100words} =~ s/(((\S+)\s+){100}).*/$1/s;
$item{descriptionFirst75words} = $item{descriptionFirst100words};