--- trunk/lib/Frey/Web.pm 2008/12/09 20:31:42 781
+++ trunk/lib/Frey/Web.pm 2008/12/11 21:36:04 816
@@ -3,21 +3,22 @@
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::ClassBrowser;
+use Frey::Class::Browser;
use Frey::INC;
use Frey::SVK;
-use Text::Tabs; # expand, unexpand
-
our @head;
sub head { @head }
@@ -93,7 +94,7 @@
sub popup { my $self = shift; $self->popup_dropdown('popup', @_); }
sub dropdown { my $self = shift; $self->popup_dropdown('dropdown', @_); }
-our $re_html = qr{<(?:!--.+?--|(\w+).+?/\1|[^>]+/)>}s; # relaxed html check for one semi-valid tag
+our $re_html = qr{<(?:!--.+?--|(\w+).+?/\1|[^>]+/?)>}s; # relaxed html check for one semi-valid tag
sub popup_dropdown {
my ( $self, $type, $name, $content, $full ) = @_;
@@ -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;
@@ -419,7 +429,7 @@
my ($self) = shift;
@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 },
);
@@ -456,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;
}
}