/[A3C]/bin/import-strix.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /bin/import-strix.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 139 - (show annotations)
Fri May 30 21:16:08 2008 UTC (11 years, 1 month ago) by dpavlin
File MIME type: text/plain
File size: 888 byte(s)
Added Strix site config importer

When invoked like:

./bin/import-strix.pl

it reports something like:

INFO - 539 Strix sites imported

Not bad :-)
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use lib 'lib';
7
8 use Jifty;
9 use Data::Dump qw/dump/;
10 use File::Find;
11 use A3C::PHP;
12
13 BEGIN { Jifty->new; };
14 Jifty->web->request(Jifty::Request->new);
15 Jifty->web->response(Jifty::Response->new);
16
17 my $config = Jifty->config->app('strix') or die "need strix config";
18
19 my $model = A3C::Model::StrixSite->new;
20
21 my $total = 0;
22
23 find({ no_chdir => 1, wanted => sub {
24 my $path = $File::Find::name;
25 return unless -f $_;
26 warn "? $path\n";
27 return unless m/conf\.php$/;
28
29 $path =~ m{/etc/([^/]+)/conf\.php$} or die "can't find site name in $path";
30 my $site = $1;
31
32 my $data = A3C::PHP->parse_file( $path );
33
34 warn "# PHP = ", dump( $data );
35 $data->{site} = $site;
36
37 my ($id,$msg) = $model->load_or_create( %$data );
38 warn "$id $site ", $msg || 'ADDED', "\n";
39 $total++ if $id;
40
41 }}, $config->{dir} );
42
43 Jifty->log->info( "$total Strix sites imported" );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26