185 |
$body = '<!-- no body -->'; |
$body = '<!-- no body -->'; |
186 |
} |
} |
187 |
|
|
188 |
my $warn_colors = { |
$status_line .= $self->warnings_html; |
|
'#' => '#444', |
|
|
'##' => '#888', |
|
|
}; |
|
|
|
|
|
$status_line |
|
|
.= qq|<span class="frey-popup">warn<span>| |
|
|
. $self->editor_links( |
|
|
join("", map { |
|
|
warn "# $_"; |
|
|
my $style = ''; |
|
|
$style = $warn_colors->{$1} |
|
|
? ' style="color:' . $warn_colors->{$1} . '"' |
|
|
: '' |
|
|
if m{^(#+)}; |
|
|
qq|<tt$style>$_</tt><br/>|; # XXX <tt> should be <code> but CSS hates me |
|
|
} $self->warnings ) |
|
|
) |
|
|
. qq|</span></span>| |
|
|
if $self->warnings; |
|
189 |
|
|
190 |
my ($exit,$description) = ('exit','stop server'); |
my ($exit,$description) = ('exit','stop server'); |
191 |
($exit,$description) = ('restart','restart server') |
($exit,$description) = ('restart','restart server') |
351 |
|
|
352 |
} |
} |
353 |
|
|
354 |
|
my $warn_colors = { |
355 |
|
'#' => '#444', |
356 |
|
'##' => '#888', |
357 |
|
}; |
358 |
|
|
359 |
|
my $multiline_markers = { |
360 |
|
'(' => '\)', |
361 |
|
'{' => '}', |
362 |
|
'[' => '\]', |
363 |
|
'"' => '"', |
364 |
|
}; |
365 |
|
|
366 |
|
my $multiline_re = '[\\' . join('\\', keys %$multiline_markers ) . ']'; |
367 |
|
warn "## multiline markers ", dump( $multiline_markers ), " -> $multiline_re"; |
368 |
|
|
369 |
|
sub log_path { |
370 |
|
$Frey::Bootstrap::log_path || warn "no log_path?"; |
371 |
|
} |
372 |
|
|
373 |
|
sub warnings_html { |
374 |
|
my ($self,$level) = shift; |
375 |
|
$level ||= $self->debug; |
376 |
|
my $path = $self->log_path; |
377 |
|
|
378 |
|
my $warnings; |
379 |
|
my $line = 0; |
380 |
|
my $multiline_end; |
381 |
|
|
382 |
|
open(my $log, '<', $path) || die "can't open $path: $!"; |
383 |
|
while(<$log>) { |
384 |
|
chomp; |
385 |
|
$line++; |
386 |
|
|
387 |
|
if ( $multiline_end ) { |
388 |
|
undef $multiline_end if m{^$multiline_end}; |
389 |
|
next; |
390 |
|
} |
391 |
|
|
392 |
|
my $style = ''; |
393 |
|
|
394 |
|
if ( m{^(#*)\s+} ) { |
395 |
|
my $l = $1 ? length($1) : 0; |
396 |
|
$multiline_end = $multiline_markers->{$1} if m{($multiline_re)$}; |
397 |
|
next if $l > $level; |
398 |
|
warn "## multiline_end: $multiline_end $l > $level for '$_'" if $multiline_end; |
399 |
|
undef $multiline_end; |
400 |
|
|
401 |
|
$style = $warn_colors->{$1} |
402 |
|
? ' style="color:' . $warn_colors->{$1} . '"' |
403 |
|
: ''; |
404 |
|
|
405 |
|
$warnings .= qq|<tt$style>$_</tt> <small> <a target="editor" href="/editor+$path+$line">+$line</a> </small> <br/>|; |
406 |
|
# FIXME <tt> should be <code> but CSS hates me |
407 |
|
} |
408 |
|
} |
409 |
|
close($log) || die "can't close $path: $!"; |
410 |
|
|
411 |
|
return |
412 |
|
qq|<span class="frey-popup"><a target="editor" href="/editor+$path+$line" title="open $path level $level">warn</a><span>| |
413 |
|
. $self->editor_links( $warnings ) |
414 |
|
. qq|</span></span>| |
415 |
|
; |
416 |
|
} |
417 |
|
|
418 |
1; |
1; |