--- lib/Grep/Import/ScrapBook.pm 2007/06/11 10:17:57 161 +++ lib/Grep/Import/ScrapBook.pm 2007/06/11 10:18:09 162 @@ -28,10 +28,21 @@ sub import { my $self = shift; + my $config = Jifty->config->app('Import')->{'ScrapBook'}; + + if (! $config ) { + Jifty->log->warn("skipping ScrapBook importer, no application->Import->ScrapBook config"); + return; + } + + # required parametars in config.yml + foreach my $param ( qw/Dir OwnerEmail/ ) { + Jifty->log->die("can't find $param in Scrapbook config") unless defined ( $config->{$param} ); + }; + my $dir = Jifty::Util->app_root . '/' . - Jifty->config->framework('Web')->{'StaticRoot'} . '/' . - Jifty->config->app('ScrapBookDir'); + Jifty->config->framework('Web')->{'StaticRoot'} . '/' . $config->{'Dir'}; my $path = $dir . '/scrapbook.rdf'; $path =~ s!//+!/!g; @@ -49,8 +60,8 @@ # warn "## original rdf -> ", dump( $rdf ); my $owner = Grep::Model::User->new(); - $owner->load_by_cols( email => Jifty->config->app('ScrapBookOwner') ); - die "can't find ScrapBookOwner ", Jifty->config->app('ScrapBookOwner') unless ( $owner->id ); + $owner->load_by_cols( email => $config->{OwnerEmail} ); + die "can't find ScrapBookOwner ", $config->{OwnerEmail} unless ( $owner->id ); Jifty->log->info( "Using user ", $owner->id, " from ", $owner->email, " for import" ); @@ -102,7 +113,7 @@ my $body = $tree->look_down( '_tag', 'body' ); - my $resolver = HTML::ResolveLink->new( base => '/static/' . Jifty->config->app('ScrapBookDir') . $rel_path ); + my $resolver = HTML::ResolveLink->new( base => '/static/' . $config->{Dir} . $rel_path ); $content = $resolver->resolve( $body->as_HTML ); # create date from id