use WebPAC::Common qw/force_array/;
use Carp qw/confess/;
use Cwd;
+use File::Slurp;
use Jifty;
my $count = 0;
foreach my $field ( keys %$fields ) {
- $log->debug("adding search field: $field");
- $o->create( name => $field ); # || $log->logdie("can't add $field");
+ my $items = $fields->{$field} || confess "no field?";
+ $log->debug("adding search field: $field [$items]");
+ $o->load_or_create(
+ name => $field,
+ items => $items,
+ ); # || $log->logdie("can't add $field");
$count++;
}
+ $log->info("synced $count search fields with Webpacus");
+
+ my $glue_path = "$path/lib/Webpacus/Webpac.pm";
+
+ $log->info("creating clue class Webpacus::Webpac at $glue_path");
+
+ my $glue = <<"_END_OF_GLUE_";
+package Webpacus::Webpac;
+
+=head1 NAME
+
+Webpacus::Webpac - configuration exported from WebPAC
+
+=cut
+
+use strict;
+use warnings;
+
+sub index_path { '/data/webpac2/var/kinosearch/webpacus' };
+
+1;
+_END_OF_GLUE_
+
+ $log->debug("glue source:\n$glue");
+
+ write_file( $glue_path, $glue ) || $log->logdie("can't create $glue_path: $!");
+
return $count;
}