/[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 865 by dpavlin, Tue Dec 16 21:09:32 2008 UTC revision 949 by dpavlin, Tue Jan 6 16:05:05 2009 UTC
# Line 80  sub html_escape { Line 80  sub html_escape {
80          return $html;          return $html;
81  }  }
82    
83    # from Mojo::ByteStream
84    sub url_escape {
85            my ( $self, $url, $pattern ) = @_;
86            $pattern ||= 'A-Za-z0-9\-\.\_\~';
87            $url =~ s/([^$pattern])/sprintf('%%%02X',ord($1))/ge;
88            return $url;
89    }
90    
91  sub html_dump {  sub html_dump {
92          my ( $self, $dump ) = @_;          my ( $self, $dump ) = @_;
93          $dump = dump( $dump ) if ref($dump);          $dump = dump( $dump ) if ref($dump);
# Line 118  sub popup_dropdown { Line 126  sub popup_dropdown {
126    
127  sub _inline {  sub _inline {
128          my ( $self, $path ) = @_;          my ( $self, $path ) = @_;
129            return unless defined $path;
130          warn "# _inline $path";          warn "# _inline $path";
131          -e $path && -s $path < $self->inline_smaller_than && -s $path;          -e $path && -s $path < $self->inline_smaller_than && -s $path;
132  }  }
# Line 186  sub _add_css_js { Line 195  sub _add_css_js {
195    
196          my ( $package, $path, $line ) = caller(1);          my ( $package, $path, $line ) = caller(1);
197    
198          if ( $content =~ m{\.(js|css)} ) {          $content = "/$content" if $content !~ m{[\n\r]} && -e $content;
199                  $content = "/$content" if -e $content;          if ( $content =~ $re_html ) {
200                  if ( $content =~ $re_html ) {                  $head = qq|
201                          $head = qq|                          $content
202                                  $content                          <!-- $type via $package at $path line $line -->
203                                  <!-- $type via $package at $path line $line -->                  |;
204                          |;          } elsif ( $content =~ m{^(/\w+|https?://)} && $content !~ m{[\n\r]} ) {
205                  } elsif ( $what eq 'js' ) {                  if ( $what eq 'js' ) {
206                          $head = qq|                          $head = qq|
207                                  <$tag type="$type" src="$content">                                  <$tag type="$type" src="$content">
208                                  /* $what via $package at $path line $line */                                  /* $what via $package at $path line $line */
# Line 248  sub page { Line 257  sub page {
257          my $self = shift;          my $self = shift;
258          my $a = {@_};          my $a = {@_};
259    
         warn "## page ",dump($a);  
   
260          $reload_counter++;          $reload_counter++;
261    
262          my $status_line = '';          my $status_line = '';
# Line 298  sub page { Line 305  sub page {
305    
306          $self->add_icon unless $icon_html;          $self->add_icon unless $icon_html;
307    
308            my $title = undef
309                    || $a->{title}
310                    || $self->title
311                    || ref($self)
312                    ;
313    
314    #       $title =~ s{(\w)\w+::}{$1:}g; # XXX compress names of classes
315    
316          my $html = join("\n",          my $html = join("\n",
317                  qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|,                  qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|,
318                  $self->_head_html,                  $self->_head_html,
319                  '<title>' . ( $self->title || $a->{title} || ref($self) ) . '</title>',                  qq|<title>$title</title>|,
320                  '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">',                  '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">',
321                  ( $icon_html || '<!-- no icon -->' ),                  ( $icon_html || '<!-- no icon -->' ),
322                  ( $a->{head} || '' ),                  ( $a->{head} || '' ),
# Line 432  sub error { Line 447  sub error {
447    
448  sub add_status {  sub add_status {
449          my ( $self, $data ) = @_;          my ( $self, $data ) = @_;
450          push @status, { 'X' => [ $self->backtrace ] };          die "no data" unless $data;
451          if ( ref($data) ) {          if ( ref $data  ) {
452                  push @status, $data;                  push @status, $data;
453          } else {          } else {
454                  if ( defined $status[ $#status ] ) {                  if ( defined $status[ $#status ] ) {

Legend:
Removed from v.865  
changed lines
  Added in v.949

  ViewVC Help
Powered by ViewVC 1.1.26