use base qw/WebPAC::Common/;
use Search::Estraier;
-use Text::Iconv;
+use Encode qw/from_to/;
use Data::Dumper;
use LWP;
use URI::Escape;
=head1 VERSION
-Version 0.09
+Version 0.10
=cut
-our $VERSION = '0.09';
+our $VERSION = '0.10';
=head1 SYNOPSIS
user => 'admin',
passwd => 'admin',
database => 'demo',
+ label => 'node label',
encoding => 'iso-8859-2',
clean => 1,
);
name of database from which data comes
+=item label
+
+label for node (optional)
+
=item encoding
character encoding of C<data_structure> if it's differenet than C<ISO-8859-2>
$log->logdie("need $p") unless ($self->{$p});
}
+ $self->{encoding} ||= 'ISO-8859-2';
+
my $url = $self->{masterurl} . '/node/' . $self->{database};
$self->{url} = $url;
$log->debug("nodes found: $nodes");
if ($nodes !~ m/^$self->{database}\t/sm) {
- $log->warn("creating index $url");
+ my $label = $self->{label} || 'WebPAC ' . $self->{database};
+ $log->warn("creating index $url ($label)");
$self->master(
action => 'nodeadd',
name => $self->{database},
- label => "WebPAC $self->{database}",
+ label => $self->convert( $label ),
) || $log->logdie("can't create Hyper Estraier node $self->{database}");
}
$self->{db}->set_url($self->{url});
$self->{db}->set_auth($self->{user}, $self->{passwd});
- my $encoding = $self->{encoding} || 'ISO-8859-2';
- $log->info("using index $self->{url} with encoding $encoding");
-
- $self->{iconv} = new Text::Iconv($encoding, 'UTF-8') or
- $log->logdie("can't create conversion from $encoding to UTF-8");
+ $log->info("using index $self->{url} with encoding $self->{encoding}");
$self ? return $self : return undef;
}
$log->debug("creating $uri");
my $doc = Search::Estraier::Document->new;
- $doc->add_attr('@uri', $self->{'iconv'}->convert($uri) );
+ $doc->add_attr('@uri', $self->convert($uri) );
$log->debug("ds = ", sub { Dumper($args->{'ds'}) } );
next if (! $vals);
- $vals = $self->{'iconv'}->convert( $vals ) or
+ $vals = $self->convert( $vals ) or
$log->logdie("can't convert '$vals' to UTF-8");
$doc->add_attr( $tag, $vals );
my $text = $args->{'text'};
if ( $text ) {
- $text = $self->{'iconv'}->convert( $text ) or
+ $text = $self->convert( $text ) or
$log->logdie("can't convert '$text' to UTF-8");
$doc->add_text( $text );
}
return $self->{_master_ua};
}
+=head2 convert
+
+ my $utf8_string = $self->convert('string in codepage');
+
+=cut
+
+sub convert {
+ my $self = shift;
+
+ my $text = shift || return;
+ from_to($text, $self->{encoding}, 'UTF-8');
+ return $text;
+}
+
=head1 AUTHOR
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
use WebPAC::Store 0.03;
use WebPAC::Normalize::XML;
use WebPAC::Output::TT;
-use WebPAC::Output::Estraier 0.08;
+use WebPAC::Output::Estraier '0.10';
use YAML qw/LoadFile/;
use Getopt::Long;
use File::Path;
my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");
$est_config->{database} = $database;
$est_config->{clean} = $clean;
+ $est_config->{label} = $db_config->{name};
my $est = new WebPAC::Output::Estraier( %{ $est_config } );