| - . $self->html_links( $error ) . - qq|| - ; + $self->add_icon('error'); + $error = $self->html_links( $error ); + return qq|
$error $backtrace| ; } =head1 Status line @@ -384,8 +470,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 ] ) { @@ -400,19 +486,19 @@ Called at beginning of each request - $self->clean_status; + $self->setup_request; =cut -sub clean_status { +sub setup_request { my ($self) = shift; + warn "## clean_status"; @head = ( 'static/frey.css' ); @status = ( - { 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup }, + { 'ClassBrowser' => Frey::Class::Browser->new( usage_sort => 1, usage_on_top => 0 )->as_markup }, { 'Bookmarklets' => Frey::Bookmarklet->new->as_markup }, - { 'INC' => Frey::INC->new->as_markup }, + { 'INC' => Frey::INC->new->as_markup }, ); - $icon_html = ''; } =head2 status_parts @@ -436,53 +522,6 @@ =cut -=head2 add_icon - - Frey::Foo->add_icon; # /static/icons/Frey/Foo.png - Frey::Foo->add_icon('warning'); # /static/icons/Frey/Foo/warning.png - -=cut - -sub icon_path { - my ($self,$class,$variant) = @_; - my $icon = $class; - $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" ); - return undef; - } -} - -sub add_icon { - my ($self,$variant) = @_; - - my $class = ref($self); - $class = $self->class if $self->can('class'); - my $icon_path = $self->icon_path( $class, $variant ) || return; - - $icon_html .= qq||; - warn "# using icon $icon_path"; - -=for later - - # FIXME http://en.wikipedia.org/wiki/Favicon suggest just rel="icon" but that doesn't seem to work! - my $ico_path = $icon_path; - $ico_path =~ s{png$}{ico}; - if ( ! -e $ico_path ) { - system "convert $icon_path $ico_path"; - warn "# convert $icon_path $ico_path : $@"; - } - $icon_html .= qq|| if -e $ico_path; - -=cut - -} - my $warn_colors = { '#' => '#444', '##' => '#888', @@ -503,7 +542,7 @@ =cut sub log_path { - $Frey::Bootstrap::log_path || die "no log_path?"; + $Frey::Bootstrap::log_path || die "no log_path did you load Frey::Bootstrap?"; } our $pwd = `pwd`; @@ -633,7 +672,7 @@ my ($self) = @_; my @backtrace; - foreach ( 0 .. 5 ) { + foreach ( 1 .. 5 ) { # 0 = backtrace my ( $package,$path,$line # subroutine hasargs @@ -659,11 +698,30 @@ sub checkbox { my ($self,$name,$value) = @_; my $checked = ''; - my $all_checkboxes = $self->$name; + my $all_checkboxes = eval { $self->$name }; + warn "ERROR tried to get checkbox value for '$name' which is unknown: $@" if $@; $all_checkboxes = [ $all_checkboxes ] unless ref($all_checkboxes) eq 'ARRAY'; # sigh, too chatty - $checked = ' checked' if grep { $_ eq $value } @$all_checkboxes; + $checked = ' checked' if grep { defined $_ && $_ eq $value } @$all_checkboxes; warn "# checkbox $name $value $checked\t", $self->dump( $self->$name ); qq||; } +=head2 strip + +Strip whitespace around content + + my $stripped = strip(' no more whitespace around this '); + +=cut + +sub strip { + my $t = shift; + $t =~ s{^\s+}{}gs; + $t =~ s{>\s+<}{><}gs; + $t =~ s{\s+$}{}gs; + return $t; +} + +no Moose::Role; + 1;