/[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 835 by dpavlin, Sun Dec 14 14:13:35 2008 UTC revision 838 by dpavlin, Sun Dec 14 22:15:51 2008 UTC
# Line 174  sub add_head { Line 174  sub add_head {
174    
175  }  }
176    
177  sub add_css {  sub _add_something {
178          my ($self,$css) = @_;          my ( $self, $regex, $tag, $type, $content ) = @_;
         my ( $package, $path, $line ) = caller;  
         $self->add_head( qq|  
         <style type="text/css">  
         /* via $package at $path line $line */  
         $css  
         </style>  
         | );  
 }  
179    
180  sub add_js {          my ( $package, $path, $line ) = caller(1);
181          my ($self,$js) = @_;  
182          my ( $package, $path, $line ) = caller;          warn "# $regex $tag $type $content caller $package $path $line";
183    
184          if ( $js =~ m{http.*\.js} ) {          if ( $content =~ $regex ) {
185                  $self->add_head( qq|                  $content = "/$content" if -e $content;
186                          <script type="text/javascript" src="$js">                  $self->add_head( strip ( qq|
187                            <$tag type="$type"  src="$content">
188                          /* via $package at $path line $line */                          /* via $package at $path line $line */
189                          </script>                          </$tag>
190                  |);                  | ) );
191          } else {          } else {
192                  $self->add_head( qq|                  $self->add_head(qq|
193                          <script type="text/javascript">                          <$tag type="$type">
194                          /* via $package at $path line $line */                          /* via $package at $path line $line */
195                          $js                          $content
196                          </script>                          </$tag>
197                  | );                  |);
198          };          };
199  }  }
200    
201    sub add_css {
202            my ($self,$css) = @_;
203            $self->_add_something( qr{\.css$}, qw{style text/css}, $css );
204    }
205    
206    sub add_js {
207            my ($self,$js) = @_;
208            $self->_add_something( qr{\.js$}, qw{script text/javascript}, $js );
209    }
210    
211  our $reload_counter = 0;  our $reload_counter = 0;
212    
213    
# Line 362  sub html_links { Line 365  sub html_links {
365          return $error;          return $error;
366  }  }
367    
368    sub html_self {
369            my $self = shift;
370            my $html = $self;
371            $html =~ s{([\w:]+)=}{<a target="$1" href="/$1" title="introspect $1">$1</a>=}gsm;
372            return $html;
373    }
374    
375  =head2 error  =head2 error
376    
377  This method will return error to browser and backtrace unless  This method will return error to browser and backtrace unless
# Line 374  sub error { Line 384  sub error {
384          my $error = join(" ", @_);          my $error = join(" ", @_);
385    
386          my $fatal = '';          my $fatal = '';
387            my $backtrace = '';
388    
389          if ( $error !~ m{\n$} ) {          if ( $error !~ m{\n$} ) {
390                  if ( my @backtrace = $self->backtrace ) {                  if ( my @backtrace = $self->backtrace ) {
391                          $error .= "\n\t" . join( "\n\t", @backtrace );                          $backtrace =
392                                      "\n" . $self->html_self . "->error backtrace\n\t"
393                                    . $self->html_links( join( "\n\t", @backtrace ) )
394                                    ;
395                          $fatal = qq| frey-fatal|;                          $fatal = qq| frey-fatal|;
396                  }                  }
397          }          }
398    
399          warn "ERROR: $error\n";          warn "ERROR: $error\n";
400          $self->add_icon('error');          $self->add_icon('error');
401          return          $error = $self->html_links( $error );
402                  qq|<pre class="frey-error$fatal">|          return qq|<pre class="frey-error$fatal">$error $backtrace</pre>| ;
                 . $self->html_links( $error ) .  
                 qq|</pre>|  
                 ;  
403  }  }
404    
405  =head1 Status line  =head1 Status line
# Line 667  sub backtrace { Line 678  sub backtrace {
678          my ($self) = @_;          my ($self) = @_;
679    
680          my @backtrace;          my @backtrace;
681          foreach ( 0 .. 5 ) {          foreach ( 1 .. 5 ) { # 0 = backtrace
682                  my (                  my (
683                          $package,$path,$line                          $package,$path,$line
684                          # subroutine hasargs                          # subroutine hasargs

Legend:
Removed from v.835  
changed lines
  Added in v.838

  ViewVC Help
Powered by ViewVC 1.1.26