/[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 159 by dpavlin, Sun Jun 10 21:20:28 2007 UTC revision 177 by dpavlin, Sat Aug 11 17:41:42 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
# Line 119  sub import { Line 130  sub import {
130                                  #time_zone => 'UTC',                                  #time_zone => 'UTC',
131                          );                          );
132                  } else {                  } else {
133                          warn "can't parse date from ", $hash->{id};                          die "can't parse date from ", $hash->{id};
134                  }                  }
135    
136                  my $i = Grep::Model::Item->new( current_user => $owner );                  my $i = Grep::Model::Item->new( current_user => $owner );
# Line 128  sub import { Line 139  sub import {
139                          title => $hash->{title},                          title => $hash->{title},
140                          link => $hash->{source},                          link => $hash->{source},
141                          content => $content,                          content => $content,
142                          issued => $hash->{id},  #                       created_on => $dt,
143                  );                  );
144    
145                    $i->set_created_on( $dt );
146    
147                  if ( ! $ok ) {                  if ( ! $ok ) {
148                          Jifty->log->error( $msg );                          Jifty->log->error( $msg );
149                          $stats->{failure}++;                          $stats->{failure}++;

Legend:
Removed from v.159  
changed lines
  Added in v.177

  ViewVC Help
Powered by ViewVC 1.1.26