]> iEval git - gruntmaster-page.git/commitdiff
Merge branch 'master' into newmc
authorMarius Gavrilescu <marius@ieval.ro>
Wed, 22 Apr 2015 07:24:09 +0000 (10:24 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Wed, 22 Apr 2015 07:24:09 +0000 (10:24 +0300)
Conflicts:
make_static.PL

1  2 
Makefile.PL
make_static.PL

diff --combined Makefile.PL
index b66d4833f49d7a90d52873e4ea6e8e2cf0476614,0d62f051a36ec7c488287160e5b42f48530bee42..a1698a17c2b3b70366fc737fd16f8e10a86a4689
@@@ -10,11 -10,10 +10,11 @@@ WriteMakefile
        LICENSE           => 'AGPL_3',
        SIGN              => 1,
        clean             => {
 -              FILES => 'static/css/ static/js/'
 +              FILES => 'static/css/ static/js/ static/logos/'
        },
        BUILD_REQUIRES    => {
                qw/CSS::Minifier::XS          0
 +                 SVG::SpriteMaker           0
                   File::Slurp                0
                   Test::MockTime             0
                   Test::More                 0
@@@ -32,6 -31,7 +32,7 @@@
                   warnings    0
  
                   File::Slurp                      0
+                  File::Which                      0
                   Gruntmaster::Data                0
                   HTML::Element::Library           0
                   HTML::TreeBuilder                0
diff --combined make_static.PL
index 24e56a8bfcb67c370dc26cc84e26043a49ad90fc,9fd5bcaf62916cb024ac8c59c07f7030a2ff1772..06c9eeea791cd9e8da281f4d43fbb576d1398c4e
@@@ -6,17 -6,18 +6,20 @@@ use CSS::Minifier::XS qw/minify/
  use Digest::SHA qw/sha256_base64/;
  use IO::Compress::Gzip qw/gzip/;
  use File::Slurp qw/read_file write_file edit_file_lines/;
 +use SVG::SpriteMaker;
+ use File::Which;
  use List::Util qw/first/;
  
  mkdir 'static';
  mkdir 'static/css';
  mkdir 'static/js';
 +mkdir 'static/logos';
  
  sub gzip_file {
        my ($file) = @_;
-       gzip $file => "$file.gz", -Level => 9, Minimal => 1;
+       my $zopfli = which 'zopfli';
+       system $zopfli => $file if $zopfli;
+       gzip $file => "$file.gz", -Level => 9, Minimal => 1 unless $zopfli;
  }
  
  sub write_gzfile {
        gzip_file $file
  }
  
 +sub sprite_name {
 +      my ($name) = $_[0] =~ m,/(.*)\.svg,;
 +      "logo-$name"
 +}
 +
 +sub make_logos {
 +      my @logos = <logos/*>;
 +      my $logos = make_sprite \&sprite_name, @logos;
 +      my @logos_light;
 +      for (<logos/*>) {
 +              my $light = s/logos/logos-light/r;
 +              push @logos_light, -f $light ? $light : $_;
 +      }
 +      my $logos_light = make_sprite \&sprite_name, @logos_light;
 +
 +      write_gzfile 'static/logos/dark.svg', $logos->render;
 +      write_gzfile 'static/logos/light.svg', $logos_light->render;
 +}
 +
  sub read_css_into_blocks {
        my ($file) = @_;
        my (@blocks, $block);
@@@ -86,14 -68,6 +89,14 @@@ sub make_js 
        system 'cp', '-rp', 'js', 'static/';
  }
  
 +my $sprite_mtime = -M 'static/logos/dark.svg' // 0;
 +for (<logos/*>, <logos-light/*>) {
 +      if (!$sprite_mtime || $sprite_mtime > -M) {
 +              make_logos;
 +              last
 +      }
 +}
 +
  my $css_mtime = -M 'static/css/slate.css' // 0;
  for (<css/*>, <css/themes/*>) {
        if (!$css_mtime || $css_mtime > -M) {
@@@ -115,4 -89,4 +118,4 @@@ edit_file_lines 
        return unless $file;
        my $hash = sha256_base64 scalar read_file $file;
        s/integrity=".*"/integrity="sha256-$hash="/;
 -} 'tmpl/skel.en'
 +} 'tmpl/skel.en';
This page took 0.03225 seconds and 4 git commands to generate.