--- trunk/lib/Frey/Web.pm 2008/12/02 18:29:01 685 +++ trunk/lib/Frey/Web.pm 2008/12/10 18:47:14 796 @@ -11,7 +11,7 @@ use File::Slurp; use Frey::Bookmarklet; -use Frey::ClassBrowser; +use Frey::Class::Browser; use Frey::INC; use Frey::SVK; @@ -93,7 +93,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 ) = @_; @@ -184,6 +184,17 @@ | ); } +sub add_js { + my ($self,$css) = @_; + my ( $package, $path, $line ) = caller; + $self->add_head( qq| + + | ); +} + our $reload_counter = 0; @@ -408,7 +419,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 }, ); @@ -446,6 +457,7 @@ 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'; @@ -648,4 +660,39 @@ return @backtrace; } +=head2 checkbox + +Generate checkbox html markup from some attribute + + my $html = $self->checkbox('attribute_name', $value); + +=cut + +sub checkbox { + my ($self,$name,$value) = @_; + my $checked = ''; + 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 { 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; +} + 1;