From f156f380d4de118e31036e80144154bdcb664ed6 Mon Sep 17 00:00:00 2001 From: Andinus Date: Sat, 11 Jun 2022 13:59:33 +0530 Subject: Display gallery title, fix authentication, show directories - Earlier non-authenticated users could access the images too. - Serve original image if thumbnail doesn't exist. - Show directories in gallery. - Remove lazy loading attribute. --- lib/Crater/Routes/Gallery.rakumod | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lib/Crater/Routes/Gallery.rakumod') diff --git a/lib/Crater/Routes/Gallery.rakumod b/lib/Crater/Routes/Gallery.rakumod index cf79cc6..aa3e4b6 100644 --- a/lib/Crater/Routes/Gallery.rakumod +++ b/lib/Crater/Routes/Gallery.rakumod @@ -8,6 +8,15 @@ sub gallery-routes( Crater::Gallery :$gallery!, #= gallery object ) is export { route { + # Logged in users can view images. + get -> LoggedIn $session, 'resources', 'img', *@path, :$original { + my $dir = $gallery.directory; + # Serve the thumbnail unless original image was requested. + $dir .= add(".crater/thumbnails") unless $original.defined; + static $dir, @path; + } + + # Gallery view. get -> LoggedIn $session { template 'gallery.crotmp', { gallery => $gallery.list(), @@ -15,11 +24,9 @@ sub gallery-routes( }; } - get -> { - redirect '/login', :see-other; - } + # Redirect to login page if not logged in. get -> *@path { - static $gallery.directory.add(".crater/thumbnails"), @path; + redirect '/login', :see-other; } } } -- cgit 1.4.1-2-gfad0 og/AUTHORS'>
path: root/AUTHORS
blob: 541b7d102f399843d4f82198c37db95e4e6cfba8 (plain) (tree)
1
2
3
4
5
6
7
8
9