/[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 839 by dpavlin, Sun Dec 14 22:47:48 2008 UTC
# Line 174  sub add_head { Line 174  sub add_head {
174    
175  }  }
176    
177    sub _add_css_js {
178            my ( $self, $what, $content ) = @_;
179    
180            my $tag  = $what eq 'css' ? 'style'    : 'script';
181            my $type = $what eq 'css' ? 'text/css' : 'text/javascript';
182            my $head;
183    
184            my ( $package, $path, $line ) = caller(1);
185    
186            if ( $content =~ m{\.(js|css)} ) {
187                    $content = "/$content" if -e $content;
188                    if ( $what eq 'js' ) {
189                            $head = qq|
190                                    <$tag type="$type" src="$content">
191                                    /* via $package at $path line $line */
192                                    </$tag>
193                            |;
194                    } else {
195                            $head = qq|
196                                    <link rel="stylesheet" type="$type" href="$content">
197                                    <!-- via $package at $path line $line -->
198                            |;
199                    }
200            } else {
201                    $head = qq|
202                            <$tag type="$type">
203                            /* via $package at $path line $line */
204                            $content
205                            </$tag>
206                    |;
207            };
208            $self->add_head( $head );
209    }
210    
211  sub add_css {  sub add_css {
212          my ($self,$css) = @_;          my ($self,$css) = @_;
213          my ( $package, $path, $line ) = caller;          $self->_add_css_js( 'css', $css );
         $self->add_head( qq|  
         <style type="text/css">  
         /* via $package at $path line $line */  
         $css  
         </style>  
         | );  
214  }  }
215    
216  sub add_js {  sub add_js {
217          my ($self,$js) = @_;          my ($self,$js) = @_;
218          my ( $package, $path, $line ) = caller;          $self->_add_css_js( 'js', $js );
   
         if ( $js =~ m{http.*\.js} ) {  
                 $self->add_head( qq|  
                         <script type="text/javascript" src="$js">  
                         /* via $package at $path line $line */  
                         </script>  
                 |);  
         } else {  
                 $self->add_head( qq|  
                         <script type="text/javascript">  
                         /* via $package at $path line $line */  
                         $js  
                         </script>  
                 | );  
         };  
219  }  }
220    
221  our $reload_counter = 0;  our $reload_counter = 0;

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

  ViewVC Help
Powered by ViewVC 1.1.26