summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-10-07 10:22:14 +0200
committerYorhel <git@yorhel.nl>2009-10-07 10:22:14 +0200
commitbafb8b134744cba74a3a019fefb36091b0e19d13 (patch)
treefd0f42fe52df2c05fd9b4519d77314d2aca3c3a1
parent9afed91c8196a8d35fc33ec23a214cabb58c45a7 (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--README4
-rwxr-xr-xutil/skingen.pl17
2 files changed, 9 insertions, 12 deletions
diff --git a/README b/README
index 1060c544..0ea41d8c 100644
--- a/README
+++ b/README
@@ -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;
}