/[Frey]/branches/zimbardo/lib/Frey/Web.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /branches/zimbardo/lib/Frey/Web.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 543 by dpavlin, Wed Nov 26 19:43:03 2008 UTC revision 546 by dpavlin, Wed Nov 26 20:48:07 2008 UTC
# Line 84  sub html_dump { Line 84  sub html_dump {
84          return "<code>$dump</code>";          return "<code>$dump</code>";
85  }  }
86    
87    sub popup    { my $self = shift; $self->popup_dropdown('popup',    @_); }
88    sub dropdown { my $self = shift; $self->popup_dropdown('dropdown', @_); }
89    
90    our $re_html = qr{<(?:!--.+?--|(\w+).+?/\1)>}s; # relaxed html check for one semi-valid tag
91    
92    sub popup_dropdown {
93            my ( $self, $type, $name, $content, $full ) = @_;
94    
95            $content = $self->html_dump($content) if ref $content;
96    
97            $content = qq|<span>$content</span>| unless $content =~ m{^\s*<(span|a|code).+?/\1>\s*};
98    
99            warn "## $type [$name] = ", length( $content ), " bytes" if $self->debug;
100    
101            if ( $name =~ m{::} && $name !~ $re_html ) {
102                    return qq|<a class="frey-$type" target="$name" href="/$name">$name $content</a>\n|;
103            } else {
104                    return qq|<span class="frey-$type">$name $content</span>\n|;
105            }
106    }
107    
108  sub dom2html {  sub dom2html {
109  #       warn "## dom2html ",dump( @_ );  #       warn "## dom2html ",dump( @_ );
110          return Continuity::Widget::DomNode->create( @_ )->to_string;          return Continuity::Widget::DomNode->create( @_ )->to_string;
# Line 132  sub add_head { Line 153  sub add_head {
153          return if ! defined $path || $path eq '';          return if ! defined $path || $path eq '';
154          $path =~ s!^/!!;          $path =~ s!^/!!;
155    
156          if ( $path =~ m{<.*>}s ) {          if ( $path =~ $re_html ) {
157                  push @{ $self->head }, $path;                  push @{ $self->head }, $path;
158          } elsif ( -e $path ) {          } elsif ( -e $path ) {
159                  if ( $path =~ m/\.(?:js|css)$/ ) {                  if ( $path =~ m/\.(?:js|css)$/ ) {
# Line 165  sub status { @status }; Line 186  sub status { @status };
186    
187  our $icon_html;  our $icon_html;
188    
 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|<span>$l bytes</span>| if ! $full && $l > $self->dump_max_bytes;  
         } else {  
                 $content = qq|<span>$content</span>|;  
         }  
   
         warn "## $type [$name] = ", length( $content ), " bytes" if $self->debug;  
   
         if ( $name =~ m{::} && ! $name =~ m{<(\w+).+?/\1>} ) {  
                 return qq|<a class="frey-$type" target="$name" href="/$name">$name $content</a>\n|;  
         } else {  
                 return qq|<span class="frey-$type">$name $content</span>\n|;  
         }  
 }  
   
189  sub page {  sub page {
190          my $self = shift;          my $self = shift;
191          my $a = {@_};          my $a = {@_};

Legend:
Removed from v.543  
changed lines
  Added in v.546

  ViewVC Help
Powered by ViewVC 1.1.26