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

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

revision 584 by dpavlin, Fri Nov 28 13:25:17 2008 UTC revision 596 by dpavlin, Fri Nov 28 17:20:05 2008 UTC
# Line 87  sub html_dump { Line 87  sub html_dump {
87  sub popup    { my $self = shift; $self->popup_dropdown('popup',    @_); }  sub popup    { my $self = shift; $self->popup_dropdown('popup',    @_); }
88  sub dropdown { my $self = shift; $self->popup_dropdown('dropdown', @_); }  sub dropdown { my $self = shift; $self->popup_dropdown('dropdown', @_); }
89    
90  our $re_html = qr{<(?:!--.+?--|(\w+).+?/\1)>}s; # relaxed html check for one semi-valid tag  our $re_html = qr{<(?:!--.+?--|(\w+).+?/\1|[^>]+/)>}s; # relaxed html check for one semi-valid tag
91    
92  sub popup_dropdown {  sub popup_dropdown {
93          my ( $self, $type, $name, $content, $full ) = @_;          my ( $self, $type, $name, $content, $full ) = @_;
# Line 98  sub popup_dropdown { Line 98  sub popup_dropdown {
98    
99          $content =~ s{<span>(<code>[^<]+</code>)</span>}{$1} && $self->TODO("code wrapped in span");          $content =~ s{<span>(<code>[^<]+</code>)</span>}{$1} && $self->TODO("code wrapped in span");
100    
101          warn "## $type [$name] = ", length( $content ), " bytes" if $self->debug;          warn "## $type [$name] = ", length( $content ), " bytes"; # if $self->debug; # FIXME
102    
103          if ( $name =~ m{::} && $name !~ $re_html ) {          if ( $name =~ m{::} && $name !~ $re_html ) {
104                  return qq|<a class="frey-$type" target="$name" href="/$name">$name $content</a>\n|;                  return qq|<a class="frey-$type" target="$name" href="/$name">$name $content</a>\n|;
105            } elsif ( $name =~ s{^\s*(<a)\s+}{$1 class="frey-$type"} ) {
106                    return qq|$name $content\n|;
107          } else {          } else {
108                  return qq|<span class="frey-$type">$name $content</span>\n|;                  return qq|<span class="frey-$type">$name $content</span>\n|;
109          }          }
# Line 214  sub page { Line 216  sub page {
216          $url =~ s{\?reload=\d+}{};          $url =~ s{\?reload=\d+}{};
217    
218          my $body = $a->{body};          my $body = $a->{body};
219          $body ||= $self->as_markup if $self->can('as_markup');          if ( ! $body ) {
220                    my $run = $a->{run} || 'as_markup';
221                    warn "# no body, invoke $self->$run";
222                    $body = $self->$run;
223            }
224          if ( $self->content_type !~ m{html} ) {          if ( $self->content_type !~ m{html} ) {
225                  warn "# return only $self body ", $self->content_type;                  warn "# return only $self body ", $self->content_type;
226                  return $body                  return $body
# Line 300  Create HTML links to editor for perl err Line 306  Create HTML links to editor for perl err
306  sub editor_links {  sub editor_links {
307          my ( $self, $error ) = @_;          my ( $self, $error ) = @_;
308    
309    #       $error =~ s[(bless\({\s+.+?\s+},\s+)("[^"]+")(\) at)][<span class="frey-dropdown">$1<code>$2</code>$3</span>]gs; # FIXME insert bless hiding back
310    
311          $error =~ s{at\s+(\S+)\s+line\s+(\d+)}          $error =~ s{at\s+(\S+)\s+line\s+(\d+)}
312                  {at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm;                  {at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm;
313    
# Line 459  sub warnings_html { Line 467  sub warnings_html {
467          $level ||= $self->debug,          $level ||= $self->debug,
468          my $path = $self->log_path;          my $path = $self->log_path;
469    
470          my $warnings;          my $max = 50;
471            my $pos = 0;
472            my @warnings = ( '' x $max ); # XXX circualar buffer for 50 lines
473          my $line = 0;          my $line = 0;
474          my $multiline_end;          my $multiline_end;
475    
# Line 470  sub warnings_html { Line 480  sub warnings_html {
480    
481                  my $style = '';                  my $style = '';
482    
483    =for filter
484    
485                  if ( $multiline_end ) {                  if ( $multiline_end ) {
486                          if ( m{^\Q$multiline_end\E} || m{^\s.+\Q$multiline_end\E;$} ) {                          if ( m{^\Q$multiline_end\E} || m{^\s.+\Q$multiline_end\E;$} ) {
487  #                               warn "## $line end of $multiline_end in '$_'\n";  #                               warn "## $line end of $multiline_end in '$_'\n";
# Line 486  sub warnings_html { Line 498  sub warnings_html {
498                                  next;                                  next;
499                          }                          }
500    
501    =cut
502                    if ( m{^(#*)\s+} ) { # FIXME
503    
504                          $style = $warn_colors->{$1}                          $style = $warn_colors->{$1}
505                                  ? ' style="color:' . $warn_colors->{$1} . '"'                                  ? ' style="color:' . $warn_colors->{$1} . '"'
506                                  : '';                                  : '';
# Line 496  sub warnings_html { Line 511  sub warnings_html {
511                                  $msg = substr( $msg, 0, $self->html_dump_width );                                  $msg = substr( $msg, 0, $self->html_dump_width );
512                                  $spacer = '&hellip;'                                  $spacer = '&hellip;'
513                          }                          }
514                          $msg =~ s{^\s}{&nbsp;}g;                          $warnings[ $pos++ % $max ]
515                          $warnings .= qq|<tt$style>$msg</tt>$spacer<small><a target="editor" href="/editor+$path+$line">+$line</a></small><br/>|;                                  = $msg
516    #                               = ( $style ? qq|<span$style>$msg</span>| : $msg )
517                                    . $spacer
518                                    . qq|<a target="editor" href="/editor+$path+$line" style="float: right;">+$line</a><br/>|;
519                          # FIXME <tt> should be <code> but CSS hates me                          # FIXME <tt> should be <code> but CSS hates me
520                  }                  }
521          }          }
522          close($log) || die "can't close $path: $!";          close($log) || die "can't close $path: $!";
523    
524            my $size = -s $path;
525    
526            my $warnings = join('',
527                    map { $warnings[ ( $pos + $_ ) % $max ] || '' } 0 .. $max
528            );
529    
530            my $s = length($warnings);
531    
532          return          return
533                    qq|<span class="frey-popup"><a target="editor" href="/editor+$path+$line" title="open $path level $level">warn</a><span>|                  # need to wrap into span so we can have links in warnings
534                  . $self->editor_links( $warnings )                    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>|
535                  . qq|</span></span>|                  . $warnings
536    #               . $self->editor_links( $warnings )
537                    . qq|</code></span></a>|
538                  ;                  ;
539  }  }
540    
# Line 534  sub backtrace { Line 562  sub backtrace {
562                  push @backtrace,                  push @backtrace,
563                          qq|via $package at $path line $line|;                          qq|via $package at $path line $line|;
564          }          }
565          warn "# backtrace: ", dump( @backtrace ) if @backtrace;          #warn "# backtrace: ", dump( @backtrace ) if @backtrace;
566          return @backtrace;          return @backtrace;
567  }  }
568    

Legend:
Removed from v.584  
changed lines
  Added in v.596

  ViewVC Help
Powered by ViewVC 1.1.26