/[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 74 by dpavlin, Sun Nov 20 20:13:39 2005 UTC revision 75 by dpavlin, Sun Nov 20 20:32:41 2005 UTC
# Line 91  sub new { Line 91  sub new {
91          my $encoding = $self->{'encoding'} || 'ISO-8859-2';          my $encoding = $self->{'encoding'} || 'ISO-8859-2';
92          $log->info("using encoding $encoding");          $log->info("using encoding $encoding");
93    
94          my $iconv = new Text::Iconv('iso-8859-2', 'utf-8');          $self->{'iconv'} = new Text::Iconv($encoding, 'UTF-8') or
95                    $log->die("can't create conversion from $encoding to UTF-8");
96    
97          $self ? return $self : return undef;          $self ? return $self : return undef;
98  }  }
99    
100    
101  =head2 add  =head2 add
102    
103  Adds one entry to database.  Adds one entry to database.
# Line 138  sub add { Line 140  sub add {
140          $log->debug("creating $uri");          $log->debug("creating $uri");
141    
142          my $doc = HyperEstraier::Document->new;          my $doc = HyperEstraier::Document->new;
143          $doc->add_attr('@uri', $uri);          $doc->add_attr('@uri', $self->{'iconv'}->convert($uri) );
144    
145          $log->debug("ds = ", sub { Dumper($args->{'ds'}) } );          $log->debug("ds = ", sub { Dumper($args->{'ds'}) } );
146    
# Line 157  sub add { Line 159  sub add {
159    
160                  $log->logconfess("no values for $tag/$type") unless ($vals);                  $log->logconfess("no values for $tag/$type") unless ($vals);
161    
162                  $doc->add_attr($tag, $vals);                  $vals = $self->{'iconv'}->convert( $vals ) or
163                  $doc->add_hidden_text($vals);                          $log->die("can't convert '$vals' to UTF-8");
164    
165                    $doc->add_attr( $tag, $vals );
166                    $doc->add_hidden_text( $vals );
167          }          }
168    
169          my $text = $args->{'text'};          my $text = $args->{'text'};
170          $doc->add_text( $text ) if ( $text );          if ( $text ) {
171                    $text = $self->{'iconv'}->convert( $text ) or
172                            $log->die("can't convert '$text' to UTF-8");
173                    $doc->add_text( $text );
174            }
175    
176          $log->debug("adding ", sub { $doc->dump_draft } );          $log->debug("adding ", sub { $doc->dump_draft } );
177          $self->{'db'}->put_doc($doc) || $log->die("can't add document $uri to index");          $self->{'db'}->put_doc($doc) || $log->die("can't add document $uri to index");

Legend:
Removed from v.74  
changed lines
  Added in v.75

  ViewVC Help
Powered by ViewVC 1.1.26