/[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 600 by dpavlin, Fri Nov 28 19:19:03 2008 UTC revision 611 by dpavlin, Fri Nov 28 23:34:26 2008 UTC
# Line 16  use Frey::INC; Line 16  use Frey::INC;
16    
17  use Frey::SVK;  use Frey::SVK;
18    
19    use Text::Tabs; # expand, unexpand
20    
21  our @head;  our @head;
22  sub head { @head }  sub head { @head }
23    
# Line 61  has 'html_dump_width' => ( Line 63  has 'html_dump_width' => (
63          is => 'rw',          is => 'rw',
64          isa => 'Int',          isa => 'Int',
65  #       required => 1, # FIXME we can't have required fields with defaults because Frey::Action isn't smart enough and asks for them  #       required => 1, # FIXME we can't have required fields with defaults because Frey::Action isn't smart enough and asks for them
66          default => 128,          default => 120,
67  );  );
68    
69  my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');  my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');
# Line 218  sub page { Line 220  sub page {
220          my $body = $a->{body};          my $body = $a->{body};
221          if ( ! $body ) {          if ( ! $body ) {
222                  my $run = $a->{run} || 'as_markup';                  my $run = $a->{run} || 'as_markup';
223                  warn "# no body, invoke $self->$run";                  warn "# no body, invoke $self->$run on ", ref($self);
224                  $body = $self->$run;                  $body = $self->$run;
225          }          }
226          if ( $self->content_type !~ m{html} ) {          if ( $self->content_type !~ m{html} ) {
# Line 467  sub warnings_html { Line 469  sub warnings_html {
469          $level ||= $self->debug,          $level ||= $self->debug,
470          my $path = $self->log_path;          my $path = $self->log_path;
471    
472          my $max = 50;          my $max = 30;
473          my $pos = 0;          my $pos = 0;
474          my @warnings = ( '' x $max ); # XXX circualar buffer for 50 lines          my @warnings = ( '' x $max ); # XXX circualar buffer for 50 lines
475          my $line = 0;          my $line = 0;
476          my $multiline_end;          my $multiline_end;
477    
478            # XXX do we really want to do this every time?
479            my $css = qq|/* short css classes for levels */\n|;
480            my $level_to_class;
481            foreach ( keys %$warn_colors ) {
482                    my $l = length($_);
483                    my $class = 'l' . $l;
484                    $css .= qq|.$class { color: $warn_colors->{$_} }\n|;
485                    $level_to_class->{ $_ } = $class;
486            }
487            $self->add_css( $css );
488    
489          open(my $log, '<', $path) || die "can't open $path: $!";          open(my $log, '<', $path) || die "can't open $path: $!";
490          while(<$log>) {          while(<$log>) {
491                  chomp;                  chomp;
# Line 499  sub warnings_html { Line 512  sub warnings_html {
512                          }                          }
513    
514  =cut  =cut
515                  if ( m{^(#*)\s+} ) { # FIXME                  if ( m{^(#*)} ) {
516    
517                          $style = $warn_colors->{$1}                          my $level = $1;
518                                  ? ' style="color:' . $warn_colors->{$1} . '"'                          my $msg = $_;
                                 : '';  
519    
                         my $msg = $self->html_escape( $_ );  
520                          my $spacer = ' ';                          my $spacer = ' ';
521                          if ( length($msg) > $self->html_dump_width ) {                          my $real_msg = expand( $msg );
522                                  $msg = substr( $msg, 0, $self->html_dump_width );                          if ( length($real_msg) > $self->html_dump_width ) {
523                                    
524                                    $real_msg = substr( $msg, 0, $self->html_dump_width );
525                                    $msg = unexpand( $real_msg );
526                                  $spacer = '&hellip;'                                  $spacer = '&hellip;'
527                          }                          }
528                          $warnings[ $pos++ % $max ]  
529                                  = $msg                          $msg = $self->html_escape( $msg );
530  #                               = ( $style ? qq|<span$style>$msg</span>| : $msg )  
531                                  . $spacer                          if ( my $class = $level_to_class->{ $level } ) {
532                                  . qq|<a target="editor" href="/editor+$path+$line" style="float: right;">+$line</a><br/>|;                                  $msg = qq|<span class="$class">$msg</span>|;
533                          # FIXME <tt> should be <code> but CSS hates me                          }
534    
535                            $msg .= $spacer .
536                                    qq|<a target="editor" href="/editor+$path+$line" style="float: right;">+$line</a>\n|;
537    
538                            $warnings[ $pos++ % $max ] = $msg;
539                  }                  }
540          }          }
541            warn "log has $line lines tell position ",tell($log);
542          close($log) || die "can't close $path: $!";          close($log) || die "can't close $path: $!";
543    
544          my $size = -s $path;          my $size = -s $path;
545    
546          my $warnings = join('',          my $warnings = join("",
547                  map { $warnings[ ( $pos + $_ ) % $max ] || '' } 0 .. $max                  map { $warnings[ ( $pos + $_ ) % $max ] || '' } 1 .. $max
548          );          );
549    
550          my $s = length($warnings);          my $s = length($warnings);
551    
552          return          return
553                  # need to wrap into span so we can have links in warnings                  # need to wrap editor link into span so we can have links in warnings
554                    qq|<span class="frey-popup"><a target="editor" href="/editor+$path+$line" title="$path \| $size -> $s bytes \| $line -> $pos lines \| level $level">warn</a><code>|                    qq|<span class="frey-popup"><a target="editor" href="/editor+$path+$line" title="$path \| $size -> $s bytes \| $line -> $pos lines \| level $level">warn</a><code>|
555                  . $warnings                  . $self->editor_links( $warnings )
 #               . $self->editor_links( $warnings )  
556                  . qq|</code></span></a>|                  . qq|</code></span></a>|
557                  ;                  ;
558  }  }

Legend:
Removed from v.600  
changed lines
  Added in v.611

  ViewVC Help
Powered by ViewVC 1.1.26