/[webpac2]/trunk/lib/WebPAC/Output/Estraier.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 /trunk/lib/WebPAC/Output/Estraier.pm

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

revision 211 by dpavlin, Mon Dec 5 17:47:10 2005 UTC revision 238 by dpavlin, Wed Dec 14 18:55:38 2005 UTC
# Line 88  sub new { Line 88  sub new {
88          }          }
89    
90          my $url = $self->{masterurl} . '/node/' . $self->{database};          my $url = $self->{masterurl} . '/node/' . $self->{database};
         $url =~ s#//#/#g;  
91          $self->{url} = $url;          $self->{url} = $url;
92    
93          $log->info("opening Hyper Estraier index $self->{url}");          $log->info("opening Hyper Estraier index $self->{url}");
# Line 127  Adds one entry to database. Line 126  Adds one entry to database.
126          id => 42,          id => 42,
127          ds => $ds,          ds => $ds,
128          type => 'display',          type => 'display',
         url_prefix => 'database name',  
129          text => 'optional text from which snippet is created',          text => 'optional text from which snippet is created',
130    );    );
131    
132  This function will create  entries in index using following URI format:  This function will create  entries in index using following URI format:
133    
134    C<file:///database%20name/000>    C<file:///type/database%20name/000>
135    
136  Each tag in C<data_structure> with specified C<type> will create one  Each tag in C<data_structure> with specified C<type> will create one
137  attribute and corresponding hidden text (used for search).  attribute and corresponding hidden text (used for search).
# Line 155  sub add { Line 153  sub add {
153          }          }
154    
155          my $type = $args->{'type'};          my $type = $args->{'type'};
156          my $mfn = $args->{'id'};          my $id = $args->{'id'};
157    
158          my $uri = "file:///$type/$database/$mfn";          my $uri = "file:///$type/$database/$id";
159          $log->debug("creating $uri");          $log->debug("creating $uri");
160    
161          my $doc = HyperEstraier::Document->new;          my $doc = HyperEstraier::Document->new;
# Line 195  sub add { Line 193  sub add {
193          }          }
194    
195          $log->debug("adding ", sub { $doc->dump_draft } );          $log->debug("adding ", sub { $doc->dump_draft } );
196          $self->{'db'}->put_doc($doc) || $log->logdie("can't add document $uri to index");          $self->{'db'}->put_doc($doc) || $log->logdie("can't add document $uri to node " . $self->{url} . " status: " . $self->{db}->status());
197    
198          return 1;          return 1;
199  }  }
# Line 216  my $estmaster_actions = { Line 214  my $estmaster_actions = {
214          nodedel => [ qw/name/ ],          nodedel => [ qw/name/ ],
215  };  };
216    
217    sub est_ua {
218            my $self = shift;
219    
220            return $self->{_master_ua} if ($self->{_master_ua});
221    
222            $self->{_master_ua} = LWP::UserAgent->new( ) || sub {
223                    my $log = $self->_get_logger;
224                    $log->logdie("can't create LWP::UserAgent: $!");
225            };
226    
227            $self->{_master_ua}->credentials('localhost:1978','Super User', $self->{user} => $self->{passwd});
228    
229            return $self->{_master_ua};
230    }
231    
232  sub est_master {  sub est_master {
233          my $self = shift;          my $self = shift;
234          my $args = {@_};          my $args = {@_};
# Line 236  sub est_master { Line 249  sub est_master {
249    
250          $log->debug("calling $url");          $log->debug("calling $url");
251    
252          if (! $self->{_master_ua}) {          my $res = $self->est_ua()->get($url);
                 $self->{_master_ua} = LWP::UserAgent->new( ) || $log->logdie("can't create LWP::UserAgent: $!");  
                 $self->{_master_ua}->credentials('localhost:1978','Super User', $self->{user} => $self->{passwd});  
         }  
   
         my $res = $self->{_master_ua}->get($url);  
253    
254          if ($res->is_success) {          if ($res->is_success) {
255                  #$log->debug( $res->content );                  #$log->debug( $res->content );
# Line 249  sub est_master { Line 257  sub est_master {
257                  return $res->content;                  return $res->content;
258          } else {          } else {
259                  $log->warn("unable to call $url: " . $res->status_line);                  $log->warn("unable to call $url: " . $res->status_line);
                 #$log->debug(Dumper($res, $self->{'_master_ua'}));  
260                  return;                  return;
261          }          }
262    

Legend:
Removed from v.211  
changed lines
  Added in v.238

  ViewVC Help
Powered by ViewVC 1.1.26