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/;
22 WebPAC::Output::Webpacus - integrate WebPAC front-end with Jifty back-end
30 our $VERSION = '0.01';
34 Does black magic to sync data between WebPAC and Webpacus, web front-end
41 my $output = new WebPAC::Output::Webpacus({
42 path => '/path/to/Webpacus',
55 my $log = $self->_get_logger;
57 foreach my $p (qw/path database/) {
58 $log->logdie("need $p") unless ($self->$p);
61 my $path = $self->path;
63 $log->logdie("Webpacus path $path not found: $!") unless -d $path;
65 my $config_path = "$path/etc/config.yml";
67 $log->logdie("expected Webpacus config at $config_path: $!") unless -e $config_path;
87 my $log = $self->_get_logger;
88 $log->logdie("need id") unless defined $id;
89 $log->logdie("need ds") unless $ds;
91 $log->debug("id: $id ds = ",sub { dump($ds) });
93 my $hash = $self->ds_to_hash( $ds, 'sorted' ) || return;
95 foreach my $f ( keys %$hash ) {
96 $self->{fields}->{$f}++;
113 my $log = $self->_get_logger();
115 $log->info("syncing search fields");
117 my $fields = $self->{fields} || confess "no fields?";
118 my $path = $self->path || confess "no path?";
120 $log->debug("fields = ", sub { dump $fields });
122 $log->info("using Webpacus installation: $path");
124 my $webpac_dir = getcwd();
126 chdir $path || $log->logdie("can't chdir($path) $!");
130 my $system_user = Webpacus::CurrentUser->superuser;
131 my $o = Webpacus::Model::Search->new(current_user => $system_user);
135 foreach my $field ( keys %$fields ) {
136 $log->debug("adding search field: $field");
137 $o->create( name => $field ); # || $log->logdie("can't add $field");
148 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
150 =head1 COPYRIGHT & LICENSE
152 Copyright 2007 Dobrica Pavlinusic, All Rights Reserved.
154 This program is free software; you can redistribute it and/or modify it
155 under the same terms as Perl itself.