diff options
author | Yorhel <git@yorhel.nl> | 2009-10-07 10:22:14 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-10-07 10:22:14 +0200 |
commit | bafb8b134744cba74a3a019fefb36091b0e19d13 (patch) | |
tree | fd0f42fe52df2c05fd9b4519d77314d2aca3c3a1 | |
parent | 9afed91c8196a8d35fc33ec23a214cabb58c45a7 (diff) |
skingen: Used CSS::Minifier::XS instead of my crappy regexes
The minified and gzipped CSS file is now 0.7kB smaller than the
non-minified but gzipped CSS file. That's significant enough on ~5kB.
-rw-r--r-- | README | 4 | ||||
-rwxr-xr-x | util/skingen.pl | 17 |
2 files changed, 9 insertions, 12 deletions
@@ -48,6 +48,10 @@ Requirements XML::Writer PerlIO::gzip + util/skingen.pl + Image::Magick + CSS::Minifier::XS (optional, minimizes CSS output) + Contact diff --git a/util/skingen.pl b/util/skingen.pl index e27ea4a1..d18f5fde 100755 --- a/util/skingen.pl +++ b/util/skingen.pl @@ -5,8 +5,8 @@ package VNDB; use strict; use warnings; use Cwd 'abs_path'; -use Data::Dumper 'Dumper'; use Image::Magick; +eval { require CSS::Minifier::XS }; our($ROOT, %O); @@ -78,19 +78,12 @@ sub writeskin { # $obj # write the CSS open my $CSS, '<', "$ROOT/data/style.css" or die $!; + my $css = join '', <$CSS>; + close $CSS; + $css =~ s/\$$_\$/$o->{$_}/g for (keys %$o); open my $SKIN, '>', "$ROOT/static/s/$o->{_name}/style.css" or die $!; - while((my $d = <$CSS>)) { - if($O{debug}) { - chomp $d; - $d =~ s/^\s*/ /; - $d =~ s{/\*.+\*/}{}; # NOTE: multiline comments or multiple comments per line won't work - next if $d !~ /[^\s\t]/; - } - $d =~ s/\$$_\$/$o->{$_}/g for (keys %$o); - print $SKIN $d; - } + print $SKIN $CSS::Minifier::XS::VERSION ? CSS::Minifier::XS::minify($css) : $css; close $SKIN; - close $CSS; } |