diff options
Diffstat (limited to 'katana.raku')
| -rwxr-xr-x | katana.raku | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/katana.raku b/katana.raku index b714b65..c157619 100755 --- a/katana.raku +++ b/katana.raku @@ -57,6 +57,41 @@ class Image { } } +class Tag { + has Str $.name; + has Str $.text; + has Str %.params; + has Tag @.succ; + + method has-text returns Bool { defined $.text } + method has-succ returns Bool { defined $.succ } + + method open returns Str {"<{$.name}{self.params}>" } + method close returns Str { "</{$.name}>" } + + method params returns Str { + return '' unless defined %!params; + my @params; + for %!params.kv -> $key, $val { + push @params, " $key='$val'"; + } + return @params.join; + } +} + +sub recurse-tags(@open-stack) { + my @close-stack; + for @open-stack -> $tag { + say $tag.open; + say $tag.text if $tag.has-text; + unshift @close-stack, $tag; + } + for @close-stack -> $tag { + say $tag.close; + recurse-tags $tag.succ if $tag.has-succ; + } +} + sub dist-dirs(Str \dist-dir --> List) { dist-dir <<~>> </large /blur /thumb> } sub ensure-directories(Str \dist-dir) { @@ -96,16 +131,34 @@ sub camera-stats(@images) { } multi MAIN( - Bool :$mr-proper, #= Clean output dir - Str :$in-dir = './in', #= Input dir - 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 - Int :$degree = 4, #= Degree of parallelism + Bool :$mr-proper, #= Clean output dir + Str :$in-dir = './in', #= Input dir + 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 = 'Katana album', #= Album title + Int :$degree = 4, #= Degree of parallelism ) { + my @html-elems; + push @html-elems, Tag.new: name => 'html', + params => ( + xmlns => 'http://www.w3.org/1999/xhtml', + lang => 'en', + 'xml:lang' => 'en' + ); + + push @html-elems, Tag.new: name => 'header', + succ => [Tag.new: name => 'body']; + + push @html-elems, Tag.new: name => 'title', + text => $title; + + recurse-tags @html-elems; + + exit; + my @images = dir($in-dir, test => { "$in-dir/$_".IO.f }).map:{ Image.new: source => $_, :$dist-dir }; |
