--- trunk/lib/Frey/Web.pm 2008/12/11 21:17:35 815 +++ trunk/lib/Frey/Web.pm 2008/12/11 21:36:04 816 @@ -3,12 +3,15 @@ with 'Frey::Session'; -use Frey::Types; - #use Continuity::Widget::DomNode; use Data::Dump qw/dump/; use Carp qw/confess cluck carp/; use File::Slurp; +use Text::Tabs; # expand, unexpand + +use lib 'lib'; + +use Frey::Types; use Frey::Bookmarklet; use Frey::Class::Browser; @@ -16,8 +19,6 @@ use Frey::SVK; -use Text::Tabs; # expand, unexpand - our @head; sub head { @head } @@ -465,16 +466,28 @@ 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'; +# $class ||= $self->title; + + 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 ); + + while ( $class =~ s{::[^:]+$}{} && ! $path ) { + $path = icon_exists( $class ) unless $class eq 'Frey'; # don't default on Frey icon + } + if ( -e $path ) { warn "# $class from $self icon_path $path" if $self->debug; return $path; } else { - $self->TODO( "add $path icon for $class" ); + $self->TODO( "add $path icon for $class $variant" ); return undef; } }