/[Frey]/branches/no-pager/lib/Frey/Designer.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 /branches/no-pager/lib/Frey/Designer.pm

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

revision 164 by dpavlin, Sun Aug 10 16:01:07 2008 UTC revision 166 by dpavlin, Mon Aug 11 19:32:29 2008 UTC
# Line 24  has 'uri' => ( Line 24  has 'uri' => (
24          required => 1,          required => 1,
25  );  );
26    
27    has 'mirror' => (
28            is => 'rw',
29            isa => 'Boolean',
30    );
31    
32  #use String::TT qw/strip tt/;  #use String::TT qw/strip tt/;
33    
34  use pQuery;  use pQuery;
35  use File::Slurp;  use File::Slurp;
36  use LWP::Simple;  use LWP::Simple ();
37  use File::Path;  use File::Path;
38  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
39    
# Line 37  sub template_path { Line 42  sub template_path {
42  }  }
43    
44  sub mirror_design {  sub mirror_design {
45          my ( $url, $path ) = @_;          my ( $self, $c, $path ) = @_;
46          return if -e $path;          return if -e $path;
47    
48            return unless $self->mirror;
49    
50            my $url = $self->uri . '/' . $c->req->path . '?' . $c->req->uri->query;
51    
52          my $base_path = $path;          my $base_path = $path;
53          $base_path =~ s{/[^/]+$}{};          $base_path =~ s{/[^/]+$}{};
54          mkpath $base_path if ! -e $base_path;          mkpath $base_path if ! -e $base_path;
55    
56          warn ">> mirror $url -> $path\n";          warn ">> mirror $url -> $path\n";
57    
58          mirror( $url, $path ) or die "can't mirror $url: $!";          LWP::Simple::mirror( $url, $path ) or die "can't mirror $url: $!";
59  }  }
60    
61  sub handler {  sub handler {
# Line 62  sub handler { Line 71  sub handler {
71    
72          my $url = $self->uri;          my $url = $self->uri;
73    
74          mirror_design( $url . $c->req->path, $path );          $self->mirror_design( $c, $path );
75    
76          $body .= read_file( $path );          $body .= read_file( $path );
77    
# Line 83  sub handler { Line 92  sub handler {
92                  my $dom = pQuery( $body );                  my $dom = pQuery( $body );
93  #               warn dump( $dom->find("body") );  #               warn dump( $dom->find("body") );
94                  $dom->find(".navigation")->each( sub {                  $dom->find(".navigation")->each( sub {
95                          warn dump( $_->innerHTML );                          my $html = $_->innerHTML;
96                            warn $html;
97    #                       $_->innerHTML(qq{
98    #                               <div style="border: 3px dashed black;">$html</div>
99    #                       });
100                  } );                  } );
101    
102    #               $body = $dom->toHtml;
103    
104          }          }
105    
106          warn "<< ", $c->req->path, " ", -s $path, " ", $c->res->content_type, "\n";          warn "<< ", $c->req->path,
107                    " ", -s $path,
108                    " ", $c->res->content_type,
109                    " ", $c->req->params ? dump( $c->req->params ) : '',
110                    "\n";
111    
112  =for later  =for later
113    

Legend:
Removed from v.164  
changed lines
  Added in v.166

  ViewVC Help
Powered by ViewVC 1.1.26