[Rt-commit] rt branch, 4.4/minify-css-js, created. rt-4.2.3-21-gee864db

Wallace Reis wreis at bestpractical.com
Fri Feb 21 13:22:30 EST 2014


The branch, 4.4/minify-css-js has been created
        at  ee864dbc0b32b58b6ec7e3e9587196dcfb8c28d6 (commit)

- Log -----------------------------------------------------------------
commit 49fe9206662a6f54c4bcc56268996f8f15573eeb
Author: Wallace Reis <wreis at bestpractical.com>
Date:   Fri Feb 7 04:01:38 2014 -0800

    Minify CSS
    
    Saved around 20KB (22% reduction).

diff --git a/lib/RT/Squish/CSS.pm b/lib/RT/Squish/CSS.pm
index 5837379..ec5c8ec 100644
--- a/lib/RT/Squish/CSS.pm
+++ b/lib/RT/Squish/CSS.pm
@@ -64,6 +64,8 @@ use warnings;
 
 package RT::Squish::CSS;
 use base 'RT::Squish', 'CSS::Squish';
+use CSS::Minifier::XS ();
+
 __PACKAGE__->mk_accessors(qw/Style/);
 
 =head2 Squish
@@ -75,12 +77,18 @@ use CSS::Squish to squish css
 sub Squish {
     my $self = shift;
     my $style = $self->Style;
-    return $self->concatenate( "$style/main.css", RT->Config->Get('CSSFiles') );
+    return $self->Filter(
+      $self->concatenate( "$style/main.css", RT->Config->Get('CSSFiles') )
+    );
 }
 
 sub roots {
     map { "$_/css" } RT::Interface::Web->StaticRoots
 }
 
-1;
+sub Filter {
+    my ( $self, $content ) = @_;
+    return CSS::Minifier::XS::minify($content);
+}
 
+1;
diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in
index f852cbb..28398fe 100644
--- a/sbin/rt-test-dependencies.in
+++ b/sbin/rt-test-dependencies.in
@@ -181,6 +181,7 @@ CGI::Emulate::PSGI
 CGI::PSGI 0.12
 Class::Accessor 0.34
 Crypt::Eksblowfish
+CSS::Minifier::XS
 CSS::Squish 0.06
 Data::GUID
 Date::Extract 0.02
diff --git a/t/web/squish.t b/t/web/squish.t
index 9d1c01b..80a3239 100644
--- a/t/web/squish.t
+++ b/t/web/squish.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 use RT;
-use RT::Test tests => 26;
+use RT::Test tests => undef;
 
 RT->Config->Set( DevelMode            => 0 );
 RT->Config->Set( WebDefaultStylesheet => 'aileron' );
@@ -14,9 +14,8 @@ diag "test squished files with devel mode disabled";
 
 $m->follow_link_ok( { url_regex => qr!aileron/squished-([a-f0-9]{32})\.css! },
     'follow squished css' );
