/[Grep]/lib/Grep/Import/ScrapBook.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Grep/Import/ScrapBook.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 161 by dpavlin, Sun Jun 10 21:20:28 2007 UTC revision 162 by dpavlin, Mon Jun 11 10:18:09 2007 UTC
# Line 28  use Data::Dump qw/dump/; Line 28  use Data::Dump qw/dump/;
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;
# Line 49  sub import { Line 60  sub import {
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    
# Line 102  sub import { Line 113  sub import {
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

Legend:
Removed from v.161  
changed lines
  Added in v.162

  ViewVC Help
Powered by ViewVC 1.1.26