X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FXML%2FFeed%2FFormat%2FAtom.pm;h=a875899882e4f89c317069bbd2b222aefe9d2672;hb=f9cc521d7da95f769892cb7a17967181a87d3acf;hp=7e8feba40f0c411575eeb059704f3802c4284dbf;hpb=b7c406f5741bfbfff25226734d99c28c6f776661;p=catagits%2FXML-Feed.git diff --git a/lib/XML/Feed/Format/Atom.pm b/lib/XML/Feed/Format/Atom.pm index 7e8feba..a875899 100644 --- a/lib/XML/Feed/Format/Atom.pm +++ b/lib/XML/Feed/Format/Atom.pm @@ -162,34 +162,34 @@ sub link { sub summary { my $entry = shift; if (@_) { - my %param; - if (ref($_[0]) eq 'XML::Feed::Content') { - %param = (Body => $_[0]->body); - } else { - %param = (Body => $_[0]); - } - $entry->{entry}->summary(XML::Atom::Content->new(%param, Version => 1.0)); + my %param; + if (ref($_[0]) eq 'XML::Feed::Content') { + %param = (Body => $_[0]->body); + } else { + %param = (Body => $_[0]); + } + $entry->{entry}->summary(XML::Atom::Content->new(%param, Version => 1.0)); } else { - my $s = $entry->{entry}->summary; + my $s = $entry->{entry}->summary; # map Atom types to MIME types my $type = ($s && ref($s) eq 'XML::Feed::Content') ? $s->type : undef; if ($type) { $type = 'text/html' if $type eq 'xhtml' || $type eq 'html'; $type = 'text/plain' if $type eq 'text'; } - my $body = $s; - if (defined $s && ref($s) eq 'XML::Feed::Content') { - $body = $s->body; - } + my $body = $s; + if (defined $s && ref($s) eq 'XML::Feed::Content') { + $body = $s->body; + } XML::Feed::Content->wrap({ type => $type, body => $body }); } } my %types = ( - 'text/xhtml' => 'xhtml', - 'text/html' => 'html', - 'text/plain' => 'text', + 'text/xhtml' => 'xhtml', + 'text/html' => 'html', + 'text/plain' => 'text', ); sub content { @@ -200,28 +200,26 @@ sub content { my $orig_body; if (ref($_[0]) eq 'XML::Feed::Content') { $orig_body = $_[0]->body; - if (defined $_[0]->type && defined $types{$_[0]->type}) { - %param = (Body => $_[0]->body, Type => $types{$_[0]->type}); + if (defined $_[0]->type && defined $types{$_[0]->type}) { + %param = (Body => $orig_body, Type => $types{$_[0]->type}); if ($param{'Type'} eq "html") { $param{'Body'} = HTML::Entities::encode_entities($param{'Body'}); } - } else { - %param = (Body => $_[0]->body); - } + } else { + } $base = $_[0]->base if defined $_[0]->base; } else { - $orig_body = $_[0]; - %param = (Body => $_[0]); + $orig_body = $_[0]; + } + if (!exists($param{Body})) + { + $param{Body} = $orig_body; } - #if (!exists($param{Body})) - #{ - # $param{Body} = $orig_body; - #} $entry->{entry}->content(XML::Atom::Content->new(%param, Version => 1.0)); # Assigning again so the type will be normalized. This seems to be # an XML-Atom do-what-I-don't-meannery. - #$entry->{entry}->content->body($orig_body); + $entry->{entry}->content->body($orig_body); $entry->{entry}->content->base($base) if defined $base; } else { my $c = $entry->{entry}->content; @@ -321,7 +319,7 @@ sub enclosure { return 1; } else { my @links = grep { defined $_->rel && $_->rel eq 'enclosure' } $entry->{entry}->link; - return undef unless @links; + return unless @links; my @encs = map { XML::Feed::Enclosure->new({ url => $_->href, length => $_->length, type => $_->type }) } @links ; return ($XML::Feed::MULTIPLE_ENCLOSURES)? @encs : $encs[-1]; }