Subject: | [PATCH] Add support for GeoRSS |
Support for GeoRSS fields would be very nice. I wrote this patch and it
seems to work OK.
Subject: | XML-Feed.patch |
diff -ur XML-Feed-0.12/lib/XML/Feed/Atom.pm /usr/lib/perl5/site_perl/5.8.8/XML/Feed/Atom.pm
--- XML-Feed-0.12/lib/XML/Feed/Atom.pm 2006-08-14 05:31:28.000000000 +0000
+++ /usr/lib/perl5/site_perl/5.8.8/XML/Feed/Atom.pm 2008-10-13 04:56:14.000000000 +0000
@@ -185,4 +185,22 @@
}
}
+sub lat {
+ my $entry = shift;
+ if (@_) {
+ $entry->{entry}->lat($_[0]) if $_[0];
+ } else {
+ $entry->{entry}->lat;
+ }
+}
+
+sub long {
+ my $entry = shift;
+ if (@_) {
+ $entry->{entry}->long($_[0]) if $_[0];
+ } else {
+ $entry->{entry}->long;
+ }
+}
+
1;
diff -ur XML-Feed-0.12/lib/XML/Feed/Entry.pm /usr/lib/perl5/site_perl/5.8.8/XML/Feed/Entry.pm
--- XML-Feed-0.12/lib/XML/Feed/Entry.pm 2005-08-12 04:28:43.000000000 +0000
+++ /usr/lib/perl5/site_perl/5.8.8/XML/Feed/Entry.pm 2008-10-14 18:48:32.000000000 +0000
@@ -32,7 +32,7 @@
my $entry = shift;
my($format) = @_;
my $new = __PACKAGE__->new($format);
- for my $field (qw( title link content summary category author id issued modified )) {
+ for my $field (qw( title link content summary category author id issued modified lat long )) {
my $val = $entry->$field();
next unless defined $val;
$new->$field($val);
@@ -49,6 +49,8 @@
sub id;
sub issued;
sub modified;
+sub lat;
+sub long;
1;
__END__
diff -ur XML-Feed-0.12/lib/XML/Feed/RSS.pm /usr/lib/perl5/site_perl/5.8.8/XML/Feed/RSS.pm
--- XML-Feed-0.12/lib/XML/Feed/RSS.pm 2006-04-22 05:13:55.000000000 +0000
+++ /usr/lib/perl5/site_perl/5.8.8/XML/Feed/RSS.pm 2008-10-13 05:43:51.000000000 +0000
@@ -15,6 +15,7 @@
$feed->{rss} = $PREFERRED_PARSER->new( version => '2.0' );
$feed->{rss}->add_module(prefix => "content", uri => 'http://purl.org/rss/1.0/modules/content/');
$feed->{rss}->add_module(prefix => "dcterms", uri => 'http://purl.org/rss/1.0/modules/dcterms/');
+ $feed->{rss}->add_module(prefix => "geo", uri => 'http://www.w3.org/2003/01/geo/wgs84_pos#');
$feed;
}
@@ -242,4 +243,23 @@
}
}
+sub lat {
+ my $item = shift->{entry};
+ if (@_) {
+ $item->{geo}{lat} = $_[0];
+ } else {
+ return $item->{geo}{lat};
+ }
+}
+
+sub long {
+ my $item = shift->{entry};
+ if (@_) {
+ $item->{geo}{long} = $_[0];
+ } else {
+ return $item->{geo}{long};
+ }
+}
+
+
1;