--- trunk/lib/Frey/Web.pm 2008/12/10 18:47:14 796 +++ trunk/lib/Frey/Web.pm 2008/12/14 14:13:35 835 @@ -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 } @@ -185,14 +186,23 @@ } sub add_js { - my ($self,$css) = @_; + my ($self,$js) = @_; my ( $package, $path, $line ) = caller; - $self->add_head( qq| - - | ); + + if ( $js =~ m{http.*\.js} ) { + $self->add_head( qq| + + |); + } else { + $self->add_head( qq| + + | ); + }; } our $reload_counter = 0; @@ -236,10 +246,7 @@ if ( ! $body ) { my $run = $a->{run} || 'as_markup'; warn "# no body, invoke $self->$run on ", ref($self); - eval { - $body = $self->$run; - }; - $body = $self->error( $@, '' ) if $@; + $body = $self->$run; } if ( $self->content_type !~ m{html} ) { warn "# return only $self body ", $self->content_type; @@ -376,6 +383,7 @@ } warn "ERROR: $error\n"; + $self->add_icon('error'); return qq|
|
 		. $self->html_links( $error ) .
@@ -456,25 +464,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||;