/[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 154 by dpavlin, Sun Jun 10 18:41:00 2007 UTC revision 155 by dpavlin, Sun Jun 10 19:20:59 2007 UTC
# Line 17  You can symlink your ScrapBook directory Line 17  You can symlink your ScrapBook directory
17    
18  or modify L<ScrapBookDir> path (relative to Grep installation static root).  or modify L<ScrapBookDir> path (relative to Grep installation static root).
19    
 =head1 SEE ALSO  
   
 L<http://amb.vis.ne.jp/mozilla/scrapbook/> - ScrapBook FireFox extension  
   
20  =cut  =cut
21    
22  use XML::Simple;  use XML::Simple;
# Line 59  sub import { Line 55  sub import {
55                  #source => 'Grep::Source',                  #source => 'Grep::Source',
56          );          );
57    
58            my $stats;
59    
60          foreach my $item ( @{ $rdf->{'RDF:Description'} } ) {          foreach my $item ( @{ $rdf->{'RDF:Description'} } ) {
61    
62                  warn "## item = ",dump( $item );                  $stats->{total}++;
63    
64                    #warn "## item = ",dump( $item );
65    
66                  my $hash;                  my $hash;
67                  foreach my $k ( keys %$item ) {                  foreach my $k ( keys %$item ) {
# Line 72  sub import { Line 72  sub import {
72                          $hash->{$n} = $item->{$k};                          $hash->{$n} = $item->{$k};
73                  }                  }
74                    
75                  warn "## hash = ", dump( $hash );                  #warn "## hash = ", dump( $hash );
76    
77    
78                  # fetch full-text content and import it                  # fetch full-text content and import it
# Line 80  sub import { Line 80  sub import {
80                  my $content_path = $dir . '/data/' . $hash->{id} . '/index.html';                  my $content_path = $dir . '/data/' . $hash->{id} . '/index.html';
81                  if ( ! -r $content_path ) {                  if ( ! -r $content_path ) {
82                          Jifty->log->warn("can't import $content_path: $!");                          Jifty->log->warn("can't import $content_path: $!");
83                            $stats->{failure}++;
84                          next;                          next;
85                  }                  }
86                  my $content = read_file( $content_path ) or                  my $content = read_file( $content_path ) or
# Line 103  sub import { Line 104  sub import {
104                          warn "can't parse date from ", $hash->{id};                          warn "can't parse date from ", $hash->{id};
105                  }                  }
106    
   
107                  my $i = Grep::Model::Item->new();                  my $i = Grep::Model::Item->new();
108                  my ($id,$msg) = $i->load_or_create(                  my ($ok,$msg) = $i->load_or_create(
109                          in_feed => $feed,                          in_feed => $feed,
110                          title => $hash->{title},                          title => $hash->{title},
111                          link => $hash->{source},                          link => $hash->{source},
# Line 113  sub import { Line 113  sub import {
113                          issued => $hash->{id},                          issued => $hash->{id},
114                  );                  );
115    
116                    if ( ! $ok ) {
117                            Jifty->log->error( $msg );
118                            $stats->{failure}++;
119                            next;
120                    }
121    
122                  warn ">> item $id $msg\n";                  if ( $msg && $msg =~ m/^Found/ ) {
123                            $stats->{old}++;
124                    } else {
125                            $stats->{new}++;
126                            Jifty->log->info("imported ", $i->id ," ", $i->link, " ", length( $content ), " bytes");
127                            $search->add( $i, $i->in_feed->owner->id );
128                    }
129    
130          }          }
131    
132          return 1;          return $stats;
133  }  }
134    
135    =head1 SEE ALSO
136    
137    L<http://amb.vis.ne.jp/mozilla/scrapbook/> - ScrapBook FireFox extension
138    
139    =cut
140    
141  1;  1;

Legend:
Removed from v.154  
changed lines
  Added in v.155

  ViewVC Help
Powered by ViewVC 1.1.26