+
reload
$exit
@@ -270,10 +312,24 @@
$self->add_icon unless $icon_html;
+ my $title = undef
+ || $a->{title}
+ || $self->title
+ || ref($self)
+ ;
+
+# $title =~ s{(\w)\w+::}{$1:}g; # XXX compress names of classes
+
+ $self->add_css(qq|
+ body {
+ padding-bottom: 3em; /* don't overlap status line */
+ }
+ |);
+
my $html = join("\n",
qq||,
$self->_head_html,
- '' . ( $self->title || $a->{title} || ref($self) ) . '',
+ qq|$title|,
'',
( $icon_html || '' ),
( $a->{head} || '' ),
@@ -355,6 +411,13 @@
return $error;
}
+sub html_self {
+ my $self = shift;
+ my $html = $self;
+ $html =~ s{([\w:]+)=}{$1=}gsm;
+ return $html;
+}
+
=head2 error
This method will return error to browser and backtrace unless
@@ -367,20 +430,22 @@
my $error = join(" ", @_);
my $fatal = '';
+ my $backtrace = '';
if ( $error !~ m{\n$} ) {
if ( my @backtrace = $self->backtrace ) {
- $error .= "\n\t" . join( "\n\t", @backtrace );
+ $backtrace =
+ "\n" . $self->html_self . "->error backtrace\n\t"
+ . $self->html_links( join( "\n\t", @backtrace ) )
+ ;
$fatal = qq| frey-fatal|;
}
}
warn "ERROR: $error\n";
- return
- qq||
- . $self->html_links( $error ) .
- qq|
|
- ;
+ $self->add_icon('error');
+ $error = $self->html_links( $error );
+ return qq|$error $backtrace
| ;
}
=head1 Status line
@@ -395,8 +460,8 @@
sub add_status {
my ( $self, $data ) = @_;
- push @status, { 'X' => [ $self->backtrace ] };
- if ( ref($data) ) {
+ die "no data" unless $data;
+ if ( ref $data ) {
push @status, $data;
} else {
if ( defined $status[ $#status ] ) {
@@ -456,25 +521,39 @@
sub icon_path {
my ($self,$class,$variant) = @_;
- my $icon = $class;
- $icon ||= $self->title;
- $icon =~ s{::}{/}g;
- $icon .= "/$variant" if $variant;
- my $path = 'static/icons/' . $icon . '.png';
- if ( -e $path ) {
- warn "# $class from $self icon_path $path" if $self->debug;
- return $path;
- } else {
- $self->TODO( "add $path icon for $class" );
+
+ sub icon_exists {
+ my $class = shift;
+ $class =~ s{::}{/}g;
+ $class .= "/$variant" if $variant;
+ my $icon_path = 'static/icons/' . $class . '.png';
+ return $icon_path if -e $icon_path;
+ return;
+ }
+
+ my $path = icon_exists( $class );
+ if ( ! $path ) {
+ my $super_class = $class;
+ while ( $super_class =~ s{::[^:]+$}{} && ! $path ) {
+ $path = icon_exists( $super_class ) unless $super_class eq 'Frey'; # don't default on Frey icon
+ }
+ }
+
+ if ( ! $path ) {
+ $self->TODO( "add icon for $class" . ( $variant ? " variant $variant" : '' ) );
return undef;
}
+
+ warn "# $class from $self icon_path $path" if $self->debug;
+ return $path;
}
sub add_icon {
my ($self,$variant) = @_;
- my $class = ref($self);
- $class = $self->class if $self->can('class');
+ my $class = $self->class if $self->can('class');
+ #$class ||= $self->title;
+ $class ||= ref($self);
my $icon_path = $self->icon_path( $class, $variant ) || return;
$icon_html .= qq||;
@@ -645,7 +724,7 @@
my ($self) = @_;
my @backtrace;
- foreach ( 0 .. 5 ) {
+ foreach ( 1 .. 5 ) { # 0 = backtrace
my (
$package,$path,$line
# subroutine hasargs