From: Marius Gavrilescu Date: Mon, 9 Mar 2015 15:12:41 +0000 (+0200) Subject: Merge branch 'master' into newmc X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=69d77267e240ef389facf309d33d4cbe68a98895;p=plack-app-gruntmaster.git Merge branch 'master' into newmc Conflicts: make_static.PL --- 69d77267e240ef389facf309d33d4cbe68a98895 diff --cc make_static.PL index 100b6c2,0a10891..6ea5eb1 --- a/make_static.PL +++ b/make_static.PL @@@ -11,64 -10,42 +11,94 @@@ use File::Slurp qw/read_file write_file mkdir 'static'; mkdir 'static/css'; - my $maker = Local::CSS::SpriteMaker->new( - css_class_prefix => 'logo-', - rc_override_classname => sub { - my ($name) = @_; - $name =~ s/-light/.logo-light/r; - } - ); ++sub make_sprite { ++ my $maker = Local::CSS::SpriteMaker->new( ++ css_class_prefix => 'logo-', ++ rc_override_classname => sub { ++ my ($name) = @_; ++ $name =~ s/-light/.logo-light/r; ++ } ++ ); + - $maker->make_sprite( - source_images => ['logos/'], - target_file => 'static/logos.png', - add_extra_padding => 10, - ); ++ $maker->make_sprite( ++ source_images => ['logos/'], ++ target_file => 'static/logos.png', ++ add_extra_padding => 10, ++ ); + - $maker->print_css( - filename => 'css/logos.css', - sprite_filename => 'https://static.mindcoding.ro/static/logos.png', - ); ++ $maker->print_css( ++ filename => 'css/logos.css', ++ sprite_filename => 'https://static.mindcoding.ro/static/logos.png', ++ ); + - system 'optipng', '-o7', '-zm1-9', 'static/logos.png'; ++ system 'optipng', '-o7', '-zm1-9', 'static/logos.png'; ++} + - my $common_css; - $common_css .= read_file $_ for ; - for () { - my ($theme) = m,themes/(.*)\.css,; - my $css = read_file $_; - $css .= $common_css; - write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css; + sub make_css { + my $common_css; + $common_css .= read_file $_ for ; + for () { + my ($theme) = m,themes/(.*)\.css,; + my $css = read_file $_; + $css .= $common_css; + write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css; + } } - if (-f 'compiler.jar') { - system java => -jar => 'compiler.jar', qw,-O SIMPLE --create_source_map static/js.map --js_output_file static/js.js --language_in ECMASCRIPT5_STRICT --source_map_location_mapping js/|/static/js/,, ; - my $js = read_file 'static/js.js'; - write_file 'static/js.js', '//# sourceMappingURL=/static/js.map', "\n", $js; - system 'cp', '-rp', 'js', 'static/'; - } else { - my $js; - $js .= read_file $_ for ; - write_file 'static/js.js', JavaScript::Minifier::XS::minify $js; + sub make_js { + if (-f 'compiler.jar') { + system java => -jar => 'compiler.jar', qw,-O SIMPLE --create_source_map static/js.map --js_output_file static/js.js --language_in ECMASCRIPT5_STRICT --source_map_location_mapping js/|/static/js/,, ; + my $js = read_file 'static/js.js'; + write_file 'static/js.js', '//# sourceMappingURL=/static/js.map', "\n", $js; + system 'cp', '-rp', 'js', 'static/'; + } else { + my $js; + $js .= read_file $_ for ; + write_file 'static/js.js', JavaScript::Minifier::XS::minify $js; + } + } + + my $css_mtime = -M 'static/css/slate.css' // 0; + for (, ) { + if (!$css_mtime || $css_mtime > -M) { + make_css; + last + } + } + + my $js_mtime = -M 'static/js.js' // 0; + for () { + if (!$js_mtime || $js_mtime > -M) { + make_js; + last + } + } ++ ++my $sprite_mtime = -M 'static/logos.png' // 0; ++for () { ++ if (!$sprite_mtime || $sprite_mtime > -M) { ++ make_sprite; ++ last ++ } +} + +package + Local::CSS::SpriteMaker; + +use parent qw/CSS::SpriteMaker/; + +sub _get_stylesheet_string { + my $self = shift; + my @ret = split "\n", $self->SUPER::_get_stylesheet_string(@_); + shift @ret; + @ret = sort @ret; + unshift @ret, <