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 |
|
|
24 |
has 'request_url' => ( |
has 'request_url' => ( |
25 |
is => 'rw', |
is => 'rw', |
26 |
isa => 'Uri', coerce => 1, |
isa => 'Uri', coerce => 1, |
27 |
default => '/', |
required => 1, |
28 |
|
# default => '/', |
29 |
); |
); |
30 |
|
|
31 |
has 'title' => ( |
has 'title' => ( |
64 |
is => 'rw', |
is => 'rw', |
65 |
isa => 'Int', |
isa => 'Int', |
66 |
# 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 |
67 |
default => 128, |
default => 120, |
68 |
); |
); |
69 |
|
|
70 |
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
124 |
$path =~ s!^/!!; |
$path =~ s!^/!!; |
125 |
if ( $path =~ m/\.js$/ ) { |
if ( $path =~ m/\.js$/ ) { |
126 |
$out .= $self->_inline_path( $path ) ? |
$out .= $self->_inline_path( $path ) ? |
127 |
qq|<!-- $path --><script type="text/javascript">\n| . read_file($path) . qq|\n</script>| : |
qq|<script type="text/javascript">\n/* inline $path */\n\n| . read_file($path) . qq|\n</script>| : |
128 |
qq|<script type="text/javascript" src="/$path"></script>|; |
qq|<script type="text/javascript" src="/$path"></script>|; |
129 |
} elsif ( $path =~ m/\.css$/ ) { |
} elsif ( $path =~ m/\.css$/ ) { |
130 |
$out .= $self->_inline_path( $path ) ? |
$out .= $self->_inline_path( $path ) ? |
131 |
qq|<!-- $path --><style type="text/css">\n| . read_file( $path ) . qq|\n</style>| : |
qq|<style type="text/css">\n/* inline $path */\n\n| . read_file( $path ) . qq|\n</style>| : |
132 |
qq|<link type="text/css" rel="stylesheet" href="/$path" media="screen">|; |
qq|<link type="text/css" rel="stylesheet" href="/$path" media="screen">|; |
133 |
} elsif ( $path =~ m{<.+>}s ) { |
} elsif ( $path =~ m{<.+>}s ) { |
134 |
$out .= $path; |
$out .= $path; |
221 |
my $body = $a->{body}; |
my $body = $a->{body}; |
222 |
if ( ! $body ) { |
if ( ! $body ) { |
223 |
my $run = $a->{run} || 'as_markup'; |
my $run = $a->{run} || 'as_markup'; |
224 |
warn "# no body, invoke $self->$run"; |
warn "# no body, invoke $self->$run on ", ref($self); |
225 |
$body = $self->$run; |
$body = $self->$run; |
226 |
} |
} |
227 |
if ( $self->content_type !~ m{html} ) { |
if ( $self->content_type !~ m{html} ) { |
370 |
sub clean_status { |
sub clean_status { |
371 |
my ($self) = shift; |
my ($self) = shift; |
372 |
@head = ( 'static/frey.css' ); |
@head = ( 'static/frey.css' ); |
373 |
|
my $params = { request_url => $self->request_url }; |
374 |
@status = ( |
@status = ( |
375 |
{ 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup }, |
{ 'ClassBrowser' => Frey::ClassBrowser->new( %$params, usage_on_top => 0 )->as_markup }, |
376 |
{ 'Bookmarklets' => Frey::Bookmarklet->new->as_markup }, |
{ 'Bookmarklets' => Frey::Bookmarklet->new( %$params )->as_markup }, |
377 |
{ 'INC' => Frey::INC->new->as_markup }, |
{ 'INC' => Frey::INC->new( %$params )->as_markup }, |
378 |
); |
); |
379 |
$icon_html = ''; |
$icon_html = ''; |
380 |
} |
} |
471 |
$level ||= $self->debug, |
$level ||= $self->debug, |
472 |
my $path = $self->log_path; |
my $path = $self->log_path; |
473 |
|
|
474 |
my $max = 50; |
my $max = 30; |
475 |
my $pos = 0; |
my $pos = 0; |
476 |
my @warnings = ( '' x $max ); # XXX circualar buffer for 50 lines |
my @warnings = ( '' x $max ); # XXX circualar buffer for 50 lines |
477 |
my $line = 0; |
my $line = 0; |
478 |
my $multiline_end; |
my $multiline_end; |
479 |
|
|
480 |
|
# XXX do we really want to do this every time? |
481 |
|
my $css = qq|/* short css classes for levels */\n|; |
482 |
|
my $level_to_class; |
483 |
|
foreach ( keys %$warn_colors ) { |
484 |
|
my $l = length($_); |
485 |
|
my $class = 'l' . $l; |
486 |
|
$css .= qq|.$class { color: $warn_colors->{$_} }\n|; |
487 |
|
$level_to_class->{ $_ } = $class; |
488 |
|
} |
489 |
|
$self->add_css( $css ); |
490 |
|
|
491 |
open(my $log, '<', $path) || die "can't open $path: $!"; |
open(my $log, '<', $path) || die "can't open $path: $!"; |
492 |
while(<$log>) { |
while(<$log>) { |
493 |
chomp; |
chomp; |
514 |
} |
} |
515 |
|
|
516 |
=cut |
=cut |
517 |
if ( m{^(#*)\s+} ) { # FIXME |
if ( m{^(#*)} ) { |
518 |
|
|
519 |
$style = $warn_colors->{$1} |
my $level = $1; |
520 |
? ' style="color:' . $warn_colors->{$1} . '"' |
my $msg = $_; |
|
: ''; |
|
521 |
|
|
|
my $msg = $self->html_escape( $_ ); |
|
522 |
my $spacer = ' '; |
my $spacer = ' '; |
523 |
if ( length($msg) > $self->html_dump_width ) { |
my $real_msg = expand( $msg ); |
524 |
$msg = substr( $msg, 0, $self->html_dump_width ); |
if ( length($real_msg) > $self->html_dump_width ) { |
525 |
|
|
526 |
|
$real_msg = substr( $msg, 0, $self->html_dump_width ); |
527 |
|
$msg = unexpand( $real_msg ); |
528 |
$spacer = '…' |
$spacer = '…' |
529 |
} |
} |
530 |
$warnings[ $pos++ % $max ] |
|
531 |
= $msg |
$msg = $self->html_escape( $msg ); |
532 |
# = ( $style ? qq|<span$style>$msg</span>| : $msg ) |
|
533 |
. $spacer |
if ( my $class = $level_to_class->{ $level } ) { |
534 |
. qq|<a target="editor" href="/editor+$path+$line" style="float: right;">+$line</a><br/>|; |
$msg = qq|<span class="$class">$msg</span>|; |
535 |
# FIXME <tt> should be <code> but CSS hates me |
} |
536 |
|
|
537 |
|
#$msg .= $spacer . qq|<a target="editor" href="/editor+$path+$line" style="float: right;">$line</a>\n|; |
538 |
|
$msg = qq|<a target="editor" href="/editor+$path+$line" style="float: right;">$line</a>$msg| |
539 |
|
. ( $spacer ? $spacer : '' ) |
540 |
|
. "\n"; # XXX <pre> needs this |
541 |
|
|
542 |
|
$warnings[ $pos++ % $max ] = $msg; |
543 |
} |
} |
544 |
} |
} |
545 |
|
warn "log has $line lines tell position ",tell($log); |
546 |
close($log) || die "can't close $path: $!"; |
close($log) || die "can't close $path: $!"; |
547 |
|
|
548 |
my $size = -s $path; |
my $size = -s $path; |
549 |
|
|
550 |
my $warnings = join('', |
my $warnings = join("", |
551 |
map { $warnings[ ( $pos + $_ ) % $max ] || '' } 0 .. $max |
map { $warnings[ ( $pos + $_ ) % $max ] || '' } 0 .. ( $max - 1 ) |
552 |
); |
); |
553 |
|
|
554 |
my $s = length($warnings); |
my $s = length($warnings); |
555 |
|
|
556 |
return |
return |
557 |
# 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 |
558 |
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>| |
559 |
. $warnings |
. $self->editor_links( $warnings ) |
|
# . $self->editor_links( $warnings ) |
|
560 |
. qq|</code></span></a>| |
. qq|</code></span></a>| |
561 |
; |
; |
562 |
} |
} |