[Jifty-commit] jifty branch, master, updated. eb18619a80ed389b9cb67fc6901d0b1cefdee384
Jifty commits
jifty-commit at lists.jifty.org
Tue Mar 30 20:57:07 EDT 2010
The branch, master has been updated
via eb18619a80ed389b9cb67fc6901d0b1cefdee384 (commit)
from 79fa76f9ddc7130ad7dd68d9023d0c075763670b (commit)
Summary of changes:
lib/Jifty/Plugin/CompressedCSSandJS.pm | 65 +++++++++++++++++++------------
1 files changed, 40 insertions(+), 25 deletions(-)
- Log -----------------------------------------------------------------
commit eb18619a80ed389b9cb67fc6901d0b1cefdee384
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Mar 30 20:57:06 2010 -0400
Factor out javascript compression from the caching
diff --git a/lib/Jifty/Plugin/CompressedCSSandJS.pm b/lib/Jifty/Plugin/CompressedCSSandJS.pm
index e4120bf..9bdf414 100644
--- a/lib/Jifty/Plugin/CompressedCSSandJS.pm
+++ b/lib/Jifty/Plugin/CompressedCSSandJS.pm
@@ -179,38 +179,53 @@ sub _generate_javascript {
my $self = shift;
return if Jifty::CAS->key('ccjs', 'js-all') && !Jifty->config->framework('DevelMode');
+
+ my $js = $self->_generate_javascript_nocache;
+
+ Jifty::CAS->publish( 'ccjs', 'js-all', $js,
+ { content_type => 'application/x-javascript', time => time() } );
+}
+
+=head3 _generate_javascript_nocache
+
+Generates compressed javascript, ignoring the cache completely.
+
+=cut
+
+sub _generate_javascript_nocache {
+ my $self = shift;
$self->log->debug("Generating JS...");
# for the file cascading logic
- my $static_handler = Jifty->handler->view('Jifty::View::Static::Handler');
- my $js = "";
-
- for my $file ( @{ Jifty::Web->javascript_libs } ) {
- next if $self->_js_is_skipped($file);
- my $include = $static_handler->file_path( File::Spec->catdir( 'js', $file ) );
-
- if ( defined $include ) {
- my $fh;
-
- if ( open $fh, '<', $include ) {
- local $_;
- $js .= "/* Including '$file' */\n\n";
- $js .= $_ while <$fh>;
- $js .= "\n/* End of '$file' */\n\n";
- } else {
- $js .= "\n/* Unable to open '$file': $! */\n";
- }
+ my $static_handler = Jifty->handler->view('Jifty::View::Static::Handler');
+ my $js = "";
+
+ for my $file ( @{ Jifty::Web->javascript_libs } ) {
+ next if $self->_js_is_skipped($file);
+ my $include = $static_handler->file_path( File::Spec->catdir( 'js', $file ) );
+
+ if ( defined $include ) {
+ my $fh;
+
+ if ( open $fh, '<', $include ) {
+ local $_;
+ $js .= "/* Including '$file' */\n\n";
+ $js .= $_ while <$fh>;
+ $js .= "\n/* End of '$file' */\n\n";
} else {
- $js .= "\n/* Unable to find '$file' */\n";
+ $js .= "\n/* Unable to open '$file': $! */\n";
}
+ } else {
+ $js .= "\n/* Unable to find '$file' */\n";
}
- if ($self->jsmin) {
- eval { $self->minify_js(\$js) };
- $self->log->error("Unable to run jsmin: $@") if $@;
- }
+ }
- Jifty::CAS->publish( 'ccjs', 'js-all', $js,
- { content_type => 'application/x-javascript', time => time() } );
+ if ($self->jsmin) {
+ eval { $self->minify_js(\$js) };
+ $self->log->error("Unable to run jsmin: $@") if $@;
+ }
+
+ return $js;
}
=head2 minify_js \$js
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list