Changeset 680

Show
Ignore:
Timestamp:
05/05/06 15:28:11
Author:
miyagawa
Message:
  • Now subscription and update share $feed object, which is experimental.
  • Planet uses $context->subcription to get members rather than from feeds. Fixes #198
Files:

Legend:

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

    r648 r680  
    3333    my $content = $res->content; 
    3434    if ( $Feed::Find::IsFeed{$content_type} || $self->looks_like_feed(\$content) ) { 
    35         $self->handle_feed($url, \$content); 
     35        $self->handle_feed($url, \$content, $args->{feed}); 
    3636    } else { 
    3737        my @feeds = Feed::Find->find_in_html(\$content, $url); 
     
    3939            $url = $feeds[0]; 
    4040            $res = $self->fetch_content($url) or return; 
    41             $self->handle_feed($url, \$res->content); 
     41            $self->handle_feed($url, \$res->content, $args->{feed}); 
    4242        } else { 
    4343            return; 
     
    7676 
    7777sub handle_feed { 
    78     my($self, $url, $xml_ref) = @_; 
     78    my($self, $url, $xml_ref, $feed) = @_; 
    7979 
    8080    my $context = Plagger->context; 
     
    9090    } 
    9191 
    92     my $feed = Plagger::Feed->new; 
     92    $feed ||= Plagger::Feed->new; 
    9393    $feed->title(_u($remote->title)); 
    9494    $feed->url($url); 
  • trunk/plagger/lib/Plagger/Plugin/Aggregator/Xango.pm

    r479 r680  
    4343    my $url = $args->{feed}->url; 
    4444    return unless $url =~ m!^https?://!i; 
     45 
     46    $self->{_url2feed}->{$url} = $args->{feed}; # map from url to feed object 
     47 
    4548    $context->log(info => "Fetch $url"); 
    4649    POE::Kernel->post($self->{xango_alias}, 'enqueue_job', Xango::Job->new(uri => URI->new($url), redirect => 0)); 
     50} 
     51 
     52sub handle_feed { 
     53    my($self, $url, $xml_ref) = @_; 
     54    $self->SUPER::handle_feed($url, $xml_ref, $self->{_url2feed}->{$url}); 
    4755} 
    4856 
  • trunk/plagger/lib/Plagger/Plugin/Publish/Planet.pm

    r445 r680  
    6161        %{ $self->conf->{template} }, 
    6262        feed  => $feed, 
    63         members => $self->_get_members($context, $feed)
     63        members => [ $context->subscription->feeds ]
    6464    }, \my $out) or $context->error($tt->error); 
    6565    $out; 
     
    9494} 
    9595 
    96 sub _get_members { 
    97     my ($self, $context, $feed) = @_; 
    98      
    99     my %members; 
    100     foreach my $entry ($feed->entries) { 
    101         unless ($members{$entry->source->id}) { 
    102             $members{$entry->source->id} = { 
    103                 title => $entry->source->title, 
    104                 link  => $entry->source->link, 
    105             }; 
    106         } 
    107     } 
    108      
    109     return [ sort { $a->{title} cmp $b->{title} } values %members ]; 
    110 } 
    111  
    112961; 
    11397