]>
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 | ||
8798626b MG |
33 | my $common_css; |
34 | $common_css .= read_file $_ for <css/*.css>; | |
35 | for (<css/themes/*>) { | |
36 | my ($theme) = m,themes/(.*)\.css,; | |
37 | my $css = read_file $_; | |
38 | $css .= $common_css; | |
39 | write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css; | |
40 | } | |
41 | ||
9cad7bdd MG |
42 | if (-f 'compiler.jar') { |
43 | 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/*>; | |
44 | my $js = read_file 'static/js.js'; | |
45 | write_file 'static/js.js', '//# sourceMappingURL=/static/js.map', "\n", $js; | |
46 | system 'cp', '-rp', 'js', 'static/'; | |
47 | } else { | |
48 | my $js; | |
49 | $js .= read_file $_ for <js/*.js>; | |
50 | write_file 'static/js.js', JavaScript::Minifier::XS::minify $js; | |
51 | } | |
6eb2623e MG |
52 | |
53 | package | |
54 | Local::CSS::SpriteMaker; | |
55 | ||
56 | use parent qw/CSS::SpriteMaker/; | |
57 | ||
58 | sub _get_stylesheet_string { | |
59 | my $self = shift; | |
60 | my @ret = split "\n", $self->SUPER::_get_stylesheet_string(@_); | |
61 | shift @ret; | |
62 | @ret = sort @ret; | |
63 | unshift @ret, <<EOF; | |
64 | a.logo { | |
65 | background-image: url("https://static.mindcoding.ro/static/logos.png"); | |
66 | background-repeat: no-repeat; | |
67 | display: inline-block; | |
68 | vertical-align: middle; | |
69 | } | |
70 | EOF | |
71 | join "\n", @ret; | |
72 | } |