CSS-Compressor-0.02/0000755000076500000240000000000011772667542013246 5ustar simonstaffCSS-Compressor-0.02/Compressor.pm0000644000076500000240000002365211772667425015750 0ustar simonstaffpackage 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.PL0000644000076500000240000000047111772667402015215 0ustar simonstaff 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/MANIFEST0000644000076500000240000000350011772667542014375 0ustar simonstaffCompressor.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.json0000644000076500000240000000150611772667542014671 0ustar simonstaff{ "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.yml0000644000076500000240000000074411772667541014523 0ustar simonstaff--- 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/README0000644000076500000240000000236311770573551014124 0ustar simonstaffNAME 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/0000755000076500000240000000000011772667541013510 5ustar simonstaffCSS-Compressor-0.02/t/load.t0000644000076500000240000000014311770571452014603 0ustar simonstaff use Test::More tests => 1; BEGIN { use_ok( 'CSS::Compressor' => qw( css_compress ) ); } CSS-Compressor-0.02/t/simple.t0000644000076500000240000000035311770571564015164 0ustar simonstaff 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/0000755000076500000240000000000011772667541014316 5ustar simonstaffCSS-Compressor-0.02/t/yui/_munge.js0000644000076500000240000000020611717316445016115 0ustar simonstaff(function() { var w = window; w.hello = function(a, abc) { "a:nomunge"; w.alert("Hello, " + a); }; })(); CSS-Compressor-0.02/t/yui/_munge.js.min0000644000076500000240000000011111720273444016665 0ustar simonstaff(function(){var a=window;a.hello=function(a,b){a.alert("Hello, "+a)}})();CSS-Compressor-0.02/t/yui/_string_combo.js0000644000076500000240000000007011717316445017466 0ustar simonstafffunction test(){ var a = "a" + "b" + "c"; } CSS-Compressor-0.02/t/yui/_string_combo.js.min0000644000076500000240000000003511720273444020244 0ustar simonstafffunction test(){var b="abc"};CSS-Compressor-0.02/t/yui/_syntax_error.js0000644000076500000240000000263511717316445017551 0ustar simonstaff 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.min0000644000076500000240000000213211720273444020316 0ustar simonstaffwindow.$=$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.css0000644000076500000240000000007711720273444021001 0ustar simonstaffa {background-position: 0 0 0 0;} b {BACKGROUND-POSITION: 0 0;}CSS-Compressor-0.02/t/yui/background-position.css.min0000644000076500000240000000006411720273444021557 0ustar simonstaffa{background-position:0 0}b{background-position:0 0}CSS-Compressor-0.02/t/yui/border-none.css0000644000076500000240000000010111720273444017216 0ustar simonstaffa { border: none; } b {BACKGROUND:none} s {border-top: none;}CSS-Compressor-0.02/t/yui/border-none.css.min0000644000076500000240000000005111720273444020004 0ustar simonstaffa{border:0}b{background:0}s{border-top:0}CSS-Compressor-0.02/t/yui/box-model-hack.css0000644000076500000240000000017611720273444017612 0ustar simonstaff#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.min0000644000076500000240000000014411720273444020367 0ustar simonstaff#elem{width:100px;voice-family:"\"}\"";voice-family:inherit;width:200px}html>body #elem{width:200px}CSS-Compressor-0.02/t/yui/bug2527974.css0000644000076500000240000000061111720273444016353 0ustar simonstaff/* 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.min0000644000076500000240000000021511720273444017135 0ustar simonstaff/*! $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.css0000644000076500000240000000037111720273444016355 0ustar simonstaff@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.min0000644000076500000240000000030511720273444017134 0ustar simonstaff@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.css0000644000076500000240000000003111720273444016355 0ustar simonstaff/*! special */ body { } CSS-Compressor-0.02/t/yui/bug2527998.css.min0000644000076500000240000000001611720273444017142 0ustar simonstaff/*! special */CSS-Compressor-0.02/t/yui/bug2528034.css0000644000076500000240000000012611720273444016340 0ustar simonstaffa[href$="/test/"] span:first-child { b:1; } a[href$="/test/"] span:first-child { } CSS-Compressor-0.02/t/yui/bug2528034.css.min0000644000076500000240000000004711720273444017124 0ustar simonstaffa[href$="/test/"] span:first-child{b:1}CSS-Compressor-0.02/t/yui/charset-media.css0000644000076500000240000000013411720273444017520 0ustar simonstaff/* re: 2495387 */ @charset 'utf-8'; @media all { body { } body { background-color: gold; } }CSS-Compressor-0.02/t/yui/charset-media.css.min0000644000076500000240000000007011720273444020301 0ustar simonstaff@charset 'utf-8';@media all{body{background-color:gold}}CSS-Compressor-0.02/t/yui/color.css0000644000076500000240000000154211720273444016134 0ustar simonstaff.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.min0000644000076500000240000000121311720273500016702 0ustar simonstaff.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.css0000644000076500000240000000005011720273444016451 0ustar simonstaffhtml >/**/ body p { color: blue; } CSS-Compressor-0.02/t/yui/comment.css.min0000644000076500000240000000003311720273444017234 0ustar simonstaffhtml>/**/body p{color:blue}CSS-Compressor-0.02/t/yui/concat-charset.css0000644000076500000240000000054511720273444017716 0ustar simonstaff/* 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.min0000644000076500000240000000007611720273444020477 0ustar simonstaff@charset "utf-8";#foo{border-width:1px}#bar{border-width:10px}CSS-Compressor-0.02/t/yui/decimals.css0000644000076500000240000000006611720273444016577 0ustar simonstaff::selection { margin: 0.6px 0.333pt 1.2em 8.8cm; } CSS-Compressor-0.02/t/yui/decimals.css.min0000644000076500000240000000005311720273444017355 0ustar simonstaff::selection{margin:.6px .333pt 1.2em 8.8cm}CSS-Compressor-0.02/t/yui/dollar-header.css0000644000076500000240000000012711720273444017517 0ustar simonstaff/*! $Header: /temp/dirname/filename.css 3 2/02/08 3:37p JSmith $ */ foo { bar: baz } CSS-Compressor-0.02/t/yui/dollar-header.css.min0000644000076500000240000000011711720273444020300 0ustar simonstaff/*! $Header: /temp/dirname/filename.css 3 2/02/08 3:37p JSmith $ */foo{bar:baz}CSS-Compressor-0.02/t/yui/float.js0000644000076500000240000000006711717316445015755 0ustar simonstaffobj.css({"float": "left"}); obj.css({cssFloat:"left"});CSS-Compressor-0.02/t/yui/float.js.min0000644000076500000240000000006511720273444016530 0ustar simonstaffobj.css({"float":"left"});obj.css({cssFloat:"left"});CSS-Compressor-0.02/t/yui/font-face.css0000644000076500000240000000021111720273444016650 0ustar simonstaff@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.min0000644000076500000240000000015511720273444017441 0ustar simonstaff@font-face{font-family:'gzipper';src:url(yanone.eot);src:local('gzipper'),url(yanone.ttf) format('truetype')}CSS-Compressor-0.02/t/yui/ie5mac.css0000644000076500000240000000014311720273444016155 0ustar simonstaff/* Ignore the next rule in IE mac \*/ .selector { color: khaki; } /* Stop ignoring in IE mac */ CSS-Compressor-0.02/t/yui/ie5mac.css.min0000644000076500000240000000003711720274061016735 0ustar simonstaff/*\*/.selector{color:khaki}/**/CSS-Compressor-0.02/t/yui/media-empty-class.css0000644000076500000240000000040211720273444020326 0ustar simonstaff/*! 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.min0000644000076500000240000000016111720273444021112 0ustar simonstaff/*! preserved */@import "another.css";@media print{.noprint{display:none}}@media screen{.printonly{display:none}}CSS-Compressor-0.02/t/yui/media-multi.css0000644000076500000240000000020211720273444017215 0ustar simonstaff@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.min0000644000076500000240000000017011720273444020003 0ustar simonstaff@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.css0000644000076500000240000000011211720273444017042 0ustar simonstaff@media screen and (-webkit-min-device-pixel-ratio:0) { some-css : here }CSS-Compressor-0.02/t/yui/media-test.css.min0000644000076500000240000000010311720273444017624 0ustar simonstaff@media screen and (-webkit-min-device-pixel-ratio:0){some-css:here}CSS-Compressor-0.02/t/yui/opacity-filter.css0000644000076500000240000000126611720273444017754 0ustar simonstaff/* 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.min0000644000076500000240000000023411720273444020530 0ustar simonstaffpre{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.css0000644000076500000240000000012011720273444020354 0ustar simonstaff#sel-o { content: "on\"ce upon \ a time"; content: 'once upon \ a ti\'me'; }CSS-Compressor-0.02/t/yui/preserve-new-line.css.min0000644000076500000240000000010511720273444021141 0ustar simonstaff#sel-o{content:"on\"ce upon \ a time";content:'once upon \ a ti\'me'}CSS-Compressor-0.02/t/yui/preserve-strings.css0000644000076500000240000000030011720273444020327 0ustar simonstaff/* 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.min0000644000076500000240000000013711720273444021121 0ustar simonstaff.sele{content:"\"keep \" me";something:'\\\' . . ';else:'empty{}';content:"/* test */"}CSS-Compressor-0.02/t/yui/pseudo-first.css0000644000076500000240000000046311720273444017443 0ustar simonstaff/* 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.min0000644000076500000240000000013011720273444020214 0ustar simonstaffp: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.css0000644000076500000240000000005011720273444016306 0ustar simonstaffp :link { ba:zinga;;; foo: bar;;; }CSS-Compressor-0.02/t/yui/pseudo.css.min0000644000076500000240000000003111720273444017067 0ustar simonstaffp :link{ba:zinga;foo:bar}CSS-Compressor-0.02/t/yui/README0000644000076500000240000000024111717316445015164 0ustar simonstaffTo 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.css0000644000076500000240000000025211720273444020256 0ustar simonstaff/*!************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.min0000644000076500000240000000023711720273444021043 0ustar simonstaff/*!************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.css0000644000076500000240000000007311720273444021223 0ustar simonstaff#elementarr { width: 1px; *width: 3pt; _width: 2em; }CSS-Compressor-0.02/t/yui/star-underscore-hacks.css.min0000644000076500000240000000005411720273444022004 0ustar simonstaff#elementarr{width:1px;*width:3pt;_width:2em}CSS-Compressor-0.02/t/yui/string-in-comment.css0000644000076500000240000000017711720273444020373 0ustar simonstaff/* 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.min0000644000076500000240000000007011720274015021140 0ustar simonstaffa{a:1}/*!"preserve" me*/b{content:"/**/"}/*\*/c{c:3}/**/CSS-Compressor-0.02/t/yui/suite.rhino0000644000076500000240000000014511717316445016501 0ustar simonstaffinput = readFile(arguments[0]); load("../ports/js/cssmin.js"); print(YAHOO.compressor.cssmin(input));CSS-Compressor-0.02/t/yui/suite.sh0000644000076500000240000000217011720260323015757 0ustar simonstaff#!/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.css0000644000076500000240000000010211720273444020303 0ustar simonstaffc {-webkit-transform-origin: 0 0;} d {-MOZ-TRANSFORM-ORIGIN: 0 0 }CSS-Compressor-0.02/t/yui/webkit-transform.css.min0000644000076500000240000000007311720273444021074 0ustar simonstaffc{-webkit-transform-origin:0 0}d{-moz-transform-origin:0 0}CSS-Compressor-0.02/t/yui/zeros.css0000644000076500000240000000015511720273444016157 0ustar simonstaffa { 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.min0000644000076500000240000000007411720273774016747 0ustar simonstaffa{margin:0;_padding-top:0;background-position:0 0;padding:0}CSS-Compressor-0.02/t/yui.t0000644000076500000240000000151611770572157014502 0ustar simonstaff 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"; }