diff options
| -rw-r--r-- | frame.html.templ | 8 | ||||
| -rwxr-xr-x | slice.raku | 32 |
2 files changed, 28 insertions, 12 deletions
diff --git a/frame.html.templ b/frame.html.templ new file mode 100644 index 0000000..4343552 --- /dev/null +++ b/frame.html.templ @@ -0,0 +1,8 @@ +<html> + <head> + <title>{title}</title> + </head> + <body> + {body} + </body> +</html> @@ -1,13 +1,18 @@ #!/usr/bin/env raku -sub cmd(Str $command, @args) { - say "=> {$command} {@args}"; - my $proc = run $command, @args, :out, :err; +sub prefix:<❱>( *@args ) { + say "❱ {@args}"; + my $proc = run @args, :out, :err; for $proc.out.slurp(:close), $proc.err.slurp(:close) { .say if .chars > 0; } } +class Template { + has Str %!vars; + has Str $!frame = 'frame.html'; +} + class Image { has Str $!filename; has Str $!source; @@ -21,23 +26,23 @@ class Image { method generate(Int :$thumb-geometry, Str :$bg-blur) { my $thumb = "$!dist-dir/thumb/{$!filename}"; - cmd 'convert', ['-auto-orient', '-geometry', $thumb-geometry, - $!source, $thumb] - unless $thumb.IO.f; + ❱ ['convert', '-auto-orient', '-geometry', $thumb-geometry, $!source, $thumb] + unless $thumb.IO.f; my $blur = "$!dist-dir/blur/{$!filename}"; - cmd 'convert', ['-flip', '-geometry', $thumb-geometry/2, - '-blur', $bg-blur, - $!source, $blur] - unless $blur.IO.f; + ❱ ['convert', '-flip', '-geometry', $thumb-geometry/2, '-blur', $bg-blur, $!source, $blur] + unless $blur.IO.f; my $large = "$!dist-dir/large/{$!filename}"; - cmd 'cp', [$!source, $large] unless $large.IO.f; + ❱ ['cp', $!source, $large] unless $large.IO.f; } + + method thumb_tag { "<img class='thumb' src='./thumb/{$!filename}' />" } + method large_tag { "<img class='large' src='./large/{$!filename}' />" } } sub make-mr-proper(:$dist-dir) { - cmd 'rm', <-r -f>, $dist-dir if $dist-dir.IO.d; + ❱ 'rm', '-r', '-f', $dist-dir if $dist-dir.IO.d; } sub ensure-directories(:$dist-dir) { @@ -51,10 +56,13 @@ multi MAIN( Str :$dist-dir = './dist', #= Output dir Int :$thumb-geometry = 800, #= Thumbnail geometry Str :$bg-blur = '0x8', #= Background blur factor + Bool :$randomize = True, #= Randomize order of images + Str :$title = 'Yay', #= Album title ) { my @images = dir($in-dir, test => { "$in-dir/$_".IO.f }) .map: { Image.new: source => $_, :$dist-dir }; + @images = @images.pick: * if $randomize; make-mr-proper :$dist-dir if $mr-proper; ensure-directories :$dist-dir; |
