28 |
sub import { |
sub import { |
29 |
my $self = shift; |
my $self = shift; |
30 |
|
|
31 |
|
my $config = Jifty->config->app('Import')->{'ScrapBook'}; |
32 |
|
|
33 |
|
if (! $config ) { |
34 |
|
Jifty->log->warn("skipping ScrapBook importer, no application->Import->ScrapBook config"); |
35 |
|
return; |
36 |
|
} |
37 |
|
|
38 |
|
# required parametars in config.yml |
39 |
|
foreach my $param ( qw/Dir OwnerEmail/ ) { |
40 |
|
Jifty->log->die("can't find $param in Scrapbook config") unless defined ( $config->{$param} ); |
41 |
|
}; |
42 |
|
|
43 |
my $dir = |
my $dir = |
44 |
Jifty::Util->app_root . '/' . |
Jifty::Util->app_root . '/' . |
45 |
Jifty->config->framework('Web')->{'StaticRoot'} . '/' . |
Jifty->config->framework('Web')->{'StaticRoot'} . '/' . $config->{'Dir'}; |
|
Jifty->config->app('ScrapBookDir'); |
|
46 |
|
|
47 |
my $path = $dir . '/scrapbook.rdf'; |
my $path = $dir . '/scrapbook.rdf'; |
48 |
$path =~ s!//+!/!g; |
$path =~ s!//+!/!g; |
60 |
# warn "## original rdf -> ", dump( $rdf ); |
# warn "## original rdf -> ", dump( $rdf ); |
61 |
|
|
62 |
my $owner = Grep::Model::User->new(); |
my $owner = Grep::Model::User->new(); |
63 |
$owner->load_by_cols( email => Jifty->config->app('ScrapBookOwner') ); |
$owner->load_by_cols( email => $config->{OwnerEmail} ); |
64 |
die "can't find ScrapBookOwner ", Jifty->config->app('ScrapBookOwner') unless ( $owner->id ); |
die "can't find ScrapBookOwner ", $config->{OwnerEmail} unless ( $owner->id ); |
65 |
|
|
66 |
Jifty->log->info( "Using user ", $owner->id, " from ", $owner->email, " for import" ); |
Jifty->log->info( "Using user ", $owner->id, " from ", $owner->email, " for import" ); |
67 |
|
|
113 |
|
|
114 |
my $body = $tree->look_down( '_tag', 'body' ); |
my $body = $tree->look_down( '_tag', 'body' ); |
115 |
|
|
116 |
my $resolver = HTML::ResolveLink->new( base => '/static/' . Jifty->config->app('ScrapBookDir') . $rel_path ); |
my $resolver = HTML::ResolveLink->new( base => '/static/' . $config->{Dir} . $rel_path ); |
117 |
$content = $resolver->resolve( $body->as_HTML ); |
$content = $resolver->resolve( $body->as_HTML ); |
118 |
|
|
119 |
# create date from id |
# create date from id |