diff options
author | Yorhel <git@yorhel.nl> | 2008-12-23 10:04:55 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2008-12-23 10:04:55 +0100 |
commit | 4ff5526f73bca33933cbff1e1cc7fee61da4327c (patch) | |
tree | 93f991f69099d8b0d54f13db28a8f516451e017d /util/skingen.pl | |
parent | b65c057afb9849bfcbefa08b40c7a548f5e3a6a7 (diff) |
Added simple CSS compression
...by removing all newlines, whitespace and comments from the
generated CSS file.
None of the CSS sent to the browser is maintained by hand now, so
adding some compression is easy. :-)
This compression is disabled if the debug config flag is enabled,
considering debugging an unreadable CSS file isn't fun.
Diffstat (limited to 'util/skingen.pl')
-rwxr-xr-x | util/skingen.pl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/util/skingen.pl b/util/skingen.pl index 95aa8d63..9c06b077 100755 --- a/util/skingen.pl +++ b/util/skingen.pl @@ -1,5 +1,7 @@ #!/usr/bin/perl +package VNDB; + use strict; use warnings; use Cwd 'abs_path'; @@ -7,8 +9,9 @@ use Data::Dumper 'Dumper'; use Image::Magick; -our $ROOT; +our($ROOT, %O); BEGIN { ($ROOT = abs_path $0) =~ s{/util/skingen\.pl$}{}; } +require $ROOT.'/data/global.pl'; if(@ARGV) { @@ -74,6 +77,12 @@ sub writeskin { # $obj open my $CSS, '<', "$ROOT/data/skingen/style.css" or die $!; 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; } |