From: Marius Gavrilescu Date: Mon, 2 Mar 2015 16:05:23 +0000 (+0200) Subject: Make sprites during build X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=6eb2623e778c789cb5db8cd87b0b045136b231b7;p=plack-app-gruntmaster.git Make sprites during build --- diff --git a/Makefile.PL b/Makefile.PL index 2f3a50f..c6d91a7 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -10,10 +10,11 @@ WriteMakefile( LICENSE => 'AGPL_3', SIGN => 1, clean => { - FILES => 'static/css/ static/js.js' + FILES => 'static/css/ static/js.js css/logos.css static/logos.png' }, BUILD_REQUIRES => { qw/CSS::Minifier::XS 0 + CSS::SpriteMaker 0 File::Slurp 0 JavaScript::Minifier::XS 0 Test::MockTime 0 diff --git a/css/logos.css b/css/logos.css deleted file mode 100644 index 9f7bf21..0000000 --- a/css/logos.css +++ /dev/null @@ -1,25 +0,0 @@ -a.logo { - background-image: url("https://static.mindcoding.ro/static/logos.png"); - background-repeat: no-repeat; - display: inline-block; - vertical-align: middle; -} - -.logo-bigstep { background-position: -5px -0px; width: 250px; height: 72px; } -.logo-bosch { background-position: -5px -77px; width: 250px; height: 75px; } -.logo-cos { background-position: -5px -937px; width: 212px; height: 53px; } -.logo-csf { background-position: -5px -812px; width: 220px; height: 120px; } -.logo-easyhost { background-position: -5px -157px; width: 250px; height: 59px; } -.logo-emag { background-position: -5px -221px; width: 250px; height: 83px; } -.logo-endava { background-position: -5px -309px; width: 250px; height: 86px; } -.logo-eyc { background-position: -5px -1217px; width: 166px; height: 53px; } -.logo-facebook { background-position: -5px -1275px; width: 111px; height: 111px; } -.logo-hermes { background-position: -5px -1111px; width: 192px; height: 101px; } -.logo-hermes.logo-light { background-position: -5px -995px; width: 200px; height: 111px; } -.logo-spyhce { background-position: -5px -400px; width: 250px; height: 95px; } -.logo-takeofflabs { background-position: -5px -556px; width: 250px; height: 51px; } -.logo-takeofflabs.logo-light { background-position: -5px -500px; width: 250px; height: 51px; } -.logo-telenav { background-position: -5px -612px; width: 250px; height: 67px; } -.logo-usr { background-position: -121px -1275px; width: 105px; height: 52px; } -.logo-yardi { background-position: -5px -750px; width: 234px; height: 57px; } -.logo-yardi.logo-light { background-position: -5px -684px; width: 250px; height: 61px; } diff --git a/logos/bigstep.png b/logos/bigstep.png new file mode 100644 index 0000000..3ee4d6b Binary files /dev/null and b/logos/bigstep.png differ diff --git a/logos/bosch.jpg b/logos/bosch.jpg new file mode 100644 index 0000000..ecd2fbe Binary files /dev/null and b/logos/bosch.jpg differ diff --git a/logos/cos.png b/logos/cos.png new file mode 100644 index 0000000..371fb2c Binary files /dev/null and b/logos/cos.png differ diff --git a/logos/csf.png b/logos/csf.png new file mode 100644 index 0000000..2193176 Binary files /dev/null and b/logos/csf.png differ diff --git a/logos/easyhost.png b/logos/easyhost.png new file mode 100644 index 0000000..3a25808 Binary files /dev/null and b/logos/easyhost.png differ diff --git a/logos/emag.png b/logos/emag.png new file mode 100644 index 0000000..1fbbe48 Binary files /dev/null and b/logos/emag.png differ diff --git a/logos/endava.jpg b/logos/endava.jpg new file mode 100644 index 0000000..9e49b07 Binary files /dev/null and b/logos/endava.jpg differ diff --git a/logos/eyc.png b/logos/eyc.png new file mode 100644 index 0000000..a203b2f Binary files /dev/null and b/logos/eyc.png differ diff --git a/logos/facebook.png b/logos/facebook.png new file mode 100644 index 0000000..cd2d5f7 Binary files /dev/null and b/logos/facebook.png differ diff --git a/logos/hermes-light.png b/logos/hermes-light.png new file mode 100644 index 0000000..2e2e417 Binary files /dev/null and b/logos/hermes-light.png differ diff --git a/logos/hermes.png b/logos/hermes.png new file mode 100644 index 0000000..fc8e791 Binary files /dev/null and b/logos/hermes.png differ diff --git a/logos/spyhce.png b/logos/spyhce.png new file mode 100644 index 0000000..fdaa0d3 Binary files /dev/null and b/logos/spyhce.png differ diff --git a/logos/takeofflabs-light.png b/logos/takeofflabs-light.png new file mode 100644 index 0000000..ce72061 Binary files /dev/null and b/logos/takeofflabs-light.png differ diff --git a/logos/takeofflabs.png b/logos/takeofflabs.png new file mode 100644 index 0000000..e0efc97 Binary files /dev/null and b/logos/takeofflabs.png differ diff --git a/logos/telenav.png b/logos/telenav.png new file mode 100644 index 0000000..26fc522 Binary files /dev/null and b/logos/telenav.png differ diff --git a/logos/usr.png b/logos/usr.png new file mode 100644 index 0000000..05ae579 Binary files /dev/null and b/logos/usr.png differ diff --git a/logos/yardi-light.png b/logos/yardi-light.png new file mode 100644 index 0000000..d99f4dd Binary files /dev/null and b/logos/yardi-light.png differ diff --git a/logos/yardi.png b/logos/yardi.png new file mode 100644 index 0000000..cde5d87 Binary files /dev/null and b/logos/yardi.png differ diff --git a/make_static.PL b/make_static.PL index a47df2d..5594f75 100644 --- a/make_static.PL +++ b/make_static.PL @@ -3,6 +3,7 @@ use v5.14; use warnings; use CSS::Minifier::XS qw//; +use CSS::SpriteMaker; use JavaScript::Minifier::XS qw//; use File::Slurp qw/read_file write_file/; @@ -10,6 +11,25 @@ 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; + } +); + +$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', +); + my $common_css; $common_css .= read_file $_ for ; for () { @@ -22,3 +42,24 @@ for () { my $js; $js .= read_file $_ for ; write_file 'static/js.js', JavaScript::Minifier::XS::minify $js; + +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, <