/[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 532 by dpavlin, Wed Nov 26 07:57:12 2008 UTC revision 535 by dpavlin, Wed Nov 26 16:17:17 2008 UTC
# Line 50  has 'dump_max_bytes' => ( Line 50  has 'dump_max_bytes' => (
50          documentation => 'Maximum dump size sent to browser before truncation',          documentation => 'Maximum dump size sent to browser before truncation',
51  );  );
52    
 =head2 inline_smaller_than  
   
 Inline JavaScript and CSS smaller than this size into page reducing  
 round-trips to server.  
   
 =cut  
   
53  has 'inline_smaller_than' => (  has 'inline_smaller_than' => (
54          is => 'rw',          is => 'rw',
55          isa => 'Int',          isa => 'Int',
56          default => 10240,          default => 10240,
57            documentation => 'Inline JavaScript and CSS to reduce round-trips',
58    );
59    
60    has 'chop_warning' => (
61            is => 'rw',
62            isa => 'Int',
63            default => 80,
64            documentation => 'Crop lines longer',
65  );  );
66    
67    my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');
68    my $escape_re  = join '|' => keys %escape;
69    
70    sub html_escape {
71            my ( $self, $html ) = @_;
72            $html =~ s/($escape_re)/$escape{$1}/g;
73            return $html;
74    }
75    
76    sub html_dump {
77            my $self = shift;
78            $self->html_escape( dump( @_ ) );
79    }
80    
81  sub dom2html {  sub dom2html {
82  #       warn "## dom2html ",dump( @_ );  #       warn "## dom2html ",dump( @_ );
83          return Continuity::Widget::DomNode->create( @_ )->to_string;          return Continuity::Widget::DomNode->create( @_ )->to_string;
# Line 357  my $warn_colors = { Line 372  my $warn_colors = {
372  };  };
373    
374  my $multiline_markers = {  my $multiline_markers = {
375          '(' => '\)',          '(' => ')',
376          '{' => '}',          '{' => '}',
377          '[' => '\]',          '[' => ']',
378          '"' => '"',          '"' => '"',
379  };  };
380    
# Line 372  sub log_path { Line 387  sub log_path {
387    
388  sub warnings_html {  sub warnings_html {
389          my ($self,$level) = shift;          my ($self,$level) = shift;
390          $level ||= $self->debug;          $level ||= $self->debug,
391          my $path = $self->log_path;          my $path = $self->log_path;
392    
393          my $warnings;          my $warnings;
# Line 384  sub warnings_html { Line 399  sub warnings_html {
399                  chomp;                  chomp;
400                  $line++;                  $line++;
401    
                 if ( $multiline_end ) {  
                         undef $multiline_end if m{^$multiline_end};  
                         next;  
                 }  
   
402                  my $style = '';                  my $style = '';
403    
404                  if ( m{^(#*)\s+} ) {                  if ( $multiline_end ) {
405                            if ( m{^\Q$multiline_end\E} || m{^\s.+\Q$multiline_end\E;$} ) {
406                                    warn "## $line end of $multiline_end in '$_'\n";
407                                    undef $multiline_end;
408                            } else {
409                                    warn "## $line skipped\n";
410                            }
411                    } elsif ( m{^(#*)\s+} ) {
412                          my $l = $1 ? length($1) : 0;                          my $l = $1 ? length($1) : 0;
413                          $multiline_end = $multiline_markers->{$1} if m{($multiline_re)$};                          if ( $l > $level ) {
414                          next if $l > $level;                                  undef $multiline_end;
415                          warn "## multiline_end: $multiline_end $l > $level for '$_'" if $multiline_end;                                  $multiline_end = $multiline_markers->{$1} if m{($multiline_re)$};
416                          undef $multiline_end;                                  warn "## $line start $1 .. $multiline_end level $l > $level for '$_'\n" if $multiline_end;
417                                    next;
418                            }
419    
420                          $style = $warn_colors->{$1}                          $style = $warn_colors->{$1}
421                                  ? ' style="color:' . $warn_colors->{$1} . '"'                                  ? ' style="color:' . $warn_colors->{$1} . '"'
422                                  : '';                                  : '';
423    
424                          $warnings .= qq|<tt$style>$_</tt> <small> <a target="editor" href="/editor+$path+$line">+$line</a> </small> <br/>|;                          my $msg = $self->html_escape( $_ );
425                            my $spacer = ' ';
426                            if ( length($msg) > $self->chop_warning ) {
427                                    $msg = substr( $msg, 0, $self->chop_warning );
428                                    $spacer = '&hellip;'
429                            }
430                            $msg =~ s{^\s}{&nbsp;}g;
431                            $warnings .= qq|<tt$style>$msg</tt>$spacer<small><a target="editor" href="/editor+$path+$line">+$line</a></small><br/>|;
432                          # FIXME <tt> should be <code> but CSS hates me                          # FIXME <tt> should be <code> but CSS hates me
433                  }                  }
434          }          }

Legend:
Removed from v.532  
changed lines
  Added in v.535

  ViewVC Help
Powered by ViewVC 1.1.26