--- trunk/lib/Frey/Designer.pm 2008/08/11 19:30:30 165 +++ trunk/lib/Frey/Designer.pm 2008/08/11 19:32:29 166 @@ -24,11 +24,16 @@ required => 1, ); +has 'mirror' => ( + is => 'rw', + isa => 'Boolean', +); + #use String::TT qw/strip tt/; use pQuery; use File::Slurp; -use LWP::Simple; +use LWP::Simple (); use File::Path; use Data::Dump qw/dump/; @@ -37,16 +42,20 @@ } sub mirror_design { - my ( $url, $path ) = @_; + my ( $self, $c, $path ) = @_; return if -e $path; + return unless $self->mirror; + + my $url = $self->uri . '/' . $c->req->path . '?' . $c->req->uri->query; + my $base_path = $path; $base_path =~ s{/[^/]+$}{}; mkpath $base_path if ! -e $base_path; warn ">> mirror $url -> $path\n"; - mirror( $url, $path ) or die "can't mirror $url: $!"; + LWP::Simple::mirror( $url, $path ) or die "can't mirror $url: $!"; } sub handler { @@ -62,7 +71,7 @@ my $url = $self->uri; - mirror_design( $url . $c->req->path, $path ); + $self->mirror_design( $c, $path ); $body .= read_file( $path ); @@ -83,12 +92,22 @@ my $dom = pQuery( $body ); # warn dump( $dom->find("body") ); $dom->find(".navigation")->each( sub { - warn dump( $_->innerHTML ); + my $html = $_->innerHTML; + warn $html; +# $_->innerHTML(qq{ +#
$html
+# }); } ); +# $body = $dom->toHtml; + } - warn "<< ", $c->req->path, " ", -s $path, " ", $c->res->content_type, "\n"; + warn "<< ", $c->req->path, + " ", -s $path, + " ", $c->res->content_type, + " ", $c->req->params ? dump( $c->req->params ) : '', + "\n"; =for later