/[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 837 by dpavlin, Sun Dec 14 15:13:55 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    

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

  ViewVC Help
Powered by ViewVC 1.1.26