Changeset 1686

Show
Ignore:
Timestamp:
09/15/06 03:15:56
Author:
miyagawa
Message:
Files:

Legend:

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

    r1577 r1686  
    5151 
    5252    my $agent = Plagger::UserAgent->new; 
    53        $agent->parse_head(0); 
    5453    my $response = $agent->fetch($url, $self); 
    5554 
  • trunk/plagger/lib/Plagger/Plugin/CustomFeed/Simple.pm

    r1683 r1686  
    2121    my($self, $context, $args) = @_; 
    2222 
    23     if ( my $match = $args->{feed}->meta->{follow_link} || $args->{feed}->meta->{follow_xpath} ) { 
    24         $args->{match} = $match; 
     23    $args->{match} = $args->{feed}->meta->{follow_link}; 
     24    $args->{xpath} = $args->{feed}->meta->{follow_xpath}; 
     25    if ($args->{match} || $args->{xpath}) { 
    2526        return $self->aggregate($context, $args); 
    2627    } 
     
    5051    $feed->link($url); 
    5152 
    52     my $re = $args->{match}; 
    53  
    54     if( $args->{feed}->meta->{follow_link} ) { 
     53    if( my $re = $args->{match} ) { 
    5554        my $resolver = HTML::ResolveLink->new(base => $url); 
    5655        $content = $resolver->resolve($content); 
     
    7473            $context->log(debug => "Add $token->[1]->{href} ($text)"); 
    7574        } 
    76     } 
    77     else { 
     75    } elsif (my $xpath = $args->{xpath}) { 
    7876        my $tree = HTML::TreeBuilder::XPath->new; 
    7977        $tree->parse($content); 
    8078        $tree->eof; 
    8179 
    82         for my $child ( $tree->findnodes($re || '//a') ) { 
     80        for my $child ( $tree->findnodes($xpath || '//a') ) { 
    8381            my $href  = $child->attr('href') or next; 
    8482            my $title = $child->attr('title') || $child->as_text; 
  • trunk/plagger/lib/Plagger/Plugin/Filter/EntryFullText.pm

    r1674 r1686  
    3030 
    3131    $self->{ua} = Plagger::UserAgent->new; 
    32     $self->{ua}->parse_head(0); 
    3332} 
    3433 
     
    8887    if ($handler) { 
    8988        $args->{match} = $handler->custom_feed_follow_link; 
     89        $args->{xpath} = $handler->custom_feed_follow_xpath; 
    9090        return $self->Plagger::Plugin::CustomFeed::Simple::aggregate($context, $args); 
    9191    } 
     
    169169sub custom_feed_handle { 0 } 
    170170sub custom_feed_follow_link { } 
     171sub custom_feed_follow_xpath { } 
    171172sub handle_force { 0 } 
    172173sub handle { 0 } 
     
    211212sub custom_feed_follow_link { 
    212213    $_[0]->{custom_feed_follow_link}; 
     214} 
     215 
     216sub custom_feed_follow_xpath { 
     217    $_[0]->{custom_feed_follow_xpath}; 
    213218} 
    214219 
  • trunk/plagger/lib/Plagger/UserAgent.pm

    r1640 r1686  
    1212    my $class = shift; 
    1313    my $self  = $class->SUPER::new(@_); 
     14       $self->parse_head(0); 
    1415 
    1516    my $conf = Plagger->context ? Plagger->context->conf->{user_agent} : {}; 
     
    114115    $url = URI->new($url) unless ref $url; 
    115116 
    116     $self->parse_head(0); 
    117117    my $response = $self->fetch($url); 
    118118    if ($response->is_error) { 
     
    134134    $url = URI->new($url) unless ref $url; 
    135135 
    136     $self->parse_head(0); 
    137  
    138136    my $response = $self->fetch($url); 
    139137    if ($response->is_error) { 
  • trunk/plagger/t/plugins/CustomFeed-Simple/xpath.t

    r1683 r1686  
    1919          meta: 
    2020            follow_xpath: //ul[@class="xoxo" or @class="subscriptionlist"]//a 
    21          
     21 
    2222  - module: CustomFeed::Simple 
    2323