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 {
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;
}
$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->base($base) if defined $base;
} else {
my $c = $entry->{entry}->content;
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];
}