CSS-Compressor-0.02/ 0000755 0000765 0000024 00000000000 11772667542 013246 5 ustar simon staff CSS-Compressor-0.02/Compressor.pm 0000644 0000765 0000024 00000023652 11772667425 015750 0 ustar simon staff package CSS::Compressor;
use strict;
use warnings;
use Exporter qw( import );
our @EXPORT_OK = qw( css_compress );
our $VERSION = '0.02';
our $MARKER;
# take package name, replace double colons with underscore and use that as
# marker for search and replace operations
BEGIN {
$MARKER = uc __PACKAGE__;
$MARKER =~ tr!:!_!s;
}
# build optimized regular expression variables ( foo -> [Ff][Oo][Oo] )
my (
$RE_BACKGROUND_POSITION,
$RE_TRANSFORM_ORIGIN_MOZ,
$RE_TRANSFORM_ORIGIN_MS,
$RE_TRANSFORM_ORIGIN_O,
$RE_TRANSFORM_ORIGIN_WEBKIT,
$RE_TRANSFORM_ORIGIN,
$RE_BORDER,
$RE_BORDER_TOP,
$RE_BORDER_RIGHT,
$RE_BORDER_BOTTOM,
$RE_BORDER_LEFT,
$RE_OUTLINE,
$RE_BACKGROUND,
$RE_ALPHA_FILTER,
) = map +(
join '' => map m![a-zA-Z]!
? '['.ucfirst($_).lc($_).']'
: '\\'.$_,
split m//
) => qw[
background-position
moz-transform-origin
ms-transform-origin
o-transform-origin
webkit-transform-origin
transform-origin
border
border-top
border-right
border-bottom
border-right
outline
background
progid:DXImageTransform.Microsoft.Alpha(Opacity=
];
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# compress
#
# IN: 1 uncompressed CSS
# OUT: 1 compressed CSS
sub css_compress {
my ( $css ) = @_;
my @comments,
my @tokens;
# collect all comment blocks...
$css =~ s! /\* (.*?) \*/
! '/*___'.$MARKER.'_PRESERVE_CANDIDATE_COMMENT_'.
( -1 + push @comments => $1 ).'___*/'
!sogex;
# preserve strings so their content doesn't get accidentally minified
$css =~ s! " ( [^"\\]*(?:\\.[^"\\]*)* ) " !
$_ = $1,
# maybe the string contains a comment-like substring?
# one, maybe more? put'em back then
s/___${MARKER}_PRESERVE_CANDIDATE_COMMENT_([0-9]+)___/$comments[$1]/go,
# minify alpha opacity in filter strings
s/$RE_ALPHA_FILTER/alpha(opacity=/go,
'"___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => $_).'___"'
!sgxe;
$css =~ s! ' ( [^'\\]*(?:\\.[^'\\]*)* ) ' !
$_ = $1,
s/___${MARKER}_PRESERVE_CANDIDATE_COMMENT_([0-9]+)___/$comments[$1]/go,
s/$RE_ALPHA_FILTER/alpha(opacity=/go,
'\'___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => $_).'___\''
!sgxe;
# strings are safe, now wrestle the comments
# ! in the first position of the comment means preserve
# so push to the preserved tokens while stripping the !
0 == index $_->[1] => '!'
and
$css =~ s!___${MARKER}_PRESERVE_CANDIDATE_COMMENT_$_->[0]___!
'___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => $_->[1]).'___'!e
# keep empty comments after child selectors (IE7 hack)
# e.g. html >/**/ body
or 0 == length $_->[1]
and
$css =~ s!>/\*___${MARKER}_PRESERVE_CANDIDATE_COMMENT_$_->[0]___!
'>/*___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => '').'___'!e
# \ in the last position looks like hack for Mac/IE5
# shorten that to /*\*/ and the next one to /**/
or '\\' eq substr $_->[1] => -1
and
$css =~ s!___${MARKER}_PRESERVE_CANDIDATE_COMMENT_$_->[0]___!
'___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => '\\').'___'!e &&
# attention: inline modification
++$_->[0] &&
$css =~ s!___${MARKER}_PRESERVE_CANDIDATE_COMMENT_$_->[0]___!
'___'.$MARKER.'_PRESERVED_TOKEN_'.(-1+push @tokens => '').'___'!e
for map +[ $_, $comments[$_] ], 0..$#comments;
# in all other cases kill the comment
$css =~ s!/\*___${MARKER}_PRESERVE_CANDIDATE_COMMENT_([0-9]+)___\*/!!g;
# Normalize all whitespace strings to single spaces. Easier to work with that way.
$css =~ s!\s+! !g;
# From here on all white space is just space - no more multi line matches!
# Remove the spaces before the things that should not have spaces before them.
# But, be careful not to turn "p :link {...}" into "p:link{...}"
# Swap out any pseudo-class colons with the token, and then swap back.
$css =~ s! ( \} [^{:]+ (?:: [^{:]+)+ \{ ) !
$_ = $1,
s/:/___${MARKER}_PSEUDOCLASSCOLON___/go,
s/\\([\\\$])/\\$1/g,
$_
!gxe;
$css =~ s! ( ^ [^{:]+ (?:: [^{:]+)+ \{ ) !
$_ = $1,
s/:/___${MARKER}_PSEUDOCLASSCOLON___/go,
s/\\([\\\$])/\\$1/g,
$_
!xe;
# Remove spaces before the things that should not have spaces before them.
$css =~ s/ +([!{};:>+()\],])/$1/g;
# bring back the colon
$css =~ s!___${MARKER}_PSEUDOCLASSCOLON___!:!go;
# retain space for special IE6 cases
$css =~ s!:first\-(line|letter)([{,])!:first-$1 $2!g;
# no space after the end of a preserved comment
$css =~ s!\*/ !*/!g;
# If there is a @charset, then only allow one, and push to the top of the file.
$css =~ s!^(.*)(\@charset "[^"]*";)!$2$1!g;
$css =~ s!^( *\@charset [^;]+; *)+!$1!g;
# Put the space back in some cases, to support stuff like
# @media screen and (-webkit-min-device-pixel-ratio:0){
$css =~ s! \b and \( !and (!gx;
# Remove the spaces after the things that should not have spaces after them.
$css =~ s/([!{},;:>+(\[]) +/$1/g;
# Replace 0.6 to .6, but only when preceded by :
$css =~ s!:0+\.([0-9]+)!:.$1!g;
# remove unnecessary semicolons
$css =~ s!;+\}!}!g;
# Replace 0(px,em,%) with 0
$css =~ s!([ :]0)(?:px|em|%|in|cm|mm|pc|pt|ex)!$1!g;
# Replace 0 0 0 0; with 0.
$css =~ s!:0(?: 0){0,3}(;|})!:0$1!g;
# Replace background-position:0; with background-position:0 0;
# same for transform-origin
$css =~ s! $RE_BACKGROUND_POSITION :0 ( [;}] ) !background-position:0 0$1!gox;
$css =~ s! $RE_TRANSFORM_ORIGIN_MOZ :0 ( [;}] ) !moz-transform-origin:0 0$1!gox;
$css =~ s! $RE_TRANSFORM_ORIGIN_MS :0 ( [;}] ) !ms-transform-origin:0 0$1!gox;
$css =~ s! $RE_TRANSFORM_ORIGIN_O :0 ( [;}] ) !o-transform-origin:0 0$1!gox;
$css =~ s! $RE_TRANSFORM_ORIGIN_WEBKIT :0 ( [;}] ) !webkit-transform-origin:0 0$1!gox;
$css =~ s! $RE_TRANSFORM_ORIGIN :0 ( [;}] ) !transform-origin:0 0$1!gox;
# Replace 0.6 to .6, but only when preceded by : or a white-space
$css =~ s! 0+\.([0-9]+)! .$1!g;
# Shorten colors from rgb(51,102,153) to #336699
# This makes it more likely that it'll get further compressed in the next step.
$css =~ s!rgb *\( *([0-9, ]+) *\)!
sprintf('#%02x%02x%02x',
split(m/ *, */, $1, 3) )
!ge;
# Shorten colors from #AABBCC to #ABC. Note that we want to make sure
# the color is not preceded by either ", " or =. Indeed, the property
# filter: chroma(color="#FFFFFF");
# would become
# filter: chroma(color="#FFF");
# which makes the filter break in IE.
# We also want to make sure we're only compressing #AABBCC patterns inside
# { }, not id selectors ( #FAABAC {} ).
# Further we want to avoid compressing invalid values (e.g. #AABBCCD to #ABCD).
$css =~ s!
(=[ ]*?["']?)?
\#
([0-9a-fA-F]) # a
([0-9a-fA-F]) # a
([0-9a-fA-F]) # b
([0-9a-fA-F]) # b
([0-9a-fA-F]) # c
([0-9a-fA-F]) # c
\b
([^{.])
!
( $1 || '' ) ne ''
# keep as compression will break filters
? $1.'#'.$2.$3.$4.$5.$6.$7.$8
# not a filter, safe to compress
: '#'.lc(
lc $2.$4.$6 eq lc $3.$5.$7
? $2.$4.$6
: $2.$3.$4.$5.$6.$7
).$8
!gex;
# border: none -> border:0
$css =~ s! $RE_BORDER :none ( [;}] ) !border:0$1!gox;
$css =~ s! $RE_BORDER_TOP :none ( [;}] ) !border-top:0$1!gox;
$css =~ s! $RE_BORDER_RIGHT :none ( [;}] ) !border-right:0$1!gox;
$css =~ s! $RE_BORDER_BOTTOM :none ( [;}] ) !border-bottom:0$1!gox;
$css =~ s! $RE_BORDER_LEFT :none ( [;}] ) !border-left:0$1!gox;
$css =~ s! $RE_OUTLINE :none ( [;}] ) !outline:0$1!gox;
$css =~ s! $RE_BACKGROUND :none ( [;}] ) !background:0$1!gox;
# shorter opacity IE filter
$css =~ s!$RE_ALPHA_FILTER!alpha(opacity=!go;
# Remove empty rules.
$css =~ s![^{}/;]+\{\}!!g;
# Replace multiple semi-colons in a row by a single one
# See SF bug #1980989
$css =~ s!;;+!;!g;
# restore preserved comments and strings
$css =~ s!___${MARKER}_PRESERVED_TOKEN_([0-9]+)___!$tokens[$1]!go;
# Trim the final string (for any leading or trailing white spaces)
$css =~ s!\A +!!;
$css =~ s! +\z!!;
$css;
}
1;
__END__
=head1 NAME
CSS::Compressor - Perl extension for CSS minification
=head1 SYNOPSIS
use CSS::Compressor qw( css_compress );
...
my $small = css_compress $css;
=head1 DESCRIPTION
This module is an implementation of the CSS parts of Yahoo! YUIcompressor in Perl.
It was needed to produce minified css on the fly using Perl based backend systems.
=head1 FUNCTIONS
=head2 css_compress( $source )
Takes the stylesheet source, minifies it and returns the result string.
=head1 SEE ALSO
=over 4
=item L
YUIcompressor project homepage
=item L
YUIcompressor source repository
=item L
an alternative, Perl-based CSS compressor
=back
=head1 ACKNOWLEDGMENT
This module was originally developed for Booking.com. With approval from
Booking.com, this module was generalized and put on CPAN, for which the author
would like to express his gratitude.
=head1 AUTHOR
Simon Bertrang, Ejanus@cpan.orgE
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2012 by Simon Bertrang
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.12.3 or,
at your option, any later version of Perl 5 you may have available.
=cut
# vim: ts=4 sw=4 et:
CSS-Compressor-0.02/Makefile.PL 0000644 0000765 0000024 00000000471 11772667402 015215 0 ustar simon staff
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'CSS::Compressor',
VERSION_FROM => 'Compressor.pm',
PREREQ_PM => {},
BUILD_REQUIRES => {
'Test::Differences' => 0,
},
ABSTRACT_FROM => 'Compressor.pm',
AUTHOR => 'Simon Bertrang ',
);
CSS-Compressor-0.02/MANIFEST 0000644 0000765 0000024 00000003500 11772667542 014375 0 ustar simon staff Compressor.pm
Makefile.PL
MANIFEST
README
t/load.t
t/simple.t
t/yui.t
t/yui/_munge.js
t/yui/_munge.js.min
t/yui/_string_combo.js
t/yui/_string_combo.js.min
t/yui/_syntax_error.js
t/yui/_syntax_error.js.min
t/yui/background-position.css
t/yui/background-position.css.min
t/yui/border-none.css
t/yui/border-none.css.min
t/yui/box-model-hack.css
t/yui/box-model-hack.css.min
t/yui/bug2527974.css
t/yui/bug2527974.css.min
t/yui/bug2527991.css
t/yui/bug2527991.css.min
t/yui/bug2527998.css
t/yui/bug2527998.css.min
t/yui/bug2528034.css
t/yui/bug2528034.css.min
t/yui/charset-media.css
t/yui/charset-media.css.min
t/yui/color.css
t/yui/color.css.min
t/yui/comment.css
t/yui/comment.css.min
t/yui/concat-charset.css
t/yui/concat-charset.css.min
t/yui/decimals.css
t/yui/decimals.css.min
t/yui/dollar-header.css
t/yui/dollar-header.css.min
t/yui/float.js
t/yui/float.js.min
t/yui/font-face.css
t/yui/font-face.css.min
t/yui/ie5mac.css
t/yui/ie5mac.css.min
t/yui/media-empty-class.css
t/yui/media-empty-class.css.min
t/yui/media-multi.css
t/yui/media-multi.css.min
t/yui/media-test.css
t/yui/media-test.css.min
t/yui/opacity-filter.css
t/yui/opacity-filter.css.min
t/yui/preserve-new-line.css
t/yui/preserve-new-line.css.min
t/yui/preserve-strings.css
t/yui/preserve-strings.css.min
t/yui/pseudo-first.css
t/yui/pseudo-first.css.min
t/yui/pseudo.css
t/yui/pseudo.css.min
t/yui/README
t/yui/special-comments.css
t/yui/special-comments.css.min
t/yui/star-underscore-hacks.css
t/yui/star-underscore-hacks.css.min
t/yui/string-in-comment.css
t/yui/string-in-comment.css.min
t/yui/suite.rhino
t/yui/suite.sh
t/yui/webkit-transform.css
t/yui/webkit-transform.css.min
t/yui/zeros.css
t/yui/zeros.css.min
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
CSS-Compressor-0.02/META.json 0000644 0000765 0000024 00000001506 11772667542 014671 0 ustar simon staff {
"abstract" : "Perl extension for CSS minification",
"author" : [
"Simon Bertrang "
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150",
"license" : [
"unknown"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "CSS-Compressor",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"Test::Differences" : 0
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : 0
}
},
"runtime" : {
"requires" : {}
}
},
"release_status" : "stable",
"version" : "0.02"
}
CSS-Compressor-0.02/META.yml 0000644 0000765 0000024 00000000744 11772667541 014523 0 ustar simon staff ---
abstract: 'Perl extension for CSS minification'
author:
- 'Simon Bertrang '
build_requires:
Test::Differences: 0
configure_requires:
ExtUtils::MakeMaker: 0
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: CSS-Compressor
no_index:
directory:
- t
- inc
requires: {}
version: 0.02
CSS-Compressor-0.02/README 0000644 0000765 0000024 00000002363 11770573551 014124 0 ustar simon staff NAME
CSS::Compressor - Perl extension for CSS minification
SYNOPSIS
use CSS::Compressor qw( css_compress );
...
my $small = css_compress $css;
DESCRIPTION
This module is an implementation of the CSS parts of Yahoo!
YUIcompressor in Perl. It was needed to produce minified css on the fly
using Perl based backend systems.
FUNCTIONS
css_compress( $source )
Takes the stylesheet source, minifies it and returns the result string.
SEE ALSO
YUIcompressor project homepage
YUIcompressor source repository
CSS::Packer
an alternative, Perl-based CSS compressor
ACKNOWLEDGMENT
This module was originally developed for Booking.com. With approval from
Booking.com, this module was generalized and put on CPAN, for which the
author would like to express his gratitude.
AUTHOR
Simon Bertrang,
COPYRIGHT AND LICENSE
Copyright (C) 2012 by Simon Bertrang
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.12.3 or, at
your option, any later version of Perl 5 you may have available.
CSS-Compressor-0.02/t/ 0000755 0000765 0000024 00000000000 11772667541 013510 5 ustar simon staff CSS-Compressor-0.02/t/load.t 0000644 0000765 0000024 00000000143 11770571452 014603 0 ustar simon staff
use Test::More
tests => 1;
BEGIN {
use_ok( 'CSS::Compressor' => qw( css_compress ) );
}
CSS-Compressor-0.02/t/simple.t 0000644 0000765 0000024 00000000353 11770571564 015164 0 ustar simon staff
use Test::More
tests => 2;
BEGIN {
use_ok('CSS::Compressor' => qw( css_compress ) );
}
my $result = css_compress(< 'some foo{color:red}' => 'match';
CSS-Compressor-0.02/t/yui/ 0000755 0000765 0000024 00000000000 11772667541 014316 5 ustar simon staff CSS-Compressor-0.02/t/yui/_munge.js 0000644 0000765 0000024 00000000206 11717316445 016115 0 ustar simon staff (function() {
var w = window;
w.hello = function(a, abc) {
"a:nomunge";
w.alert("Hello, " + a);
};
})();
CSS-Compressor-0.02/t/yui/_munge.js.min 0000644 0000765 0000024 00000000111 11720273444 016665 0 ustar simon staff (function(){var a=window;a.hello=function(a,b){a.alert("Hello, "+a)}})(); CSS-Compressor-0.02/t/yui/_string_combo.js 0000644 0000765 0000024 00000000070 11717316445 017466 0 ustar simon staff function test(){
var a = "a" +
"b" +
"c";
}
CSS-Compressor-0.02/t/yui/_string_combo.js.min 0000644 0000765 0000024 00000000035 11720273444 020244 0 ustar simon staff function test(){var b="abc"}; CSS-Compressor-0.02/t/yui/_syntax_error.js 0000644 0000765 0000024 00000002635 11717316445 017551 0 ustar simon staff
window.$ = $telerik.$;
$(document).ready(function() {
movePageElements();
var text = $('textarea').val();
if (text != "")
$('textarea').attr("style", "display: block;");
else
$('textarea').attr("style", "display: none;");
//cleanup
text = null;
});
function movePageElements() {
var num = null;
var pagenum = $(".pagecontrolscontainer");
if (pagenum.length > 0) {
var num = pagenum.attr("pagenumber");
if ((num > 5) && (num < 28)) {
var x = $('div#commentbutton');
$("div.buttonContainer").prepend(x);
}
else {
$('div#commentbutton').attr("style", "display: none;");
}
}
//Add in dropshadowing
if ((num > 5) && (num < 28)) {
var top = $('.dropshadow-top');
var middle = $('#dropshadow');
var bottom = $('.dropshadow-bottom');
$('#page').prepend(top);
$('#topcontainer').after(middle);
middle.append($('#topcontainer'));
middle.after(bottom);
}
//cleanup
num = null;
pagenum = null;
top = null;
middle = null;
bottom=null;
}
function expandCollapseDiv(id) {
$telerik.$(id).slideToggle("slow");
}
function expandCollapseHelp() {
$('.helpitems').slideToggle("slow");
//Add in dropshadowing
if ($('#helpcontainer').length) {
$('#help-dropshadow-bot').insertAfter('#helpcontainer');
$('#help-dropshadow-bot').removeAttr("style");
}
}
function expandCollapseComments() {
var style = $('textarea').attr("style");
if (style == "display: none;")
$('textarea').fadeIn().focus();
else
$('textarea').fadeOut();
//cleanup
style = null;
}
CSS-Compressor-0.02/t/yui/_syntax_error.js.min 0000644 0000765 0000024 00000002132 11720273444 020316 0 ustar simon staff window.$=$telerik.$;$(document).ready(function(){movePageElements();var a=$("textarea").val();if(a!=""){$("textarea").attr("style","display: block;")}else{$("textarea").attr("style","display: none;")}a=null});function movePageElements(){var e=null;var b=$(".pagecontrolscontainer");if(b.length>0){var e=b.attr("pagenumber");if((e>5)&&(e<28)){var a=$("div#commentbutton");$("div.buttonContainer").prepend(a)}else{$("div#commentbutton").attr("style","display: none;")}}if((e>5)&&(e<28)){var f=$(".dropshadow-top");var d=$("#dropshadow");var c=$(".dropshadow-bottom");$("#page").prepend(f);$("#topcontainer").after(d);d.append($("#topcontainer"));d.after(c)}e=null;b=null;f=null;d=null;c=null}function expandCollapseDiv(a){$telerik.$(a).slideToggle("slow")}function expandCollapseHelp(){$(".helpitems").slideToggle("slow");if($("#helpcontainer").length){$("#help-dropshadow-bot").insertAfter("#helpcontainer");$("#help-dropshadow-bot").removeAttr("style")}}function expandCollapseComments(){var a=$("textarea").attr("style");if(a=="display: none;"){$("textarea").fadeIn().focus()}else{$("textarea").fadeOut()}a=null}; CSS-Compressor-0.02/t/yui/background-position.css 0000644 0000765 0000024 00000000077 11720273444 021001 0 ustar simon staff a {background-position: 0 0 0 0;}
b {BACKGROUND-POSITION: 0 0;} CSS-Compressor-0.02/t/yui/background-position.css.min 0000644 0000765 0000024 00000000064 11720273444 021557 0 ustar simon staff a{background-position:0 0}b{background-position:0 0} CSS-Compressor-0.02/t/yui/border-none.css 0000644 0000765 0000024 00000000101 11720273444 017216 0 ustar simon staff a {
border: none;
}
b {BACKGROUND:none}
s {border-top: none;} CSS-Compressor-0.02/t/yui/border-none.css.min 0000644 0000765 0000024 00000000051 11720273444 020004 0 ustar simon staff a{border:0}b{background:0}s{border-top:0} CSS-Compressor-0.02/t/yui/box-model-hack.css 0000644 0000765 0000024 00000000176 11720273444 017612 0 ustar simon staff #elem {
width: 100px;
voice-family: "\"}\"";
voice-family:inherit;
width: 200px;
}
html>body #elem {
width: 200px;
}
CSS-Compressor-0.02/t/yui/box-model-hack.css.min 0000644 0000765 0000024 00000000144 11720273444 020367 0 ustar simon staff #elem{width:100px;voice-family:"\"}\"";voice-family:inherit;width:200px}html>body #elem{width:200px} CSS-Compressor-0.02/t/yui/bug2527974.css 0000644 0000765 0000024 00000000611 11720273444 016353 0 ustar simon staff /* this file contains no css, it exists purely to put the revision number into the
combined css before uploading it to SiteManager. The exclaimation at the start
of the comment informs yuicompressor not to strip the comment out */
/*! $LastChangedRevision: 81 $ $LastChangedDate: 2009-05-27 17:41:02 +0100 (Wed, 27 May 2009) $ */
body {
yo: cats;
}
ul[id$=foo] label:hover {yo: yo;} CSS-Compressor-0.02/t/yui/bug2527974.css.min 0000644 0000765 0000024 00000000215 11720273444 017135 0 ustar simon staff /*! $LastChangedRevision: 81 $ $LastChangedDate: 2009-05-27 17:41:02 +0100 (Wed, 27 May 2009) $ */body{yo:cats}ul[id$=foo] label:hover{yo:yo} CSS-Compressor-0.02/t/yui/bug2527991.css 0000644 0000765 0000024 00000000371 11720273444 016355 0 ustar simon staff @media screen and/*!YUI-Compresser */(-webkit-min-device-pixel-ratio:0) {
a{
b: 1;
}
}
@media screen and/*! */ /*! */(-webkit-min-device-pixel-ratio:0) {
a{
b: 1;
}
}
@media -webkit-min-device-pixel-ratio:0 {
a{
b: 1;
}
} CSS-Compressor-0.02/t/yui/bug2527991.css.min 0000644 0000765 0000024 00000000305 11720273444 017134 0 ustar simon staff @media screen and/*!YUI-Compresser */(-webkit-min-device-pixel-ratio:0){a{b:1}}@media screen and/*! *//*! */(-webkit-min-device-pixel-ratio:0){a{b:1}}@media -webkit-min-device-pixel-ratio:0{a{b:1}} CSS-Compressor-0.02/t/yui/bug2527998.css 0000644 0000765 0000024 00000000031 11720273444 016355 0 ustar simon staff /*! special */
body {
}
CSS-Compressor-0.02/t/yui/bug2527998.css.min 0000644 0000765 0000024 00000000016 11720273444 017142 0 ustar simon staff /*! special */ CSS-Compressor-0.02/t/yui/bug2528034.css 0000644 0000765 0000024 00000000126 11720273444 016340 0 ustar simon staff a[href$="/test/"] span:first-child { b:1; }
a[href$="/test/"] span:first-child { }
CSS-Compressor-0.02/t/yui/bug2528034.css.min 0000644 0000765 0000024 00000000047 11720273444 017124 0 ustar simon staff a[href$="/test/"] span:first-child{b:1} CSS-Compressor-0.02/t/yui/charset-media.css 0000644 0000765 0000024 00000000134 11720273444 017520 0 ustar simon staff /* re: 2495387 */
@charset 'utf-8';
@media all {
body {
}
body {
background-color: gold;
}
} CSS-Compressor-0.02/t/yui/charset-media.css.min 0000644 0000765 0000024 00000000070 11720273444 020301 0 ustar simon staff @charset 'utf-8';@media all{body{background-color:gold}} CSS-Compressor-0.02/t/yui/color.css 0000644 0000765 0000024 00000001542 11720273444 016134 0 ustar simon staff .color {
me: rgb(123, 123, 123);
impressed: #FfEedD;
again: #ABCDEF;
andagain:#aa66cc;
background-color:#aa66ccc;
filter: chroma(color="#FFFFFF");
background: none repeat scroll 0 0 rgb(255, 0,0);
alpha: rgba(1, 2, 3, 4);
color:#1122aa
}
#AABBCC {
background-color:#ffee11;
filter: chroma(color = #FFFFFF );
color:#441122;
foo:#00fF11 #ABC #AABbCc #123344;
border-color:#aa66ccC
}
.foo #AABBCC {
background-color:#fFEe11;
color:#441122;
border-color:#AbC;
filter: chroma(color= #FFFFFF)
}
.bar, #AABBCC {
background-color:#FFee11;
border-color:#00fF11 #ABCDEF;
filter: chroma(color=#11FFFFFF);
color:#441122;
}
.foo, #AABBCC.foobar {
background-color:#ffee11;
border-color:#00fF11 #ABCDEF #AABbCc;
color:#441122;
}
@media screen {
.bar, #AABBCC {
background-color:#ffEE11;
color:#441122
}
}
CSS-Compressor-0.02/t/yui/color.css.min 0000644 0000765 0000024 00000001213 11720273500 016702 0 ustar simon staff .color{me:#7b7b7b;impressed:#fed;again:#abcdef;andagain:#a6c;background-color:#aa66ccc;filter:chroma(color="#FFFFFF");background:none repeat scroll 0 0 #f00;alpha:rgba(1,2,3,4);color:#12a}#AABBCC{background-color:#fe1;filter:chroma(color = #FFFFFF);color:#412;foo:#0f1 #ABC #abc #123344;border-color:#aa66ccC}.foo #AABBCC{background-color:#fe1;color:#412;border-color:#AbC;filter:chroma(color= #FFFFFF)}.bar,#AABBCC{background-color:#fe1;border-color:#0f1 #abcdef;filter:chroma(color=#11FFFFFF);color:#412}.foo,#AABBCC.foobar{background-color:#fe1;border-color:#0f1 #abcdef #abc;color:#412}@media screen{.bar,#AABBCC{background-color:#fe1;color:#412}} CSS-Compressor-0.02/t/yui/comment.css 0000644 0000765 0000024 00000000050 11720273444 016451 0 ustar simon staff html >/**/ body p {
color: blue;
}
CSS-Compressor-0.02/t/yui/comment.css.min 0000644 0000765 0000024 00000000033 11720273444 017234 0 ustar simon staff html>/**/body p{color:blue} CSS-Compressor-0.02/t/yui/concat-charset.css 0000644 0000765 0000024 00000000545 11720273444 017716 0 ustar simon staff /* This is invalid CSS, but frequently happens as a result of concatenation. */
@charset "utf-8";
#foo {
border-width:1px;
}
/*
Note that this is erroneous!
The actual CSS file can only have a single charset.
However, this is the job of the author/application.
The compressor should not get involved.
*/
@charset "another one";
#bar {
border-width:10px;
} CSS-Compressor-0.02/t/yui/concat-charset.css.min 0000644 0000765 0000024 00000000076 11720273444 020477 0 ustar simon staff @charset "utf-8";#foo{border-width:1px}#bar{border-width:10px} CSS-Compressor-0.02/t/yui/decimals.css 0000644 0000765 0000024 00000000066 11720273444 016577 0 ustar simon staff ::selection {
margin: 0.6px 0.333pt 1.2em 8.8cm;
}
CSS-Compressor-0.02/t/yui/decimals.css.min 0000644 0000765 0000024 00000000053 11720273444 017355 0 ustar simon staff ::selection{margin:.6px .333pt 1.2em 8.8cm} CSS-Compressor-0.02/t/yui/dollar-header.css 0000644 0000765 0000024 00000000127 11720273444 017517 0 ustar simon staff /*!
$Header: /temp/dirname/filename.css 3 2/02/08 3:37p JSmith $
*/
foo {
bar: baz
}
CSS-Compressor-0.02/t/yui/dollar-header.css.min 0000644 0000765 0000024 00000000117 11720273444 020300 0 ustar simon staff /*!
$Header: /temp/dirname/filename.css 3 2/02/08 3:37p JSmith $
*/foo{bar:baz} CSS-Compressor-0.02/t/yui/float.js 0000644 0000765 0000024 00000000067 11717316445 015755 0 ustar simon staff obj.css({"float": "left"});
obj.css({cssFloat:"left"}); CSS-Compressor-0.02/t/yui/float.js.min 0000644 0000765 0000024 00000000065 11720273444 016530 0 ustar simon staff obj.css({"float":"left"});obj.css({cssFloat:"left"}); CSS-Compressor-0.02/t/yui/font-face.css 0000644 0000765 0000024 00000000211 11720273444 016650 0 ustar simon staff @font-face {
font-family: 'gzipper';
src: url(yanone.eot);
src: local('gzipper'),
url(yanone.ttf) format('truetype');
}
CSS-Compressor-0.02/t/yui/font-face.css.min 0000644 0000765 0000024 00000000155 11720273444 017441 0 ustar simon staff @font-face{font-family:'gzipper';src:url(yanone.eot);src:local('gzipper'),url(yanone.ttf) format('truetype')} CSS-Compressor-0.02/t/yui/ie5mac.css 0000644 0000765 0000024 00000000143 11720273444 016155 0 ustar simon staff /* Ignore the next rule in IE mac \*/
.selector {
color: khaki;
}
/* Stop ignoring in IE mac */
CSS-Compressor-0.02/t/yui/ie5mac.css.min 0000644 0000765 0000024 00000000037 11720274061 016735 0 ustar simon staff /*\*/.selector{color:khaki}/**/ CSS-Compressor-0.02/t/yui/media-empty-class.css 0000644 0000765 0000024 00000000402 11720273444 020326 0 ustar simon staff /*! preserved */
emptiness {}
@import "another.css";
/* I'm empty - delete me */
empty { ;}
@media print {
.noprint { display: none; }
}
@media screen {
/* this rule should be removed, not simply minified.*/
.breakme {}
.printonly { display: none; }
} CSS-Compressor-0.02/t/yui/media-empty-class.css.min 0000644 0000765 0000024 00000000161 11720273444 021112 0 ustar simon staff /*! preserved */@import "another.css";@media print{.noprint{display:none}}@media screen{.printonly{display:none}} CSS-Compressor-0.02/t/yui/media-multi.css 0000644 0000765 0000024 00000000202 11720273444 017215 0 ustar simon staff @media only all and (max-width:50em), only all and (max-device-width:800px), only all and (max-width:780px) {
some-css : here
}
CSS-Compressor-0.02/t/yui/media-multi.css.min 0000644 0000765 0000024 00000000170 11720273444 020003 0 ustar simon staff @media only all and (max-width:50em),only all and (max-device-width:800px),only all and (max-width:780px){some-css:here} CSS-Compressor-0.02/t/yui/media-test.css 0000644 0000765 0000024 00000000112 11720273444 017042 0 ustar simon staff @media screen and (-webkit-min-device-pixel-ratio:0) {
some-css : here
} CSS-Compressor-0.02/t/yui/media-test.css.min 0000644 0000765 0000024 00000000103 11720273444 017624 0 ustar simon staff @media screen and (-webkit-min-device-pixel-ratio:0){some-css:here} CSS-Compressor-0.02/t/yui/opacity-filter.css 0000644 0000765 0000024 00000001266 11720273444 017754 0 ustar simon staff /* example from https://developer.mozilla.org/en/CSS/opacity */
pre { /* make the box translucent (80% opaque) */
border: solid red;
opacity: 0.8; /* Firefox, Safari(WebKit), Opera */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; /* IE 8 */
filter: PROGID:DXImageTransform.Microsoft.Alpha(Opacity=80); /* IE 4-7 */
zoom: 1; /* set "zoom", "width" or "height" to trigger "hasLayout" in IE 7 and lower */
}
/** and again */
code {
-ms-filter: "PROGID:DXImageTransform.Microsoft.Alpha(Opacity=80)"; /* IE 8 */
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80); /* IE 4-7 */
} CSS-Compressor-0.02/t/yui/opacity-filter.css.min 0000644 0000765 0000024 00000000234 11720273444 020530 0 ustar simon staff pre{border:solid red;opacity:.8;-ms-filter:"alpha(opacity=80)";filter:alpha(opacity=80);zoom:1}code{-ms-filter:"alpha(opacity=80)";filter:alpha(opacity=80)} CSS-Compressor-0.02/t/yui/preserve-new-line.css 0000644 0000765 0000024 00000000120 11720273444 020354 0 ustar simon staff #sel-o {
content: "on\"ce upon \
a time";
content: 'once upon \
a ti\'me';
} CSS-Compressor-0.02/t/yui/preserve-new-line.css.min 0000644 0000765 0000024 00000000105 11720273444 021141 0 ustar simon staff #sel-o{content:"on\"ce upon \
a time";content:'once upon \
a ti\'me'} CSS-Compressor-0.02/t/yui/preserve-strings.css 0000644 0000765 0000024 00000000300 11720273444 020327 0 ustar simon staff /* preserving strings */
.sele {
content: "\"keep \" me";
something: '\\\' . . ';
else: 'empty{}';
content: "/* test */"; /* <---- this is not a comment, should be be kept */
} CSS-Compressor-0.02/t/yui/preserve-strings.css.min 0000644 0000765 0000024 00000000137 11720273444 021121 0 ustar simon staff .sele{content:"\"keep \" me";something:'\\\' . . ';else:'empty{}';content:"/* test */"} CSS-Compressor-0.02/t/yui/pseudo-first.css 0000644 0000765 0000024 00000000463 11720273444 017443 0 ustar simon staff /*
because of IE6 first-letter and first-line
must be followed by a space
http://reference.sitepoint.com/css/pseudoelement-firstletter
Thanks: P.Sorokin comment at http://www.phpied.com/cssmin-js/
*/
p:first-letter{
buh: hum;
}
p:first-line{
baa: 1;
}
p:first-line,a,p:first-letter,b{
color: red;
} CSS-Compressor-0.02/t/yui/pseudo-first.css.min 0000644 0000765 0000024 00000000130 11720273444 020214 0 ustar simon staff p:first-letter {buh:hum}p:first-line {baa:1}p:first-line ,a,p:first-letter ,b{color:red} CSS-Compressor-0.02/t/yui/pseudo.css 0000644 0000765 0000024 00000000050 11720273444 016306 0 ustar simon staff p :link {
ba:zinga;;;
foo: bar;;;
} CSS-Compressor-0.02/t/yui/pseudo.css.min 0000644 0000765 0000024 00000000031 11720273444 017067 0 ustar simon staff p :link{ba:zinga;foo:bar} CSS-Compressor-0.02/t/yui/README 0000644 0000765 0000024 00000000241 11717316445 015164 0 ustar simon staff To add a test:
1. Create a "blah.css" or "blah.js" file.
2. Create a "blah.css.min" or "blah.js.min" file, containing the expected minified output.
That's all! CSS-Compressor-0.02/t/yui/special-comments.css 0000644 0000765 0000024 00000000252 11720273444 020256 0 ustar simon staff /*!************88****
Preserving comments
as they are
********************
Keep the initial !
*******************/
#yo {
ma: "ma";
}
/*!
I said
pre-
serve! */ CSS-Compressor-0.02/t/yui/special-comments.css.min 0000644 0000765 0000024 00000000237 11720273444 021043 0 ustar simon staff /*!************88****
Preserving comments
as they are
********************
Keep the initial !
*******************/#yo{ma:"ma"}/*!
I said
pre-
serve! */ CSS-Compressor-0.02/t/yui/star-underscore-hacks.css 0000644 0000765 0000024 00000000073 11720273444 021223 0 ustar simon staff #elementarr {
width: 1px;
*width: 3pt;
_width: 2em;
} CSS-Compressor-0.02/t/yui/star-underscore-hacks.css.min 0000644 0000765 0000024 00000000054 11720273444 022004 0 ustar simon staff #elementarr{width:1px;*width:3pt;_width:2em} CSS-Compressor-0.02/t/yui/string-in-comment.css 0000644 0000765 0000024 00000000177 11720273444 020373 0 ustar simon staff /* te " st */
a{a:1}
/*!"preserve" me*/
b{content: "/**/"}
/* quite " quote ' \' \" */
/* ie mac \*/
c {c : 3}
/* end hiding */ CSS-Compressor-0.02/t/yui/string-in-comment.css.min 0000644 0000765 0000024 00000000070 11720274015 021140 0 ustar simon staff a{a:1}/*!"preserve" me*/b{content:"/**/"}/*\*/c{c:3}/**/ CSS-Compressor-0.02/t/yui/suite.rhino 0000644 0000765 0000024 00000000145 11717316445 016501 0 ustar simon staff input = readFile(arguments[0]);
load("../ports/js/cssmin.js");
print(YAHOO.compressor.cssmin(input)); CSS-Compressor-0.02/t/yui/suite.sh 0000644 0000765 0000024 00000002170 11720260323 015757 0 ustar simon staff #!/usr/bin/env bash
cd $(dirname $0)
# Get the jar to use.
jar="$(ls ../build/*.jar | sort | tail -n1)"
echo "jar: $jar"
runtest () {
testfile="$1"
expected=${testfile/\.FAIL/}.min
expected="$(
cat $expected
)"
filetype="$(
echo $testfile | egrep -o '(cs|j)s'
)"
if [ "$2" == "cssminjs" ]; then
actual="$(
java -jar ../lib/rhino-1.6R7.jar suite.rhino $testfile
)"
else
actual="$(
java -jar $jar --type $filetype $testfile
)"
fi
if [ "$expected" == "$actual" ]; then
echo "Passed: $testfile" > /dev/stderr
else
(
echo "Test failed: $testfile"
echo ""
echo "Expected:"
echo "$expected"
echo ""
echo "Actual:"
echo "$actual"
) > /dev/stderr
return 1
fi
}
ls *.FAIL | while read failtest; do
echo "Failing test: " $failtest > /dev/stderr
runtest $failtest && echo "Test passed, please remove the '.FAIL' from the filename"
done
ls *.{css,js} | while read testfile; do
runtest $testfile || exit 1
done
echo
echo "now testing the JS port of CSSMIN..."
ls *.css | while read testfile; do
runtest $testfile "cssminjs" || exit 1
done
exit 0
CSS-Compressor-0.02/t/yui/webkit-transform.css 0000644 0000765 0000024 00000000102 11720273444 020303 0 ustar simon staff c {-webkit-transform-origin: 0 0;}
d {-MOZ-TRANSFORM-ORIGIN: 0 0 } CSS-Compressor-0.02/t/yui/webkit-transform.css.min 0000644 0000765 0000024 00000000073 11720273444 021074 0 ustar simon staff c{-webkit-transform-origin:0 0}d{-moz-transform-origin:0 0} CSS-Compressor-0.02/t/yui/zeros.css 0000644 0000765 0000024 00000000155 11720273444 016157 0 ustar simon staff a {
margin: 0px 0pt 0em 0%;
_padding-top: 0ex;
background-position: 0 0;
padding: 0in 0cm 0mm 0pc
}
CSS-Compressor-0.02/t/yui/zeros.css.min 0000644 0000765 0000024 00000000074 11720273774 016747 0 ustar simon staff a{margin:0;_padding-top:0;background-position:0 0;padding:0} CSS-Compressor-0.02/t/yui.t 0000644 0000765 0000024 00000001516 11770572157 014502 0 ustar simon staff
our @files;
use FindBin;
BEGIN { @files = grep +( !m! \b dataurl-base64-linebreakindata.css \E\b !x ), glob "$FindBin::Bin/yui/*.css" }
use Test::Differences;
use Test::More
tests => 1 + @files;
BEGIN {
use_ok( 'CSS::Compressor' => qw( css_compress ) );
}
diag "yui test files: @files\n";
for my $file ( @files ) {
die "$!: $file.min"
unless open my $fh => '<' => $file;
my $source = do { local $/; <$fh> };
close $fh;
die "$!: $file.min"
unless open $fh => '<' => $file.'.min';
my $target = do { local $/; <$fh> };
close $fh;
my $result = css_compress( $source );
# make diffs readable
s!([{;])!$1\n!smg,
s!([}])!\n$1!smg
for $result, $target;
my ( $name ) = $file =~ m!([^/]+)\z!;
eq_or_diff $result => $target => "css_compress($name) == $name.min";
}