Changeset 732

Show
Ignore:
Timestamp:
05/13/06 07:13:25
Author:
miyagawa
Message:
  • Support enclosure creation in XML::Feed and Publish::Feed
  • Added Gosuke Miyashita as author of Publish::Feed thanks to his Publish::PodCast?
  • Added $entry->has_enclosure method
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Entry.pm

    r719 r732  
    8585} 
    8686 
     87sub has_enclosure { 
     88    my $self = shift; 
     89    scalar @{$self->{enclosures}} > 0; 
     90} 
     91 
    87921; 
    8893 
  • trunk/plagger/lib/Plagger/Plugin/Publish/Feed.pm

    r355 r732  
    5858        $entry->issued($e->date) if $e->date; 
    5959        $entry->author($e->author); 
     60 
     61        # RSS 2.0 by spec doesn't allow multiple enclosures 
     62        if ($e->has_enclosure) { 
     63            my @enclosures = $feed_format eq 'RSS' ? ($e->enclosures->[0]) : $e->enclosures; 
     64            for my $enclosure (@enclosures) { 
     65                $entry->add_enclosure({ 
     66                    url    => $enclosure->url, 
     67                    length => $enclosure->length, 
     68                    type   => $enclosure->type, 
     69                }); 
     70            } 
     71        } 
     72 
    6073        $feed->add_entry($entry); 
    6174    } 
     
    100113} 
    101114 
     115# XXX okay, this is a hack until XML::Feed is updated 
     116*XML::Feed::Entry::Atom::add_enclosure = sub { 
     117    my($entry, $enclosure) = @_; 
     118    my $link = XML::Atom::Link->new; 
     119    $link->rel('enclosure'); 
     120    $link->type($enclosure->{type}); 
     121    $link->href($enclosure->{url}); 
     122    $link->length($enclosure->{length}); 
     123    $entry->{entry}->add_link($link); 
     124}; 
     125 
     126*XML::Feed::Entry::RSS::add_enclosure = sub { 
     127    my($entry, $enclosure) = @_; 
     128    $entry->{entry}->{enclosure} = { 
     129        url    => $enclosure->{url}, 
     130        type   => $enclosure->{type}, 
     131        length => $enclosure->{length}, 
     132    }; 
     133}; 
     134 
     135 
    1021361; 
    103137 
     
    157191Yoshiki KURIHARA 
    158192 
     193Tatsuhiko Miyagawa 
     194 
     195Gosuke Miyashita 
     196 
    159197=head1 SEE ALSO 
    160198