From: Marius Gavrilescu Date: Wed, 22 Apr 2015 07:17:45 +0000 (+0300) Subject: Remove all logos, replace PNG with SVG X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=cf39f49f7a89076dc1fc67a9224d7546bf27a1a3;p=plack-app-gruntmaster.git Remove all logos, replace PNG with SVG --- diff --git a/Makefile.PL b/Makefile.PL index 8404b77..b66d483 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -10,11 +10,11 @@ WriteMakefile( LICENSE => 'AGPL_3', SIGN => 1, clean => { - FILES => 'static/css/ static/js/ css/logos.css static/logos.png' + FILES => 'static/css/ static/js/ static/logos/' }, BUILD_REQUIRES => { qw/CSS::Minifier::XS 0 - CSS::SpriteMaker 0 + SVG::SpriteMaker 0 File::Slurp 0 Test::MockTime 0 Test::More 0 diff --git a/css/logo.css b/css/logo.css index db86d4f..57ef811 100644 --- a/css/logo.css +++ b/css/logo.css @@ -3,13 +3,3 @@ max-width: 600px; max-height: 150px; } - -#mind path { stroke: none } -#coding path { fill: #FFF } -#circle { stroke: #FFF } -#head { fill: #FFF } - -.logo-light #mind path { stroke: #373435 } -.logo-light #coding path { fill: #373435 } -.logo-light #circle { stroke: #373435 } -.logo-light #head { fill: #373435 } diff --git a/js/90-themes.js b/js/90-themes.js index 347cad2..4a7067e 100644 --- a/js/90-themes.js +++ b/js/90-themes.js @@ -8,9 +8,9 @@ function set_style(name, trans){ localStorage.setItem("theme", name); $(function() { if(name == 'slate' || name == 'cyborg') - $('.logo').each(e => e.classList.remove('logo-light')); + $('img').each(e => e.setAttribute('src', e.getAttribute('src').replace('logos/light', 'logos/dark'))); else - $('.logo').each(e => e.classList.add('logo-light')); + $('img').each(e => e.setAttribute('src', e.getAttribute('src').replace('logos/dark', 'logos/light'))); }); } diff --git a/lib/Plack/App/Gruntmaster/HTML.pm b/lib/Plack/App/Gruntmaster/HTML.pm index 7863f4f..d4afb4c 100644 --- a/lib/Plack/App/Gruntmaster/HTML.pm +++ b/lib/Plack/App/Gruntmaster/HTML.pm @@ -89,13 +89,8 @@ sub _render { $tree->as_HTML(undef, undef, $optional_end_tags); } -my $logo = read_file 'mclogo.svg'; -$logo =~ y/\n//d; -$logo =~ s/(\s+)/ /g; - sub process_skel { my ($tree, %args) = @_; - $tree->fid('logo')->replace_with(HTML::Element::Library::super_literal $logo); $tree->content_handler( title => $args{title}, content => literal $args{meat}); diff --git a/logos-light/hermes.svg b/logos-light/hermes.svg new file mode 100644 index 0000000..d69869b --- /dev/null +++ b/logos-light/hermes.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/logos-light/mindcoding.svg b/logos-light/mindcoding.svg new file mode 100644 index 0000000..1f64b08 --- /dev/null +++ b/logos-light/mindcoding.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/logos/bigstep.png b/logos/bigstep.png deleted file mode 100644 index 3ee4d6b..0000000 Binary files a/logos/bigstep.png and /dev/null differ diff --git a/logos/bosch.jpg b/logos/bosch.jpg deleted file mode 100644 index ecd2fbe..0000000 Binary files a/logos/bosch.jpg and /dev/null differ diff --git a/logos/cos.png b/logos/cos.png deleted file mode 100644 index 371fb2c..0000000 Binary files a/logos/cos.png and /dev/null differ diff --git a/logos/csf.png b/logos/csf.png deleted file mode 100644 index 2193176..0000000 Binary files a/logos/csf.png and /dev/null differ diff --git a/logos/easyhost.png b/logos/easyhost.png deleted file mode 100644 index 3a25808..0000000 Binary files a/logos/easyhost.png and /dev/null differ diff --git a/logos/emag.png b/logos/emag.png deleted file mode 100644 index 1fbbe48..0000000 Binary files a/logos/emag.png and /dev/null differ diff --git a/logos/endava.jpg b/logos/endava.jpg deleted file mode 100644 index 9e49b07..0000000 Binary files a/logos/endava.jpg and /dev/null differ diff --git a/logos/eyc.png b/logos/eyc.png deleted file mode 100644 index a203b2f..0000000 Binary files a/logos/eyc.png and /dev/null differ diff --git a/logos/facebook.png b/logos/facebook.png deleted file mode 100644 index cd2d5f7..0000000 Binary files a/logos/facebook.png and /dev/null differ diff --git a/logos/facebook.svg b/logos/facebook.svg new file mode 100644 index 0000000..8e311d6 --- /dev/null +++ b/logos/facebook.svg @@ -0,0 +1,4 @@ + + + + diff --git a/logos/hermes-light.png b/logos/hermes-light.png deleted file mode 100644 index 2e2e417..0000000 Binary files a/logos/hermes-light.png and /dev/null differ diff --git a/logos/hermes.png b/logos/hermes.png deleted file mode 100644 index fc8e791..0000000 Binary files a/logos/hermes.png and /dev/null differ diff --git a/logos/hermes.svg b/logos/hermes.svg new file mode 100644 index 0000000..bdc20c3 --- /dev/null +++ b/logos/hermes.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/logos/mindcoding.svg b/logos/mindcoding.svg new file mode 100644 index 0000000..d2483de --- /dev/null +++ b/logos/mindcoding.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/logos/spyhce.png b/logos/spyhce.png deleted file mode 100644 index fdaa0d3..0000000 Binary files a/logos/spyhce.png and /dev/null differ diff --git a/logos/takeofflabs-light.png b/logos/takeofflabs-light.png deleted file mode 100644 index ce72061..0000000 Binary files a/logos/takeofflabs-light.png and /dev/null differ diff --git a/logos/takeofflabs.png b/logos/takeofflabs.png deleted file mode 100644 index e0efc97..0000000 Binary files a/logos/takeofflabs.png and /dev/null differ diff --git a/logos/telenav.png b/logos/telenav.png deleted file mode 100644 index 26fc522..0000000 Binary files a/logos/telenav.png and /dev/null differ diff --git a/logos/usr.png b/logos/usr.png deleted file mode 100644 index 05ae579..0000000 Binary files a/logos/usr.png and /dev/null differ diff --git a/logos/yardi-light.png b/logos/yardi-light.png deleted file mode 100644 index d99f4dd..0000000 Binary files a/logos/yardi-light.png and /dev/null differ diff --git a/logos/yardi.png b/logos/yardi.png deleted file mode 100644 index cde5d87..0000000 Binary files a/logos/yardi.png and /dev/null differ diff --git a/make_static.PL b/make_static.PL index ea060bc..24e56a8 100644 --- a/make_static.PL +++ b/make_static.PL @@ -3,46 +3,47 @@ use v5.14; use warnings; use CSS::Minifier::XS qw/minify/; -use CSS::SpriteMaker; 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 List::Util qw/first/; mkdir 'static'; mkdir 'static/css'; mkdir 'static/js'; - -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->print_css( - filename => 'css/logos.css', - sprite_filename => '/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'; -} +mkdir 'static/logos'; sub gzip_file { my ($file) = @_; gzip $file => "$file.gz", -Level => 9, Minimal => 1; } +sub write_gzfile { + my ($file, @content) = @_; + write_file $file, @content; + gzip_file $file +} + +sub sprite_name { + my ($name) = $_[0] =~ m,/(.*)\.svg,; + "logo-$name" +} + +sub make_logos { + my @logos = ; + my $logos = make_sprite \&sprite_name, @logos; + my @logos_light; + for () { + 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); @@ -75,24 +76,20 @@ sub make_css { } } - for my $name (keys %css) { - write_file "static/css/$name.css", minify $css{$name}; - gzip_file "static/css/$name.css" - } + write_gzfile "static/css/$_.css", minify $css{$_} for keys %css } sub make_js { system java => -jar => 'compiler.jar', qw,-O SIMPLE --create_source_map static/js/js.map --js_output_file static/js/all.js --language_in ECMASCRIPT6_STRICT --language_out ECMASCRIPT5_STRICT --source_map_location_mapping js/|/static/js/,, ; my $js = read_file 'static/js/all.js'; - write_file 'static/js/all.js', '//# sourceMappingURL=/static/js/js.map', "\n", $js; + write_gzfile 'static/js/all.js', '//# sourceMappingURL=/static/js/js.map', "\n", $js; system 'cp', '-rp', 'js', 'static/'; - gzip_file 'static/js/all.js'; } -my $sprite_mtime = -M 'static/logos.png' // 0; -for () { +my $sprite_mtime = -M 'static/logos/dark.svg' // 0; +for (, ) { if (!$sprite_mtime || $sprite_mtime > -M) { - make_sprite; + make_logos; last } } @@ -119,24 +116,3 @@ edit_file_lines { my $hash = sha256_base64 scalar read_file $file; s/integrity=".*"/integrity="sha256-$hash="/; } 'tmpl/skel.en'; - -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, <