/[Grep]/lib/Grep/Action/Fetch.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Grep/Action/Fetch.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9 by dpavlin, Sat Feb 17 23:32:33 2007 UTC revision 21 by dpavlin, Sun Feb 18 15:07:03 2007 UTC
# Line 11  package Grep::Action::Fetch; Line 11  package Grep::Action::Fetch;
11  use base qw/Grep::Action Jifty::Action/;  use base qw/Grep::Action Jifty::Action/;
12    
13  use XML::Feed;  use XML::Feed;
14    use LWP::UserAgent;
15    
16  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
17    
# Line 65  sub take_action { Line 66  sub take_action {
66    
67          my $uri = $feed->uri;          my $uri = $feed->uri;
68          if ($uri =~ m/%s/) {          if ($uri =~ m/%s/) {
69                  $uri = sprintf( $uri, $self->argument_value('q') );                  $uri = $feed->search_uri( $self->argument_value('q') );
70                  Jifty->log->info("Searching ", $feed->title, " at $uri");                  Jifty->log->info("Searching ", $feed->title, " at $uri");
71          } else {          } else {
72                  Jifty->log->info("Fetching ", $feed->title, " at $uri");                  Jifty->log->info("Fetching ", $feed->title, " at $uri");
73          }          }
74    
75          my $xml_feed = XML::Feed->parse( URI->new($uri) )          my $ua = LWP::UserAgent->new;
76                  or die XML::Feed->errstr;          $ua->default_header( 'Cookie' => $feed->cookie );
77            my $r = $ua->get( $uri );
78            die "Can't fetch $uri: " . $r->status_line unless ( $r->is_success );
79    
80          warn "fetching ", $xml_feed->title, "\n";          my $content = $r->content;
81    
82            die "No content returned from $uri" unless length( $content ) > 1;
83    
84            my $xml_feed = XML::Feed->parse( \$content )
85                    or die $feed->title, " returned ", XML::Feed->errstr, " for $uri\n";
86    
87            warn "getting entries from ", $xml_feed->title, "\n";
88    
89          my @items;          my @items;
90    
# Line 113  sub take_action { Line 123  sub take_action {
123    
124          } else {          } else {
125    
126                  $self->result->message( 'No results found' );                  $self->result->error( 'No results found' );
   
                 # with default sticky_on_failure, this will keep form data  
                 $self->result->failure( 1 );  
   
127                  return 0;                  return 0;
128    
129          }          }
130  }  }
131    

Legend:
Removed from v.9  
changed lines
  Added in v.21

  ViewVC Help
Powered by ViewVC 1.1.26