1 package WebPAC::Output::Webpacus;
6 use base qw/WebPAC::Common WebPAC::Output Class::Accessor/;
7 __PACKAGE__->mk_accessors(qw(
13 use Data::Dump qw/dump/;
14 use WebPAC::Common qw/force_array/;
23 WebPAC::Output::Webpacus - integrate WebPAC front-end with Jifty back-end
31 our $VERSION = '0.01';
35 Does black magic to sync data between WebPAC and Webpacus, web front-end
42 my $output = new WebPAC::Output::Webpacus({
43 path => '/path/to/Webpacus',
56 my $log = $self->_get_logger;
58 foreach my $p (qw/path database/) {
59 $log->logdie("need $p") unless ($self->$p);
62 my $path = $self->path;
64 $log->logdie("Webpacus path $path not found: $!") unless -d $path;
66 my $config_path = "$path/etc/config.yml";
68 $log->logdie("expected Webpacus config at $config_path: $!") unless -e $config_path;
88 my $log = $self->_get_logger;
89 $log->logdie("need id") unless defined $id;
90 $log->logdie("need ds") unless $ds;
92 $log->debug("id: $id ds = ",sub { dump($ds) });
94 my $hash = $self->ds_to_hash( $ds, 'sorted' ) || return;
96 foreach my $f ( keys %$hash ) {
97 $self->{fields}->{$f}++;
114 my $log = $self->_get_logger();
116 $log->info("syncing search fields");
118 my $fields = $self->{fields} || confess "no fields?";
119 my $path = $self->path || confess "no path?";
121 $log->debug("fields = ", sub { dump $fields });
123 $log->info("using Webpacus installation: $path");
125 my $webpac_dir = getcwd();
127 chdir $path || $log->logdie("can't chdir($path) $!");
131 my $system_user = Webpacus::CurrentUser->superuser;
132 my $o = Webpacus::Model::Search->new(current_user => $system_user);
136 foreach my $field ( keys %$fields ) {
137 my $items = $fields->{$field} || confess "no field?";
138 $log->debug("adding search field: $field [$items]");
142 ); # || $log->logdie("can't add $field");
146 $log->info("synced $count search fields with Webpacus");
148 my $glue_path = "$path/lib/Webpacus/Webpac.pm";
150 $log->info("creating clue class Webpacus::Webpac at $glue_path");
152 my $glue = <<"_END_OF_GLUE_";
153 package Webpacus::Webpac;
157 Webpacus::Webpac - configuration exported from WebPAC
164 sub index_path { '/data/webpac2/var/kinosearch/webpacus' };
169 $log->debug("glue source:\n$glue");
171 write_file( $glue_path, $glue ) || $log->logdie("can't create $glue_path: $!");
180 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
182 =head1 COPYRIGHT & LICENSE
184 Copyright 2007 Dobrica Pavlinusic, All Rights Reserved.
186 This program is free software; you can redistribute it and/or modify it
187 under the same terms as Perl itself.