--- trunk/lib/Frey/Web.pm 2008/11/26 20:47:13 545 +++ trunk/lib/Frey/Web.pm 2008/11/26 20:48:07 546 @@ -84,6 +84,27 @@ return "$dump"; } +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 + +sub popup_dropdown { + my ( $self, $type, $name, $content, $full ) = @_; + + $content = $self->html_dump($content) if ref $content; + + $content = qq|$content| unless $content =~ m{^\s*<(span|a|code).+?/\1>\s*}; + + warn "## $type [$name] = ", length( $content ), " bytes" if $self->debug; + + if ( $name =~ m{::} && $name !~ $re_html ) { + return qq|$name $content\n|; + } else { + return qq|$name $content\n|; + } +} + sub dom2html { # warn "## dom2html ",dump( @_ ); return Continuity::Widget::DomNode->create( @_ )->to_string; @@ -132,7 +153,7 @@ return if ! defined $path || $path eq ''; $path =~ s!^/!!; - if ( $path =~ m{<.*>}s ) { + if ( $path =~ $re_html ) { push @{ $self->head }, $path; } elsif ( -e $path ) { if ( $path =~ m/\.(?:js|css)$/ ) { @@ -165,29 +186,6 @@ our $icon_html; -sub popup { my $self = shift; $self->popup_dropdown('popup', @_); } -sub dropdown { my $self = shift; $self->popup_dropdown('dropdown', @_); } - -sub popup_dropdown { - my ( $self, $type, $name, $content, $full ) = @_; - - if ( ref($content) ) { - $content = $self->html_dump($content); -# my $l = length($content); -# $content = qq|$l bytes| if ! $full && $l > $self->dump_max_bytes; - } else { - $content = qq|$content|; - } - - warn "## $type [$name] = ", length( $content ), " bytes" if $self->debug; - - if ( $name =~ m{::} && ! $name =~ m{<(\w+).+?/\1>} ) { - return qq|$name $content\n|; - } else { - return qq|$name $content\n|; - } -} - sub page { my $self = shift; my $a = {@_};