/[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

trunk/lib/Frey/Designer.pm revision 196 by dpavlin, Tue Oct 28 19:34:10 2008 UTC branches/no-pager/lib/Frey/Designer.pm revision 702 by dpavlin, Wed Dec 3 21:12:43 2008 UTC
# Line 12  use Frey::Types; Line 12  use Frey::Types;
12    
13  extends 'Frey';  extends 'Frey';
14  with 'Frey::Web';  with 'Frey::Web';
15    with 'Frey::Path';
16    
17  has 'uri' => (  has 'uri' => (
18          is => 'rw',          is => 'rw',
# Line 37  has 'resolve_links' => ( Line 38  has 'resolve_links' => (
38  use HTML::Query;  use HTML::Query;
39  use File::Slurp;  use File::Slurp;
40  use LWP::Simple qw/get/;  use LWP::Simple qw/get/;
 use File::Path;  
41  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
42  use HTML::ResolveLink;  use HTML::ResolveLink;
43    
44  sub path {  sub path {
45          my $self = shift;          my $self = shift;
46          my $path = 'templates/www.carnet.hr/' . $self->uri->path;          my $path = join('/', ( 'templates', $self->uri->host, $self->uri->path ) );
47          $path .= '.html' if $path !~ m/\.\w+$/;          $path .= '.html' if $path !~ m/\.\w+$/;
48          return $path;          return $path;
49  }  }
# Line 56  sub get_page { Line 56  sub get_page {
56    
57          if ( ! -e $path && $self->mirror ) {          if ( ! -e $path && $self->mirror ) {
58    
59                  my $base_path = $path;                  $self->mkbasepath( $path );
                 $base_path =~ s{/[^/]+$}{};  
                 mkpath $base_path if ! -e $base_path;  
60    
61                  my $url = $self->uri;                  my $url = $self->uri;
62                  warn ">> mirror $url -> $path\n";                  warn ">> mirror $url -> $path\n";
# Line 81  sub get_page { Line 79  sub get_page {
79          return $body;          return $body;
80  }  }
81    
82  sub html {  sub as_markup {
83      my ( $self, $req ) = @_;      my ( $self ) = @_;
84    
85      my $body;          my $body = $self->get_page;
   
         if ( $self->uri->path =~ m{/__bookmarklet} ) {  
                 my $js = read_file( 'static/xpath.js' );  
                 $js =~ s{//.*}{}gm;     # remove comments so that compaction below doesn't screw code  
                 $js =~ s/\s\s+/ /gs;  
         $req->print(qq{  
                         Drag this <a href="javascript:void($js);">bookmarklet</a> to bookmark toolbar or menu to install XPATH inspector  
                 });  
                 return;  
         }  
   
         $body .= $self->get_page;  
86    
87          # strip full hostname          # strip full hostname
88          my $url = $self->uri;          my $url = $self->uri;
# Line 129  sub html { Line 115  sub html {
115    
116          warn "<< ", $self->uri,          warn "<< ", $self->uri,
117                  " ", -s $self->path,                  " ", -s $self->path,
                 " ", $req->params ? dump( $req->params ) : '',  
118                  "\n";                  "\n";
119    
120  =for later  =for later
# Line 153  sub html { Line 138  sub html {
138    
139          warn $body;          warn $body;
140    
141          $req->print( $self->page( title => $self->uri, body => $body ) );          return $self->page( title => $self->uri, body => $body );
142  }  }
143    
144  1;  1;

Legend:
Removed from v.196  
changed lines
  Added in v.702

  ViewVC Help
Powered by ViewVC 1.1.26