-# $Id: Changes,v 1.4 2004/07/29 16:42:29 btrott Exp $
+# $Id: Changes,v 1.7 2004/10/09 07:02:01 btrott Exp $
Revision history for XML::Feed
-0.02
+0.03 2004.10.09
+ - Fixed bug with feed format detection: properly detect format even in
+ feeds with <!DOCTYPE> at the top. (Thanks to Alberto Quario for the
+ note.)
+ - Use Class::ErrorHandler instead of XML::Feed::ErrorHandler.
+ - Moved auto-discovery code into Feed::Find. XML::Feed->find_feeds is
+ now just a wrapper around that module.
+
+0.02 2004.07.29
- Changed behavior of Entry->summary to prevent it from returning the
full contents of the entry. Now, in an RSS feed, summary only returns
a value if there is both a <description> element *and* one of the
lib/XML/Feed/Atom.pm
lib/XML/Feed/Content.pm
lib/XML/Feed/Entry.pm
-lib/XML/Feed/ErrorHandler.pm
lib/XML/Feed/RSS.pm
Makefile.PL
MANIFEST This list of files
name: XML-Feed
-version: 0.02
+version: 0.03
abstract: XML Syndication Feed Support
author: Benjamin Trott <cpan@stupidfool.org>
license: perl
distribution_type: module
requires:
+ Class::ErrorHandler: 0
+ Feed::Find: 0
XML::RSS: 1.01
XML::Atom: 0.08
LWP: 0
directory:
- t
- inc
-generated_by: Module::Install version 0.33
+generated_by: Module::Install version 0.35
-# $Id: Makefile.PL,v 1.1.1.1 2004/05/29 17:29:56 btrott Exp $
+# $Id: Makefile.PL,v 1.2 2004/10/04 03:38:11 btrott Exp $
use inc::Module::Install;
include('ExtUtils::AutoInstall');
+requires('Class::ErrorHandler');
+requires('Feed::Find');
requires('XML::RSS' => 1.01);
requires('XML::Atom' => 0.08);
requires('LWP');
-$Id: README,v 1.1.1.1 2004/05/29 17:29:56 btrott Exp $
+$Id: README,v 1.2 2004/10/09 07:06:11 btrott Exp $
This is XML::Feed, an abstraction above the RSS and Atom syndication
feed formats. It supports both parsing and autodiscovery of feeds.
PREREQUISITES
+ * Class::ErrorHandler
* XML::RSS
* XML::Atom
* LWP
* DateTime::Format::Mail
* DateTime::Format::W3CDTF
* List::Util
+ * Feed::Find
INSTALLATION
#line 1 "inc/Module/Install.pm - /Library/Perl/5.8.1/Module/Install.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install.pm $ $Author: autrijus $
-# $Revision: #67 $ $Change: 1885 $ $DateTime: 2004/03/11 05:55:27 $ vim: expandtab shiftwidth=4
+# $Revision: #69 $ $Change: 2301 $ $DateTime: 2004/07/13 07:16:40 $ vim: expandtab shiftwidth=4
package Module::Install;
-$VERSION = '0.33';
+$VERSION = '0.35';
die << "." unless $INC{join('/', inc => split(/::/, __PACKAGE__)).'.pm'};
Please invoke ${\__PACKAGE__} with:
use File::Path ();
@inc::Module::Install::ISA = 'Module::Install';
+*inc::Module::Install::VERSION = *VERSION;
-#line 129
+#line 132
sub import {
my $class = shift;
delete $INC{"$self->{path}.pm"};
}
-#line 156
+#line 159
sub autoload {
my $self = shift;
};
}
-#line 181
+#line 184
sub new {
my ($class, %args) = @_;
bless(\%args, $class);
}
-#line 210
+#line 213
sub call {
my $self = shift;
goto &{$obj->can($method)};
}
-#line 225
+#line 228
sub load {
my ($self, $method) = @_;
$obj;
}
-#line 255
+#line 258
sub load_extensions {
my ($self, $path, $top_obj) = @_;
}
}
-#line 279
+#line 282
sub find_extensions {
my ($self, $path) = @_;
__END__
-#line 614
+#line 620
#line 1 "inc/Module/Install/Include.pm - /Library/Perl/5.8.1/Module/Install/Include.pm"
# $File: //depot/cpan/Module-Install/lib/Module/Install/Include.pm $ $Author: autrijus $
-# $Revision: #8 $ $Change: 1811 $ $DateTime: 2003/12/14 18:52:33 $ vim: expandtab shiftwidth=4
+# $Revision: #9 $ $Change: 2288 $ $DateTime: 2004/07/01 04:49:12 $ vim: expandtab shiftwidth=4
package Module::Install::Include;
use Module::Install::Base; @ISA = qw(Module::Install::Base);
sub include { +shift->admin->include(@_) };
sub include_deps { +shift->admin->include_deps(@_) };
sub auto_include { +shift->admin->auto_include(@_) };
+sub auto_include_deps { +shift->admin->auto_include_deps(@_) };
1;
-# $Id: Feed.pm,v 1.8 2004/07/29 16:44:18 btrott Exp $
+# $Id: Feed.pm,v 1.10 2004/10/09 07:05:08 btrott Exp $
package XML::Feed;
use strict;
-use base qw( XML::Feed::ErrorHandler );
+use base qw( Class::ErrorHandler );
use LWP::UserAgent;
use HTML::Parser;
+use Feed::Find;
use vars qw( $VERSION );
-$VERSION = '0.02';
-
-use constant FEED_MIME_TYPES => [
- 'application/x.atom+xml',
- 'application/atom+xml',
- 'text/xml',
- 'application/rss+xml',
- 'application/rdf+xml',
-];
+$VERSION = '0.03';
sub parse {
my $class = shift;
## feed ourselves.
my $tag;
while ($xml =~ /<(\S+)/sg) {
- (my $t = $1) =~ tr/a-zA-Z0-9:\-\?//cd;
- $tag = $t, last unless substr($t, 0, 1) eq '?';
+ (my $t = $1) =~ tr/a-zA-Z0-9:\-\?!//cd;
+ my $first = substr $t, 0, 1;
+ $tag = $t, last unless $first eq '?' || $first eq '!';
}
return $class->error("Cannot find first element") unless $tag;
$tag =~ s/^.*://;
sub find_feeds {
my $class = shift;
my($uri) = @_;
- my $ua = LWP::UserAgent->new;
- my $req = HTTP::Request->new(GET => $uri);
- my $res = $ua->request($req);
- return unless $res->is_success;
- my @feeds;
- my %is_feed = map { $_ => 1 } @{ FEED_MIME_TYPES() };
- my $ct = $res->content_type;
- if ($is_feed{$ct}) {
- @feeds = ($uri);
- } elsif ($ct eq 'text/html' || $ct eq 'application/xhtml+xml') {
- my $base_uri = $uri;
- my $find_links = sub {
- my($tag, $attr) = @_;
- if ($tag eq 'link') {
- return unless $attr->{rel};
- my %rel = map { $_ => 1 } split /\s+/, lc($attr->{rel});
- (my $type = lc $attr->{type}) =~ s/^\s*//;
- $type =~ s/\s*$//;
- push @feeds, URI->new_abs($attr->{href}, $base_uri)->as_string
- if $is_feed{$type} &&
- ($rel{alternate} || $rel{'service.feed'});
- } elsif ($tag eq 'base') {
- $base_uri = $attr->{href};
- }
- };
- my $p = HTML::Parser->new(api_version => 3,
- start_h => [ $find_links, "tagname, attr" ]);
- $p->parse($res->content);
- }
+ my @feeds = Feed::Find->find($uri)
+ or return $class->error(Feed::Find->errstr);
@feeds;
}
-# $Id: Content.pm,v 1.1 2004/06/20 15:20:38 btrott Exp $
+# $Id: Content.pm,v 1.2 2004/10/04 03:38:11 btrott Exp $
package XML::Feed::Content;
use strict;
-use base qw( XML::Feed::ErrorHandler );
+use base qw( Class::ErrorHandler );
sub wrap {
my $class = shift;
+++ /dev/null
-# $Id: ErrorHandler.pm,v 1.2 2004/05/29 18:19:50 btrott Exp $
-
-package XML::Feed::ErrorHandler;
-use strict;
-
-use vars qw( $ERROR );
-
-sub error {
- my $msg = $_[1] || '';
- $msg .= "\n" unless $msg =~ /\n$/;
- if (ref($_[0])) {
- $_[0]->{_errstr} = $msg;
- } else {
- $ERROR = $msg;
- }
- return;
- }
-sub errstr { ref($_[0]) ? $_[0]->{_errstr} : $ERROR }
-
-1;