Subject: | patch with tweaks for rss 2.0 |
added support for self-contained items (i.e. no outside link- all information contained in the description). the spec allows the 'link' and 'title' to be optional if the description is present. i have a few feeds that do not have links and adding fake ones would only confuse the subscribers of the feed.
also added a 'guid' field, which is the equivalent of isPermaLink="false"
--- /Library/Perl/5.8.1/XML/RSS.pm 2003-11-22 22:59:24.000000000 -0800
+++ RSS.pm 2004-03-14 21:02:36.000000000 -0800
@@ -1200,9 +1200,10 @@
foreach my $item (@{$self->{items}}) {
if ($item->{title}) {
$output .= '<item>'."\n";
- $output .= '<title>'.$self->encode($item->{title}).'</title>'."\n";
- $output .= '<link>'.$self->encode($item->{'link'}).'</link>'."\n";
-
+ $output .= '<title>'.$self->encode($item->{title}).'</title>'."\n"
+ if $item->{title};
+ $output .= '<link>'.$self->encode($item->{'link'}).'</link>'."\n"
+ if $item->{link};
$output .= '<description>'.$self->encode($item->{description}).'</description>'."\n"
if $item->{description};
@@ -1219,12 +1220,17 @@
# $output .= '<enclosure>'.$self->encode($item->{enclosure}).'</enclosure>'."\n"
# if $item->{enclosure};
- # The unique identifier -- in this implementation we assume
- # that it's a permalink to the item, so we always include the
- # isPermaLink attribute. Also, I call it permaLink in the
- # hash for purposes of clarity.
- $output .= '<guid isPermaLink="true">'.$self->encode($item->{permaLink}).'</guid>'."\n"
- if $item->{permaLink};
+ # The unique identifier. Use 'permaLink' for an external
+ # identifier, or 'guid' for a internal string.
+ # (I call it permaLink in the hash for purposes of clarity.)
+ if ($item->{permaLink})
+ {
+ $output .= '<guid isPermaLink="true">'.$self->encode($item->{permaLink}).'</guid>'."\n";
+ }
+ elsif ($item->{guid})
+ {
+ $output .= '<guid isPermaLink="false">'.$self->encode($item->{guid}).'</guid>'."\n";
+ }
$output .= '<pubDate>'.$self->encode($item->{pubDate}).'</pubDate>'."\n"
if $item->{pubDate};