]> iEval git - gruntmaster-page.git/blame - make_static.PL
Merge branch 'master' into newmc
[gruntmaster-page.git] / make_static.PL
CommitLineData
8798626b
MG
1#!/usr/bin/perl
2use v5.14;
3use warnings;
4
5use CSS::Minifier::XS qw//;
6eb2623e 6use CSS::SpriteMaker;
8798626b
MG
7use JavaScript::Minifier::XS qw//;
8
9use File::Slurp qw/read_file write_file/;
10
11mkdir 'static';
12mkdir 'static/css';
13
6eb2623e
MG
14my $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
33my $common_css;
34$common_css .= read_file $_ for <css/*.css>;
35for (<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
42if (-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
53package
54 Local::CSS::SpriteMaker;
55
56use parent qw/CSS::SpriteMaker/;
57
58sub _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;
64a.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}
70EOF
71 join "\n", @ret;
72}
This page took 0.030082 seconds and 4 git commands to generate.