/[Frey]/branches/zimbardo/lib/Frey/Web.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/zimbardo/lib/Frey/Web.pm

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

revision 568 by dpavlin, Thu Nov 27 22:09:59 2008 UTC revision 577 by dpavlin, Fri Nov 28 00:30:03 2008 UTC
# Line 16  use Frey::INC; Line 16  use Frey::INC;
16    
17  use Frey::SVK;  use Frey::SVK;
18    
19  has 'head' => (  our @head = ( 'static/frey.css' );
         is => 'rw',  
         isa => 'ArrayRef[Str]',  
         default => sub { [ 'static/frey.css' ] },  
 );  
20    
21  has 'request_url' => (  has 'request_url' => (
22          is => 'rw',          is => 'rw',
# Line 115  sub _inline_path { Line 111  sub _inline_path {
111  sub _head_html {  sub _head_html {
112          my $self = shift;          my $self = shift;
113          my $out = '';          my $out = '';
114          foreach my $path ( @{ $self->head } ) {          foreach my $path ( @head ) {
115                  $path =~ s!^/!!;                  $path =~ s!^/!!;
116                  if ( $path =~ m/\.js$/ ) {                  if ( $path =~ m/\.js$/ ) {
117                          $out .= $self->_inline_path( $path ) ?                          $out .= $self->_inline_path( $path ) ?
# Line 151  sub add_head { Line 147  sub add_head {
147          $path =~ s!^/!!;          $path =~ s!^/!!;
148    
149          if ( $path =~ $re_html ) {          if ( $path =~ $re_html ) {
150                  push @{ $self->head }, $path;                  push @head, $path;
151          } elsif ( -e $path ) {          } elsif ( -e $path ) {
152                  if ( $path =~ m/\.(?:js|css)$/ ) {                  if ( $path =~ m/\.(?:js|css)$/ ) {
153                          push @{ $self->head }, $path;                          push @head, $path;
154                  } else {                  } else {
155                          confess "can't add_head( $path ) it's not js or css";                          confess "can't add_head( $path ) it's not js or css";
156                  }                  }
# Line 165  sub add_head { Line 161  sub add_head {
161    
162  }  }
163    
164    sub add_css {
165            my ($self,$css) = @_;
166            my ( $package, $path, $line ) = caller;
167            $self->add_head( qq|
168            <style type="text/css">
169            /* via package $package at $path line $line */
170            $css
171            </style>
172            | );
173    }
174    
175  our $reload_counter = 0;  our $reload_counter = 0;
176    
177    
# Line 230  sub page { Line 237  sub page {
237                          </span>                          </span>
238                  |;                  |;
239    
240          my $info = Frey::SVK->info;          my $svk = Frey::SVK->new;
241          my $revision = Frey::SVK->info->{Revision} || '';          my $info = $svk->info;
242            my $revision = $svk->info->{Revision} || '';
243          $revision = $1 if $info->{'Mirrored From'} =~ m{Rev\.\s+(\d+)};          $revision = $1 if $info->{'Mirrored From'} =~ m{Rev\.\s+(\d+)};
244    
245          $self->add_icon unless $icon_html;          $self->add_icon unless $icon_html;
# Line 316  sub error { Line 324  sub error {
324                  ;                  ;
325  }  }
326    
327    =head1 Status line
328    
329    =head2 add_status
330    
331      $self->add_status( name => { some => 'data' } );
332    
333      $self->add_status( "append to last status popup" );
334    
335    =cut
336    
337  sub add_status {  sub add_status {
338          my ( $self, $data ) = @_;          my ( $self, $data ) = @_;
339          push @status, $data;          if ( ref($data) ) {
340                    push @status, $data;
341            } else {
342                    $status[ $#status ]->{added} = $data;
343            }
344  }  }
345    
346    =head2 clean_status
347    
348    Called at beginning of each request
349    
350      $self->clean_status;
351    
352    =cut
353    
354  sub clean_status {  sub clean_status {
355            my ($self) = shift;
356            @head = ();
357          @status = ();          @status = ();
358          $icon_html = '';          $icon_html = '';
359  }  }
360    
361    =head2 status_parts
362    
363    Dump all status line parts
364    
365      $self->status_parts
366    
367    =cut
368    
369  sub status_parts {  sub status_parts {
370          warn "## status parts ", dump( map { keys %$_ } @status );          warn "## status parts ", dump( map { keys %$_ } @status );
371  }  }
# Line 353  sub icon_path { Line 393  sub icon_path {
393          $icon .= "/$variant" if $variant;          $icon .= "/$variant" if $variant;
394          my $path = 'static/icons/' . $icon . '.png';          my $path = 'static/icons/' . $icon . '.png';
395          if ( -e $path ) {          if ( -e $path ) {
396                  warn "# $class from $self icon_path $path";                  warn "# $class from $self icon_path $path" if $self->debug;
397                  return $path;                  return $path;
398          } else {          } else {
399                  $self->TODO( "add $path icon for $class" );                  $self->TODO( "add $path icon for $class" );
# Line 483  sub backtrace { Line 523  sub backtrace {
523                  ) = caller($_) or last;                  ) = caller($_) or last;
524    
525                  push @backtrace,                  push @backtrace,
526                          qq|via $package from $path <a target="editor" href="/editor+$path+$line">$path</a>|;                          qq|via package $package at $path line $line|;
527          }          }
528          warn "# backtrace: ", dump( @backtrace ) if @backtrace;          warn "# backtrace: ", dump( @backtrace ) if @backtrace;
529          return @backtrace;          return @backtrace;

Legend:
Removed from v.568  
changed lines
  Added in v.577

  ViewVC Help
Powered by ViewVC 1.1.26