/[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 158 by dpavlin, Sun Jun 10 20:16:30 2007 UTC revision 159 by dpavlin, Sun Jun 10 21:20:28 2007 UTC
# Line 22  or modify L<ScrapBookDir> path (relative Line 22  or modify L<ScrapBookDir> path (relative
22  use XML::Simple;  use XML::Simple;
23  use File::Slurp;  use File::Slurp;
24  use HTML::ResolveLink;  use HTML::ResolveLink;
25    use HTML::TreeBuilder;
26  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
27    
28  sub import {  sub import {
# Line 86  sub import { Line 86  sub import {
86    
87                  # fetch full-text content and import it                  # fetch full-text content and import it
88    
89                  my $content_path = $dir . '/data/' . $hash->{id} . '/index.html';                  my $rel_path = '/data/' . $hash->{id} . '/index.html';
90    
91                    my $content_path = $dir . $rel_path;
92                  if ( ! -r $content_path ) {                  if ( ! -r $content_path ) {
93                          Jifty->log->warn("can't import $content_path: $!");                          Jifty->log->warn("can't import $content_path: $!");
94                          $stats->{failure}++;                          $stats->{failure}++;
# Line 95  sub import { Line 97  sub import {
97                  my $content = read_file( $content_path ) or                  my $content = read_file( $content_path ) or
98                          die "can't read $content_path: $!";                          die "can't read $content_path: $!";
99    
100                  my $resolver = HTML::ResolveLink->new( base => $content_path );                  my $tree = HTML::TreeBuilder->new or die "can't create html tree";
101                  $content = $resolver->resolve( $content );                  $tree->parse( $content ) or die "can't parse fetched content";
102    
103                    my $body = $tree->look_down( '_tag', 'body' );
104    
105                    my $resolver = HTML::ResolveLink->new( base => '/static/' . Jifty->config->app('ScrapBookDir') . $rel_path );
106                    $content = $resolver->resolve( $body->as_HTML );
107    
108                  # create date from id                  # create date from id
109    

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

  ViewVC Help
Powered by ViewVC 1.1.26