1 # $Id: Atom.pm 942 2004-12-31 23:01:21Z btrott $
3 package XML::Feed::Atom;
6 use base qw( XML::Feed );
8 use XML::Atom::Util qw( iso2dt );
9 use List::Util qw( first );
15 $feed->{atom} = XML::Atom::Feed->new(Stream => $str)
16 or return $feed->error(XML::Atom::Feed->errstr);
23 sub title { $_[0]->{atom}->title }
25 my $l = first { $_->rel eq 'alternate' } $_[0]->{atom}->link;
26 $l ? $l->href : undef;
28 sub description { $_[0]->{atom}->tagline }
29 sub copyright { $_[0]->{atom}->copyright }
30 sub language { $_[0]->{atom}->language }
31 sub generator { $_[0]->{atom}->generator }
32 sub author { $_[0]->{atom}->author ? $_[0]->{atom}->author->name : undef }
33 sub modified { iso2dt($_[0]->{atom}->modified) }
37 for my $entry ($_[0]->{atom}->entries) {
38 push @entries, XML::Feed::Atom::Entry->wrap($entry);
43 package XML::Feed::Atom::Entry;
46 use base qw( XML::Feed::Entry );
47 use XML::Atom::Util qw( iso2dt );
48 use XML::Feed::Content;
49 use List::Util qw( first );
51 sub title { $_[0]->{entry}->title }
53 my $l = first { $_->rel eq 'alternate' } $_[0]->{entry}->link;
54 $l ? $l->href : undef;
58 XML::Feed::Content->wrap({ type => 'text/html',
59 body => $_[0]->{entry}->summary });
63 my $c = $_[0]->{entry}->content;
64 XML::Feed::Content->wrap({ type => $c ? $c->type : undef,
65 body => $c ? $c->body : undef });
69 my $ns = XML::Atom::Namespace->new(dc => 'http://purl.org/dc/elements/1.1/');
70 $_[0]->{entry}->get($ns, 'subject');
73 sub author { $_[0]->{entry}->author ? $_[0]->{entry}->author->name : undef }
74 sub id { $_[0]->{entry}->id }
75 sub issued { iso2dt($_[0]->{entry}->issued) }
76 sub modified { iso2dt($_[0]->{entry}->modified) }