246 |
if ( ! $body ) { |
if ( ! $body ) { |
247 |
my $run = $a->{run} || 'as_markup'; |
my $run = $a->{run} || 'as_markup'; |
248 |
warn "# no body, invoke $self->$run on ", ref($self); |
warn "# no body, invoke $self->$run on ", ref($self); |
249 |
eval { |
$body = $self->$run; |
|
$body = $self->$run; |
|
|
}; |
|
|
$body = $self->error( $@, '' ) if $@; |
|
250 |
} |
} |
251 |
if ( $self->content_type !~ m{html} ) { |
if ( $self->content_type !~ m{html} ) { |
252 |
warn "# return only $self body ", $self->content_type; |
warn "# return only $self body ", $self->content_type; |
362 |
return $error; |
return $error; |
363 |
} |
} |
364 |
|
|
365 |
|
sub html_self { |
366 |
|
my $self = shift; |
367 |
|
my $html = $self; |
368 |
|
$html =~ s{([\w:]+)=}{<a target="$1" href="/$1" title="introspect $1">$1</a>=}gsm; |
369 |
|
return $html; |
370 |
|
} |
371 |
|
|
372 |
=head2 error |
=head2 error |
373 |
|
|
374 |
This method will return error to browser and backtrace unless |
This method will return error to browser and backtrace unless |
381 |
my $error = join(" ", @_); |
my $error = join(" ", @_); |
382 |
|
|
383 |
my $fatal = ''; |
my $fatal = ''; |
384 |
|
my $backtrace = ''; |
385 |
|
|
386 |
if ( $error !~ m{\n$} ) { |
if ( $error !~ m{\n$} ) { |
387 |
if ( my @backtrace = $self->backtrace ) { |
if ( my @backtrace = $self->backtrace ) { |
388 |
$error .= "\n\t" . join( "\n\t", @backtrace ); |
$backtrace = |
389 |
|
"\n" . $self->html_self . "->error backtrace\n\t" |
390 |
|
. $self->html_links( join( "\n\t", @backtrace ) ) |
391 |
|
; |
392 |
$fatal = qq| frey-fatal|; |
$fatal = qq| frey-fatal|; |
393 |
} |
} |
394 |
} |
} |
395 |
|
|
396 |
warn "ERROR: $error\n"; |
warn "ERROR: $error\n"; |
397 |
return |
$self->add_icon('error'); |
398 |
qq|<pre class="frey-error$fatal">| |
$error = $self->html_links( $error ); |
399 |
. $self->html_links( $error ) . |
return qq|<pre class="frey-error$fatal">$error $backtrace</pre>| ; |
|
qq|</pre>| |
|
|
; |
|
400 |
} |
} |
401 |
|
|
402 |
=head1 Status line |
=head1 Status line |
472 |
|
|
473 |
sub icon_path { |
sub icon_path { |
474 |
my ($self,$class,$variant) = @_; |
my ($self,$class,$variant) = @_; |
|
# $class ||= $self->title; |
|
475 |
|
|
476 |
sub icon_exists { |
sub icon_exists { |
477 |
my $class = shift; |
my $class = shift; |
483 |
} |
} |
484 |
|
|
485 |
my $path = icon_exists( $class ); |
my $path = icon_exists( $class ); |
486 |
|
if ( ! $path ) { |
487 |
while ( $class =~ s{::[^:]+$}{} && ! $path ) { |
my $super_class = $class; |
488 |
$path = icon_exists( $class ) unless $class eq 'Frey'; # don't default on Frey icon |
while ( $super_class =~ s{::[^:]+$}{} && ! $path ) { |
489 |
|
$path = icon_exists( $super_class ) unless $super_class eq 'Frey'; # don't default on Frey icon |
490 |
|
} |
491 |
} |
} |
492 |
|
|
493 |
if ( -e $path ) { |
if ( ! $path ) { |
494 |
warn "# $class from $self icon_path $path" if $self->debug; |
$self->TODO( "add icon for $class" . ( $variant ? " variant $variant" : '' ) ); |
|
return $path; |
|
|
} else { |
|
|
$self->TODO( "add $path icon for $class $variant" ); |
|
495 |
return undef; |
return undef; |
496 |
} |
} |
497 |
|
|
498 |
|
warn "# $class from $self icon_path $path" if $self->debug; |
499 |
|
return $path; |
500 |
} |
} |
501 |
|
|
502 |
sub add_icon { |
sub add_icon { |
503 |
my ($self,$variant) = @_; |
my ($self,$variant) = @_; |
504 |
|
|
505 |
my $class = ref($self); |
my $class = $self->class if $self->can('class'); |
506 |
$class = $self->class if $self->can('class'); |
#$class ||= $self->title; |
507 |
|
$class ||= ref($self); |
508 |
my $icon_path = $self->icon_path( $class, $variant ) || return; |
my $icon_path = $self->icon_path( $class, $variant ) || return; |
509 |
|
|
510 |
$icon_html .= qq|<link rel="icon" type="image/png" href="/$icon_path">|; |
$icon_html .= qq|<link rel="icon" type="image/png" href="/$icon_path">|; |
675 |
my ($self) = @_; |
my ($self) = @_; |
676 |
|
|
677 |
my @backtrace; |
my @backtrace; |
678 |
foreach ( 0 .. 5 ) { |
foreach ( 1 .. 5 ) { # 0 = backtrace |
679 |
my ( |
my ( |
680 |
$package,$path,$line |
$package,$path,$line |
681 |
# subroutine hasargs |
# subroutine hasargs |