174 |
|
|
175 |
} |
} |
176 |
|
|
177 |
sub _add_something { |
sub _add_css_js { |
178 |
my ( $self, $regex, $tag, $type, $content ) = @_; |
my ( $self, $what, $content ) = @_; |
179 |
|
|
180 |
my ( $package, $path, $line ) = caller(1); |
my $tag = $what eq 'css' ? 'style' : 'script'; |
181 |
|
my $type = $what eq 'css' ? 'text/css' : 'text/javascript'; |
182 |
|
my $head; |
183 |
|
|
184 |
warn "# $regex $tag $type $content caller $package $path $line"; |
my ( $package, $path, $line ) = caller(1); |
185 |
|
|
186 |
if ( $content =~ $regex ) { |
if ( $content =~ m{\.(js|css)} ) { |
187 |
$content = "/$content" if -e $content; |
$content = "/$content" if -e $content; |
188 |
$self->add_head( strip ( qq| |
if ( $what eq 'js' ) { |
189 |
<$tag type="$type" src="$content"> |
$head = qq| |
190 |
/* via $package at $path line $line */ |
<$tag type="$type" src="$content"> |
191 |
</$tag> |
/* 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 { |
} else { |
201 |
$self->add_head(qq| |
$head = qq| |
202 |
<$tag type="$type"> |
<$tag type="$type"> |
203 |
/* via $package at $path line $line */ |
/* via $package at $path line $line */ |
204 |
$content |
$content |
205 |
</$tag> |
</$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 |
$self->_add_something( qr{\.css$}, qw{style text/css}, $css ); |
$self->_add_css_js( 'css', $css ); |
214 |
} |
} |
215 |
|
|
216 |
sub add_js { |
sub add_js { |
217 |
my ($self,$js) = @_; |
my ($self,$js) = @_; |
218 |
$self->_add_something( qr{\.js$}, qw{script text/javascript}, $js ); |
$self->_add_css_js( 'js', $js ); |
219 |
} |
} |
220 |
|
|
221 |
our $reload_counter = 0; |
our $reload_counter = 0; |