Changeset 343

Show
Ignore:
Timestamp:
03/06/06 16:18:12
Author:
miyagawa
Message:

Added EXPERIMENTAL aggregate.feed.filter hook. Fixes #102.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Aggregator/Simple.pm

    r276 r343  
    3737    $context->log(debug => $response->status . ": $url"); 
    3838 
    39     $self->handle_feed($url, \$response->content); 
     39    my $args = { content => $response->content }; 
     40    Plagger->context->run_hook('aggregator.filter.feed', $args); 
     41 
     42    $self->handle_feed($url, \$args->{content}); 
    4043} 
    4144 
  • trunk/plagger/lib/Plagger/Plugin/Filter/RSSTimeZoneString.pm

    r256 r343  
    2020); 
    2121 
    22 my $tz_RE = join '|', keys %tz; 
     22my $tz_RE   = join '|', keys %tz; 
    2323 
    2424sub register { 
     
    2626    $context->register_hook( 
    2727        $self, 
    28         'update.entry.fixup' => \&update
     28        'aggregator.filter.feed' => \&filter
    2929    ); 
    3030} 
    3131 
    32 sub update
     32sub filter
    3333    my($self, $context, $args) = @_; 
    34     my $entry = $args->{entry}->{feed_entry}; 
    3534 
    36     ## only work with RSS 0.91/2.0 and XML::Feed (Aggregator::Simple) 
    37     return unless $entry && $entry->{entry} && $entry->{entry}->{pubDate}; 
    38  
    39     my $ts = $entry->{entry}->{pubDate}; 
    40     if ($ts =~ s/($tz_RE)$/$tz{$1}/) { 
    41         $context->log(info => "Fixing bad timezone $1 to $tz{$1}"); 
    42  
    43         require DateTime::Format::Mail; 
    44         my $parser = DateTime::Format::Mail->new; 
    45            $parser->loose; 
    46         my $date = $parser->parse_datetime($ts); 
    47         $args->{entry}->date( Plagger::Date->rebless($date) ); 
     35    while ($args->{content} =~ s!($tz_RE)</(pubDate|lastBuildDate)>!$tz{$1}</$2>!) { 
     36        $context->log(info => "Fixed bad timezone $1 to $tz{$1}"); 
    4837    } 
    4938} 
     
    5948=head1 SYNOPSIS 
    6049 
    61     - module: Filter::RSSTimeZoneString 
     50  - module: Filter::RSSTimeZoneString 
    6251 
    6352=head1 DESCRIPTION