]>
Commit | Line | Data |
---|---|---|
8798626b MG |
1 | #!/usr/bin/perl |
2 | use v5.14; | |
3 | use warnings; | |
4 | ||
5 | use CSS::Minifier::XS qw//; | |
6eb2623e | 6 | use CSS::SpriteMaker; |
8798626b MG |
7 | use JavaScript::Minifier::XS qw//; |
8 | ||
9 | use File::Slurp qw/read_file write_file/; | |
10 | ||
11 | mkdir 'static'; | |
12 | mkdir 'static/css'; | |
13 | ||
6eb2623e MG |
14 | my $maker = Local::CSS::SpriteMaker->new( |
15 | css_class_prefix => 'logo-', | |
16 | rc_override_classname => sub { | |
17 | my ($name) = @_; | |
18 | $name =~ s/-light/.logo-light/r; | |
19 | } | |
20 | ); | |
21 | ||
22 | $maker->make_sprite( | |
23 | source_images => ['logos/'], | |
24 | target_file => 'static/logos.png', | |
25 | add_extra_padding => 10, | |
26 | ); | |
27 | ||
28 | $maker->print_css( | |
29 | filename => 'css/logos.css', | |
30 | sprite_filename => 'https://static.mindcoding.ro/static/logos.png', | |
31 | ); | |
32 | ||
c9dee865 MG |
33 | system 'optipng', '-o7', '-zm1-9', 'static/logos.png'; |
34 | ||
8798626b MG |
35 | my $common_css; |
36 | $common_css .= read_file $_ for <css/*.css>; | |
37 | for (<css/themes/*>) { | |
38 | my ($theme) = m,themes/(.*)\.css,; | |
39 | my $css = read_file $_; | |
40 | $css .= $common_css; | |
41 | write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css; | |
42 | } | |
43 | ||
9cad7bdd MG |
44 | if (-f 'compiler.jar') { |
45 | 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/,, <js/*>; | |
46 | my $js = read_file 'static/js.js'; | |
47 | write_file 'static/js.js', '//# sourceMappingURL=/static/js.map', "\n", $js; | |
48 | system 'cp', '-rp', 'js', 'static/'; | |
49 | } else { | |
50 | my $js; | |
51 | $js .= read_file $_ for <js/*.js>; | |
52 | write_file 'static/js.js', JavaScript::Minifier::XS::minify $js; | |
53 | } | |
6eb2623e MG |
54 | |
55 | package | |
56 | Local::CSS::SpriteMaker; | |
57 | ||
58 | use parent qw/CSS::SpriteMaker/; | |
59 | ||
60 | sub _get_stylesheet_string { | |
61 | my $self = shift; | |
62 | my @ret = split "\n", $self->SUPER::_get_stylesheet_string(@_); | |
63 | shift @ret; | |
64 | @ret = sort @ret; | |
65 | unshift @ret, <<EOF; | |
66 | a.logo { | |
67 | background-image: url("https://static.mindcoding.ro/static/logos.png"); | |
68 | background-repeat: no-repeat; | |
69 | display: inline-block; | |
70 | vertical-align: middle; | |
71 | } | |
72 | EOF | |
73 | join "\n", @ret; | |
74 | } |