Improving My RSS 1.0 Feed

Those of you who subscribe to my RSS 1.0 Feed now have the full content of the first 5 articles on this website instead of just a teaser.

I’ve taken advantage of the content:encoded tag provided by the RSS 1.0 content module, to include the full body as encoded CDATA.

The feeds are generated by a Perl script from my backend database. Thanks to the power of the Template Toolkit I was able to write a simple filter to make all the links referenced in the articles absolute so they are easier to follow when the feed is read out of context of the site. It’s a very basic filter, and won’t win any awards for best practice, but if it helps anyone else, the code is available below.

sub make_links_absolute {
my $text = shift;
$text =~ s[<(.*?)"/(.*?)"(.*?)>][<$1"$baseurl$2"$3>]sg;
return $text;
}

The code is then added into the FILTERS option when I create by Template object, and called in the template by piping to make_links_absolute.

my $template = Template->new({
FILTERS => {
'make_links_absolute' => \&make_links_absolute,
}
});

The other feeds are still headline and teaser only I’m afraid.

Leave a Reply