[Jifty-commit] r1786 - in jifty/trunk: . lib/Jifty/View/Mason share/web/templates/__jifty/css share/web/templates/__jifty/js

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed Aug 9 18:34:25 EDT 2006


Author: clkao
Date: Wed Aug  9 18:34:15 2006
New Revision: 1786

Modified:
   jifty/trunk/Makefile.PL
   jifty/trunk/lib/Jifty/View/Mason/Handler.pm
   jifty/trunk/share/web/templates/__jifty/css/dhandler
   jifty/trunk/share/web/templates/__jifty/js/dhandler
   jifty/trunk/t/TestApp/t/10-compress.t

Log:
Revert my gzip layer changes, and leave the tests.


Modified: jifty/trunk/Makefile.PL
==============================================================================
--- jifty/trunk/Makefile.PL	(original)
+++ jifty/trunk/Makefile.PL	Wed Aug  9 18:34:15 2006
@@ -52,7 +52,6 @@
 requires('Object::Declare' => '0.13');
 requires('PAR::Dist::FromCPAN');
 requires('Params::Validate');
-requires('PerlIO::gzip');
 requires('Pod::Simple'); #Pod::Simple::Text
 requires('Scalar::Defer' => '0.06');
 requires('String::Koremutake');

Modified: jifty/trunk/lib/Jifty/View/Mason/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Mason/Handler.pm	(original)
+++ jifty/trunk/lib/Jifty/View/Mason/Handler.pm	Wed Aug  9 18:34:15 2006
@@ -78,24 +78,20 @@
     my $m = HTML::Mason::Request->instance;
     my $r = Jifty->handler->apache;
 
-    unless ($r->http_header_sent or not $m->auto_send_headers) {
-	my $want_gzip = 0;
+    $r->content_type || $r->content_type('text/html; charset=utf-8'); # Set up a default
 
-	if (Jifty::View::Static::Handler->client_accepts_gzipped_content) {
-	    ++$want_gzip;
-	    $r->header_out( "Content-Encoding" => "gzip" );
+    if ($r->content_type =~ /charset=([\w-]+)$/ ) {
+        my $enc = $1;
+	if (lc($enc) =~ /utf-?8/) {
+            binmode *STDOUT, ":utf8";
 	}
-
-	my $enc_layer;
-	$r->content_type || $r->content_type('text/html; charset=utf-8'); # Set up a default
-	if ($r->content_type =~ /charset=([\w-]+)$/ ) {
-	    $enc_layer = lc($1) =~ /utf-?8/ ? ':utf8' : ":encoding($1)"; 
+	else {
+            binmode *STDOUT, ":encoding($enc)";
 	}
+    }
 
+    unless ($r->http_header_sent or not $m->auto_send_headers) {
         $r->send_http_header();
-
-	binmode *STDOUT, ":gzip(lazy)" if $want_gzip;
-	binmode *STDOUT, $enc_layer if $enc_layer;
     }
 
     # We could perhaps install a new, faster out_method here that

Modified: jifty/trunk/share/web/templates/__jifty/css/dhandler
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/css/dhandler	(original)
+++ jifty/trunk/share/web/templates/__jifty/css/dhandler	Wed Aug  9 18:34:15 2006
@@ -20,8 +20,20 @@
 $r->content_type("text/css");
 $r->header_out( 'Expires' => HTTP::Date::time2str(time + 31536000) );
 
-Jifty->log->debug("Sending squished CSS");
-print Jifty->web->cached_css;
+# XXX TODO: If we start caching the squished CSS in a file somewhere, we
+# can have the static handler serve it, which would take care of gzipping
+# for us.
+use Compress::Zlib qw();
 
+if ( Jifty::View::Static::Handler->client_accepts_gzipped_content ) {
+    Jifty->log->debug("Sending gzipped squished CSS");
+    $r->header_out( "Content-Encoding" => "gzip" );
+    binmode STDOUT;
+    print Compress::Zlib::memGzip( Jifty->web->cached_css );
+}
+else {
+    Jifty->log->debug("Sending squished CSS");
+    print Jifty->web->cached_css;
+}
 return;
 </%init>

Modified: jifty/trunk/share/web/templates/__jifty/js/dhandler
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/js/dhandler	(original)
+++ jifty/trunk/share/web/templates/__jifty/js/dhandler	Wed Aug  9 18:34:15 2006
@@ -20,8 +20,20 @@
 $r->content_type("application/x-javascript");
 $r->header_out( 'Expires' => HTTP::Date::time2str(time + 31536000) );
 
-Jifty->log->debug("Sending squished JS");
-print Jifty->web->cached_javascript;
+# XXX TODO: If we start caching the squished JS in a file somewhere, we
+# can have the static handler serve it, which would take care of gzipping
+# for us.
+use Compress::Zlib qw();
 
+if ( Jifty::View::Static::Handler->client_accepts_gzipped_content ) {
+    Jifty->log->debug("Sending gzipped squished JS");
+    $r->header_out( "Content-Encoding" => "gzip" );
+    binmode STDOUT;
+    print Compress::Zlib::memGzip( Jifty->web->cached_javascript );
+}
+else {
+    Jifty->log->debug("Sending squished JS");
+    print Jifty->web->cached_javascript;
+}
 return;
 </%init>

Modified: jifty/trunk/t/TestApp/t/10-compress.t
==============================================================================
--- jifty/trunk/t/TestApp/t/10-compress.t	(original)
+++ jifty/trunk/t/TestApp/t/10-compress.t	Wed Aug  9 18:34:15 2006
@@ -24,8 +24,11 @@
 my $expected = $mech->response->content;
 like($expected, qr/Jifty Test Application/);
 
+SKIP: {
+skip "blah", 2;
 my $request = HTTP::Request->new( GET => "$URL/", ['Accept-Encoding' => 'gzip'] );
 my $response = $mech->request( $request );
 is($response->header('Content-Encoding'), 'gzip');
 # blah, can't check if this is same as expected because there are continuation serials.
 like(Compress::Zlib::memGunzip($response->content), qr/Jifty Test Application/);
+}


More information about the Jifty-commit mailing list