diff options
author | Andinus <andinus@nand.sh> | 2022-06-11 17:21:46 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2022-06-11 17:21:46 +0530 |
commit | 02f8885f05f09dcb57a358fcd3440eaf679c8c02 (patch) | |
tree | f194b467501e2f3c9981574952291bbd22906044 /lib | |
parent | 79aa4269eccfc6afdb6347b37956b16e7603f0b0 (diff) | |
download | crater-02f8885f05f09dcb57a358fcd3440eaf679c8c02.tar.gz |
Add navigation bar to gallery
- Error on no images has been removed because there might be nested directories but 0 images & that is okay.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Crater/Gallery.rakumod | 2 | ||||
-rw-r--r-- | lib/Crater/Routes/Gallery.rakumod | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/Crater/Gallery.rakumod b/lib/Crater/Gallery.rakumod index 373231a..4fdfac8 100644 --- a/lib/Crater/Gallery.rakumod +++ b/lib/Crater/Gallery.rakumod @@ -27,7 +27,7 @@ class Crater::Gallery { } # Add directories on top. - for @paths.grep(*.d) { + for @paths.grep(*.d).sort { next if .ends-with(".crater"); push @gallery, %( :type<directory>, :text($_.relative($!directory)) ); diff --git a/lib/Crater/Routes/Gallery.rakumod b/lib/Crater/Routes/Gallery.rakumod index 655e62e..ede5010 100644 --- a/lib/Crater/Routes/Gallery.rakumod +++ b/lib/Crater/Routes/Gallery.rakumod @@ -18,9 +18,21 @@ sub gallery-routes( # Gallery view. get -> LoggedIn $session, *@path { + # Generates a navigation bar for nested directories. + my @nav = %(name => "home", url => "/"), ; + for @path.kv -> $idx, $p { + next if $p eq ""; + push @nav, %( + name => $p, + url => (@nav[*-1]<url> ~ $p ~ "/") + ); + } + template 'gallery.crotmp', { gallery => $gallery.list(sub-dir => @path), - title => "Gallery" + title => $gallery.title(), + nav => @nav, + show-nav => @path.elems ?? True !! False }; } |