]> iEval git - gruntmaster-page.git/blobdiff - make_static.PL
Remove some UTF-8 from a/
[gruntmaster-page.git] / make_static.PL
index 6ea5eb1478fe7dce4b2256a3cc2b3ccd9af2fe49..4857bf0ccd37e2a367a75d1b037070df167023fa 100644 (file)
@@ -6,6 +6,7 @@ use CSS::Minifier::XS qw//;
 use CSS::SpriteMaker;
 use JavaScript::Minifier::XS qw//;
 
+use IO::Compress::Gzip qw/gzip/;
 use File::Slurp qw/read_file write_file/;
 
 mkdir 'static';
@@ -28,10 +29,17 @@ sub make_sprite {
 
        $maker->print_css(
                filename        => 'css/logos.css',
-               sprite_filename => 'https://static.mindcoding.ro/static/logos.png',
+               sprite_filename => '/static/logos.png',
        );
 
-       system 'optipng', '-o7', '-zm1-9', 'static/logos.png';
+       system 'pngnq-s9', '-s1', 'static/logos.png';
+       system 'optipng', '-o7', '-zm1-9', 'static/logos-nq8.png';
+       rename 'static/logos-nq8.png', 'static/logos.png';
+}
+
+sub gzip_file {
+       my ($file) = @_;
+       gzip $file => "$file.gz", -Level => 9, Minimal => 1;
 }
 
 sub make_css {
@@ -42,6 +50,7 @@ sub make_css {
                my $css = read_file $_;
                $css .= $common_css;
                write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css;
+               gzip_file "static/css/$theme.css";
        }
 }
 
@@ -56,6 +65,15 @@ sub make_js {
                $js .= read_file $_ for <js/*.js>;
                write_file 'static/js.js', JavaScript::Minifier::XS::minify $js;
        }
+       gzip_file 'static/js.js';
+}
+
+my $sprite_mtime = -M 'static/logos.png' // 0;
+for (<logos/*>) {
+       if (!$sprite_mtime || $sprite_mtime > -M) {
+               make_sprite;
+               last
+       }
 }
 
 my $css_mtime = -M 'static/css/slate.css' // 0;
@@ -74,14 +92,6 @@ for (<js/*>) {
        }
 }
 
-my $sprite_mtime = -M 'static/logos.png' // 0;
-for (<js/*>) {
-       if (!$sprite_mtime || $sprite_mtime > -M) {
-               make_sprite;
-               last
-       }
-}
-
 package
   Local::CSS::SpriteMaker;
 
@@ -94,7 +104,7 @@ sub _get_stylesheet_string {
        @ret = sort @ret;
        unshift @ret, <<EOF;
 a.logo {
-       background-image: url("https://static.mindcoding.ro/static/logos.png");
+       background-image: url("/static/logos.png");
        background-repeat: no-repeat;
        display: inline-block;
        vertical-align: middle;
This page took 0.021235 seconds and 4 git commands to generate.