summary refs log blame commit diff stats
path: root/lib/Crater/Gallery.rakumod
blob: ea92c47195045501438362fe3480e0d0c9d270ee (plain) (tree)
























                                                                                   
class Crater::Gallery {
    has IO $.directory is required;

    method list() {
        my @gallery;
        for dir($!directory).sort(*.modified) {
            if .IO.d {

            } elsif .IO.f {
                my Str $ext = .extension.lc;
                if $ext eq "jpg"|"png" {
                    push @gallery, %( :type<img>, :src($_.relative($!directory)) );
                } elsif $ext eq "0" {
                    push @gallery, %( :type<heading>, :text($_.slurp) );
                } elsif $ext eq "txt" {
                    push @gallery, %( :type<text>, :text($_.slurp) );
                } else {
                    warn "Unhandled file :$_";
                }
            }
        }

        return @gallery;
    }
}