r1407@llin: dpavlin | 2007-10-31 12:26:06 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 31 Oct 2007 11:26:12 +0000 (11:26 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 31 Oct 2007 11:26:12 +0000 (11:26 +0000)
 create Webpacus::Webpac glue to transfer configuration

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@933 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Output/Webpacus.pm

index 5a3d54a..088cf9f 100644 (file)
@@ -14,6 +14,7 @@ use Data::Dump qw/dump/;
 use WebPAC::Common qw/force_array/;
 use Carp qw/confess/;
 use Cwd;
+use File::Slurp;
 
 use Jifty;
 
@@ -133,11 +134,42 @@ sub finish {
        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;
 
 }