Apache2-Filter-Minifier-CSS

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    - use CSS::Minifier::XS if available; its -MUCH- faster
    - new "CssMinifier" PerlVar, to let you specify which minifier package or
      function to use (otherwise we try C:M:XS first, falling back to C:M)

1.03    Fri Sep 28 11:09 PDT 2007
    - rewrote Build.PL/Makefile.PL so they now check if you've got Apache::Test
      installed -at-configuration-time-.  if not, the build is abortted.  One
      day, CPAN(PLUS) et al. will support "configure_requires", but until then
      we've got to check for this ourselves.
    - fixed Content-Type filtering so that it now properly handles HTTP headers
      that have additional attributes (e.g. "charset=...")

1.02    Tue Sep 25 23:33 PDT 2007
    - added Makefile.PL, so CPANPLUS testers stop failing tests because they
      don't have Module::Build installed

1.01    Fri Sep 21 13:39 PDT 2007
    - added explicit dependency on MP2
    - updated test requirements to "need_*" instead of "have_*"

1.00    Thu Sep 20 16:47 PDT 2007

t/MY/CharsetHandler.pm  view on Meta::CPAN

use warnings;
use Apache2::RequestIO qw();
use Apache2::RequestRec qw();
use Apache2::RequestUtil qw();
use Apache2::Const -compile => qw(OK);
use File::Spec::Functions qw(catfile);
use File::Slurp qw(slurp);

sub handler {
    my $r = shift;
    $r->content_type('text/css; charset=iso-8859-1');
    $r->print( slurp(catfile($r->document_root,'test.css')) );
    return Apache2::Const::OK;
}

1;

t/conf/extra.conf.in  view on Meta::CPAN

</Location>

<Location /mimetypes/multiple>
    SetHandler              modperl
    PerlResponseHandler     MY::PlainHandler
    PerlOutputFilterHandler Apache2::Filter::Minifier::CSS
    PerlAddVar              CssMimeType application/octet-stream
    PerlAddVar              CssMimeType text/plain
</Location>

<Location /content-type/charset>
    SetHandler              modperl
    PerlResponseHandler     MY::CharsetHandler
    PerlOutputFilterHandler Apache2::Filter::Minifier::CSS
</Location>

<Location /content-type/missing>
    SetHandler              modperl
    PerlResponseHandler     MY::NoCTypeHandler
    PerlOutputFilterHandler Apache2::Filter::Minifier::CSS
</Location>

t/content-type.t  view on Meta::CPAN

use warnings FATAL => 'all';
use if $ENV{AUTOMATED_TESTING}, 'Test::DiagINC'; use Apache::Test;
use Apache::TestRequest;
use Apache::TestUtil qw(t_cmp);
use lib 't';
use File::Slurp qw(slurp);

# Test "Content-Type" headers
plan tests => 2, need_lwp;

# "Content-Type" with additional attributes (e.g. "charset")
charset_minified: {
    my $body = GET_BODY '/content-type/charset';
    my $min  = slurp( 't/htdocs/minified.txt' );
    chomp($min);

    ok( t_cmp($body, $min) );
}

# Missing "Content-Type" header; should decline processing and we get the
# un-minified version.
content_type_missing: {
    my $res  = GET '/content-type/missing';



( run in 1.694 second using v1.01-cache-2.11-cpan-39bf76dae61 )