Changeset 1635

Show
Ignore:
Timestamp:
09/02/06 01:55:14
Author:
miyagawa
Message:

Publish::Feed: fixed RSS 2.0 invalid webMaster field. Added unit test

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Publish/Feed.pm

    r1600 r1635  
    4343    my $feed_format = $conf->{format} || 'Atom'; 
    4444 
    45     local $XML::Atom::DefaultVersion = "1.0"; 
    46  
    4745    # generate feed 
    4846    my $feed = XML::Feed->new($feed_format); 
     
    5250    $feed->generator("Plagger/$Plagger::VERSION"); 
    5351    $feed->description($f->description || ''); 
    54     $feed->author($f->author) if $f->primary_author; 
     52    $feed->author( $self->make_author($f->author, $feed_format) ) 
     53        if $f->primary_author; 
    5554 
    5655    if ($feed_format eq 'Atom') { 
     
    7877        $entry->modified($e->date) if $e->date; 
    7978 
     79        $entry->author( $self->make_author($e->author, $feed_format) ); 
    8080        if ($feed_format eq 'RSS') { 
    8181            my $author = 'nobody@example.com'; 
     
    143143    $path =~ s!\s+!_!g; 
    144144    $path; 
     145} 
     146 
     147sub make_author { 
     148    my($self, $author, $feed_format) = @_; 
     149 
     150    if ($feed_format eq 'RSS') { 
     151        my $rfc822 = 'nobody@example.com'; 
     152        $rfc822 .= ' (' . $author . ')' if $author; 
     153        return $rfc822; 
     154    } else { 
     155        return defined $author ? $author : 'nobody'; 
     156    } 
    145157} 
    146158 
  • trunk/plagger/t/plugins/Publish-Feed/atom1-valid.t

    r1467 r1635  
    22use t::TestPlagger; 
    33 
    4 test_requires_network; 
    54test_plugin_deps; 
    65 
     
    3635my $out = `$ENV{HOME}/svn/feedvalidator/src/demo.py $main::output A`; 
    3736like $out, qr/No errors or warnings/; 
    38