Changeset 1580
- Timestamp:
- 08/24/06 02:29:30
- Files:
-
- branches/hackathon-summary/plagger/lib/Plagger/Plugin/Aggregator/Simple.pm (modified) (3 diffs)
- branches/hackathon-summary/plagger/lib/Plagger/Thing.pm (modified) (2 diffs)
- branches/hackathon-summary/plagger/t/core/atom-type.t (added)
- branches/hackathon-summary/plagger/t/samples/atom-type.xml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/hackathon-summary/plagger/lib/Plagger/Plugin/Aggregator/Simple.pm
r1539 r1580 7 7 use Plagger::FeedParser; 8 8 use Plagger::UserAgent; 9 use Plagger::Text; 9 10 use List::Util qw(first); 10 11 use UNIVERSAL::require; … … 136 137 $entry->feed_link($feed->link); 137 138 $entry->id($e->id); 138 $entry->body($e->content->body || $e->summary->body); 139 if ($e->summary->body) { 140 $entry->summary($e->summary->body); 141 } 139 140 my $content = feed_to_text($e, $e->content); 141 my $summary = feed_to_text($e, $e->summary); 142 $entry->body($content || $summary); 143 $entry->summary($summary) if $summary; 142 144 143 145 # enclosure support, to be added to XML::Feed … … 226 228 } 227 229 230 sub feed_to_text { 231 my($e, $content) = @_; 232 return unless $content->body; 233 234 if (ref($e) eq 'XML::Feed::Entry::Atom') { 235 # in Atom, be a little strict with TextConstruct 236 # TODO: this actually doesn't work since XML::Feed and XML::Atom does the right 237 # thing with Atom 1.0 TextConstruct 238 if ($content->type eq 'text/plain' || $content->type eq 'text') { 239 return Plagger::Text->new(type => 'text', data => $content->body); 240 } else { 241 return Plagger::Text->new(type => 'html', data => $content->body); 242 } 243 } elsif (ref($e) eq 'XML::Feed::Entry::RSS') { 244 # in RSS there's no explicit way to declare the type. Just guess it 245 return Plagger::Text->new_from_text($content->body); 246 } else { 247 die "Something is wrong: $e"; 248 } 249 } 250 228 251 sub _u { 229 252 my $str = shift; branches/hackathon-summary/plagger/lib/Plagger/Thing.pm
r1527 r1580 4 4 5 5 use Plagger::Text; 6 use Scalar::Util qw(blessed); 6 7 7 8 sub has_tag { … … 53 54 if (@_) { 54 55 my $text = $_[0]; 55 unless ( ref($text)) {56 unless ( blessed($text) && $text->isa('Plagger::Text') ) { 56 57 $text = Plagger::Text->new_from_text($text); 57 58 }
