6 use File::Temp qw/tempdir/;
11 use WebPAC::Input::ISIS;
12 use WebPAC::Store 0.03;
13 use WebPAC::Normalize::XML;
14 use WebPAC::Output::TT;
15 use WebPAC::Output::Estraier 0.02;
16 use YAML qw/LoadFile/;
19 my $limit = shift @ARGV;
21 my $config = LoadFile('conf/config.yml');
23 print "config = ",Dumper($config);
25 die "no databases in config file!\n" unless ($config->{databases});
27 while (my ($database, $db_config) = each %{ $config->{databases} }) {
29 my $type = lc($db_config->{input}->{type});
31 die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis');
33 my $abs_path = abs_path($0);
34 $abs_path =~ s#/[^/]*$#/#;
36 my $lookup = new WebPAC::Lookup(
37 lookup_file => $db_config->{input}->{lookup},
40 my $db_path = $config->{webpac}->{db_path} . '/' . $database;
43 my $log = $lookup->_get_logger;
44 $log->info("working on $database in $db_path");
46 my $isis = new WebPAC::Input::ISIS(
47 code_page => $config->{webpac}->{webpac_encoding},
48 limit_mfn => $db_config->{input}->{limit},
51 my $maxmfn = $isis->open(
52 filename => $db_config->{input}->{path},
53 code_page => $db_config->{input}->{encoding}, # database encoding
58 my $db = new WebPAC::Store(
62 my $n = new WebPAC::Normalize::XML(
63 # filter => { 'foo' => sub { shift } },
65 lookup_regex => $lookup->regex,
70 tag => $db_config->{normalize}->{tag},
71 xml_file => $db_config->{normalize}->{path},
74 my $out = new WebPAC::Output::TT(
75 include_path => $config->{webpac}->{template_path},
76 filters => { foo => sub { shift } },
79 my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");
80 $est_config->{database} = $database;
82 $log->info("using HyperEstraier URL $est_config->{url}");
84 my $est = new WebPAC::Output::Estraier(
90 for ( 0 ... $isis->size ) {
92 my $row = $isis->fetch || next;
94 my $mfn = $row->{'000'}->[0] || die "can't find MFN";
96 my $ds = $n->data_structure($row);
98 # print STDERR Dumper($row, $ds);
100 # my $html = $out->apply(
101 # template => 'html_ffzg.tt',
105 # # create test output
107 # my $file = sprintf('out/%02d.html', $mfn );
108 # open(my $fh, '>', $file) or die "can't open $file: $!";
112 # $html =~ s#\s*[\n\r]+\s*##gs;
114 # print STDERR $html;
119 type => $config->{hyperestraier}->{type},
126 $log->info("$total_rows records indexed");