-$m->content_like( qr!/\*\* End of .*?.css \*/!, 'squished css' );
-$m->content_lacks( 'counteract the titlebox',
-    'no mobile.css by default' );
+$m->content_like( qr/body\{font.*table\{font/, 'squished css' );
+$m->content_lacks( 'a#fullsite', 'no mobile.css by default' );
 
 $m->back;
 my ($js_link) =
@@ -36,9 +35,8 @@ RT->AddStyleSheets( 'mobile.css' );
 $m->login;
 $m->follow_link_ok( { url_regex => qr!aileron/squished-([a-f0-9]{32})\.css! },
     'follow squished css' );
-$m->content_like( qr!/\*\* End of .*?.css \*/!, 'squished css' );
-$m->content_contains( 'counteract the titlebox',
-    'has mobile.css' );
+$m->content_like( qr/body\{font.*table\{font/, 'squished css' );
+$m->content_contains( 'a#fullsite', 'has mobile.css' );
 
 $m->back;
 ($js_link) =
@@ -76,3 +74,4 @@ $m->content_contains('not-by-default.js', "found extra javascript resource");
 $m->content_contains('nottherebutwedontcare.css', "found extra css resource");
 $m->content_contains('jquery_noconflict.js', "found a default js resource");
 
+done_testing;

commit d8b915aefcf7feaa61c0d3ef81a9ae62d92e69e6
Author: Wallace Reis <wreis at bestpractical.com>
Date:   Fri Feb 7 08:48:54 2014 -0800

    Minify JS
    
    ...and remove the dep on jsmin.

diff --git a/.gitignore b/.gitignore
index 159f895..66988ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,9 +43,6 @@
 /config.status
 /config.log
 /config.pld
-/jsmin.c
-/jsmin
-/bin/jsmin
 /nytprof.out*
 /.prove
 *~
diff --git a/Makefile.in b/Makefile.in
index f9b6402..3f90def 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -540,44 +540,3 @@ vessel-import: build-snapshot
      --log-level=info \
      --skip cpan-capitalization,cpan-mod_perl,cpan-Encode,cpan-PPI,cpan-Test-Exception-LessClever,cpan-Test-Manifest,cpan-Test-Object,cpan-Test-Pod,cpan-Test-Requires,cpan-Test-SubCalls,cpan-Test-cpan-Tester,cpan-Test-Warn --skip-all-recommends
 	mv $(VESSEL)/scripts/RT/build  $(VESSEL)/scripts/RT/build.pl
-
-JSMIN_URL = http://download.bestpractical.com/mirror/jsmin-2013-03-29.c
-JSMIN_SHA = 67dc8d73a8878f88cdaeb1a86775872eae5c3077
-
-jsmin: jsmin-checkcc jsmin-fetch jsmin-verify jsmin-confirm jsmin-build jsmin-install
-	@echo ""
-	@echo "To configure RT to use jsmin, add the following line to $(DESTDIR)$(RT_ETC_PATH)/RT_SiteConfig.pm:"
-	@echo ""
-	@echo "    Set(\$$JSMinPath, '$(DESTDIR)$(RT_BIN_PATH)/jsmin');"
-	@echo ""
-
-jsmin-checkcc:
-	@[ -n "$(CC)" ] || (echo "You don't appear to have a C compiler, please set CC and re-run configure" && exit 1)
-
-jsmin-confirm:
-	@echo "jsmin is distributed under a slightly unusual license and can't be shipped"
-	@echo "with RT.  Before configuring RT to use jsmin, please read jsmin's license"
-	@echo "below:"
-	@echo ""
-	@$(PERL) -pe 'print && exit if /^\*\// or /^#include/' jsmin.c
-	@echo ""
-	@echo "Press Enter to accept the license, or Ctrl-C to stop now."
-	@$(PERL) -e '<STDIN>'
-
-jsmin-fetch:
-	@echo ""
-	@echo "Downloading jsmin.c from $(JSMIN_URL)"
-	@echo ""
-	@$(PERL) -MLWP::Simple -e 'exit not is_success(getstore("$(JSMIN_URL)", "jsmin.c"))' \
-		|| (echo "Failed to download $(JSMIN_URL)" && exit 1)
-
-jsmin-verify:
-	@$(PERL) -MDigest::SHA -e \
-		'exit not Digest::SHA->new(1)->addfile("jsmin.c")->hexdigest eq "$(JSMIN_SHA)"' \
-		|| (echo "Verification of jsmin.c failed! Possible man in the middle?" && exit 1)
-
-jsmin-build:
-	$(CC) -o jsmin jsmin.c
-
-jsmin-install:
-	$(INSTALL) -o $(BIN_OWNER) -g $(RTGROUP) -m 0755 "jsmin" "$(DESTDIR)$(RT_BIN_PATH)/"
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index fe95a75..d16d416 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -947,19 +947,6 @@ A list of additional JavaScript files to be included in head.
 
 Set(@JSFiles, qw//);
 
-=item C<$JSMinPath>
-
-Path to the jsmin binary; if specified, it will be used to minify
-C<JSFiles>.  The default, and the fallback if the binary cannot be
-found, is to simply concatenate the files.
-
-jsmin can be installed by running 'make jsmin' from the RT install
-directory, or from http://www.crockford.com/javascript/jsmin.html
-
-=cut
-
-# Set($JSMinPath, "/path/to/jsmin");
-
 =item C<@CSSFiles>
 
 A list of additional CSS files to be included in head.
diff --git a/lib/RT/Squish/JS.pm b/lib/RT/Squish/JS.pm
index 0c3bd3d..82b3f26 100644
--- a/lib/RT/Squish/JS.pm
+++ b/lib/RT/Squish/JS.pm
@@ -64,6 +64,7 @@ use warnings;
 
 package RT::Squish::JS;
 use base 'RT::Squish';
+use JavaScript::Minifier::XS ();
 
 =head2 Squish
 
@@ -91,38 +92,8 @@ sub Squish {
 }
 
 sub Filter {
-    my $self    = shift;
-    my $content = shift;
-
-    my $minified;
-    my $jsmin = RT->Config->Get('JSMinPath');
-    if ( $jsmin && -x $jsmin ) {
-        my $input = $content;
-        my ( $output, $error );
-
-        # If we're running under fastcgi, STDOUT and STDERR are tied
-        # filehandles, which cause IPC::Run3 to flip out.  Construct
-        # temporary, not-tied replacements for it to see instead.
-        my $stdout = IO::Handle->new;
-        $stdout->fdopen( 1, 'w' );
-        local *STDOUT = $stdout;
-        my $stderr = IO::Handle->new;
-        $stderr->fdopen( 2, 'w' );
-        local *STDERR = $stderr;
-
-        local $SIG{'CHLD'} = 'DEFAULT';
-        require IPC::Run3;
-        IPC::Run3::run3( [$jsmin], \$input, \$output, \$error );
-        if ( $? >> 8 ) {
-            $RT::Logger->warning("failed to jsmin: $error ");
-        }
-        else {
-            $content  = $output;
-            $minified = 1;
-        }
-    }
-
-    return $content;
+    my ( $self, $content ) = @_;
+    return JavaScript::Minifier::XS::minify($content);
 }
 
 1;
diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in
index 28398fe..f5938fb 100644
--- a/sbin/rt-test-dependencies.in
+++ b/sbin/rt-test-dependencies.in
@@ -214,6 +214,7 @@ HTML::RewriteAttributes 0.05
 HTML::Scrubber 0.08
 HTTP::Message 6.0
 IPC::Run3
+JavaScript::Minifier::XS
 JSON
 LWP::Simple
 List::MoreUtils
diff --git a/t/web/passthrough-jsmin b/t/web/passthrough-jsmin
deleted file mode 100755
index 41b0196..0000000
--- a/t/web/passthrough-jsmin
+++ /dev/null
@@ -1,4 +0,0 @@
-
-echo "// passthrough-jsmin added this";
-
-exec cat;
diff --git a/t/web/squish.t b/t/web/squish.t
index 80a3239..1b97cc4 100644
--- a/t/web/squish.t
+++ b/t/web/squish.t
@@ -47,14 +47,11 @@ $m->content_contains('jQuery.noConflict', "found default js content");
 RT::Test->stop_server;
 
 
-diag "Test with a trivial jsmin which is a pass-through";
-RT->Config->Set( 'JSMinPath' => RT::Test::get_abs_relocatable_dir("passthrough-jsmin"));
 ( $url, $m ) = RT::Test->started_ok;
 $m->login;
 ($js_link) =
   $m->content =~ m!src="([^"]+?squished-([a-f0-9]{32})\.js)"!;
 $m->get_ok( $url . $js_link, 'follow squished js' );
-$m->content_contains( 'passthrough-jsmin added this', "has passthrough-added content" );
 $m->content_contains( 'function just_testing', "has not-by-default.js" );
 $m->content_contains('jQuery.noConflict', "found default js content");
 RT::Test->stop_server;

commit ee864dbc0b32b58b6ec7e3e9587196dcfb8c28d6
Author: Wallace Reis <wreis at bestpractical.com>
Date:   Fri Feb 21 15:12:02 2014 -0300

    Create UPGRADING-4.4 document

diff --git a/docs/UPGRADING-4.4 b/docs/UPGRADING-4.4
new file mode 100644
index 0000000..85f2aa2
--- /dev/null
+++ b/docs/UPGRADING-4.4
@@ -0,0 +1,19 @@
+=head1 UPGRADING FROM RT 4.2.0 and greater
+
+The 4.4 release is a major upgrade and as such there are more changes
+than in a minor bugfix release (e.g., 4.2.2 to 4.2.3) and some of these
+changes are backward-incompatible. The following lists some of the notable
+changes, especially those that might require you to change a configuration
+option or other setting due to a change in RT. Read this section carefully
+before you upgrade and look for changes to features you currently use.
+
+=over
+
+=item *
+
+The support for C<jsmin> (via the C<$JSMinPath> configuration) has been
+removed in favor of a built-in solution.
+
+=back
+
+=cut

-----------------------------------------------------------------------


More information about the rt-commit mailing list