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;
- }
- );
++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->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',
- );
++ $maker->print_css(
++ filename => 'css/logos.css',
++ sprite_filename => 'https://static.mindcoding.ro/static/logos.png',
++ );
+
- system 'optipng', '-o7', '-zm1-9', 'static/logos.png';
++ system 'optipng', '-o7', '-zm1-9', 'static/logos.png';
++}
+
- my $common_css;
- $common_css .= read_file $_ for <css/*.css>;
- for (<css/themes/*>) {
- my ($theme) = m,themes/(.*)\.css,;
- my $css = read_file $_;
- $css .= $common_css;
- write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css;
+ sub make_css {
+ my $common_css;
+ $common_css .= read_file $_ for <css/*.css>;
+ for (<css/themes/*>) {
+ my ($theme) = m,themes/(.*)\.css,;
+ my $css = read_file $_;
+ $css .= $common_css;
+ write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css;
+ }
}
- if (-f 'compiler.jar') {
- 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/*>;
- my $js = read_file 'static/js.js';
- write_file 'static/js.js', '//# sourceMappingURL=/static/js.map', "\n", $js;
- system 'cp', '-rp', 'js', 'static/';
- } else {
- my $js;
- $js .= read_file $_ for <js/*.js>;
- write_file 'static/js.js', JavaScript::Minifier::XS::minify $js;
+ sub make_js {
+ if (-f 'compiler.jar') {
+ 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/*>;
+ my $js = read_file 'static/js.js';
+ write_file 'static/js.js', '//# sourceMappingURL=/static/js.map', "\n", $js;
+ system 'cp', '-rp', 'js', 'static/';
+ } else {
+ my $js;
+ $js .= read_file $_ for <js/*.js>;
+ write_file 'static/js.js', JavaScript::Minifier::XS::minify $js;
+ }
+ }
+
+ my $css_mtime = -M 'static/css/slate.css' // 0;
+ for (<css/*>, <css/themes/*>) {
+ if (!$css_mtime || $css_mtime > -M) {
+ make_css;
+ last
+ }
+ }
+
+ my $js_mtime = -M 'static/js.js' // 0;
+ for (<js/*>) {
+ if (!$js_mtime || $js_mtime > -M) {
+ make_js;
+ last
+ }
+ }
++
++my $sprite_mtime = -M 'static/logos.png' // 0;
++for (<js/*>) {
++ if (!$sprite_mtime || $sprite_mtime > -M) {
++ make_sprite;
++ last
++ }
+}
+
+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, <<EOF;
+a.logo {
+ background-image: url("https://static.mindcoding.ro/static/logos.png");
+ background-repeat: no-repeat;
+ display: inline-block;
+ vertical-align: middle;
+}
+EOF
+ join "\n", @ret;
+}