summary refs log tree commit diff stats
path: root/lib/Crater/Routes/Gallery.rakumod
blob: cf79cc6d66d212f018640d880247df0d1a9a1319 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use Cro::HTTP::Router;
use Cro::WebApp::Template;

use Crater::Gallery;
use Crater::Session;

sub gallery-routes(
    Crater::Gallery :$gallery!, #= gallery object
) is export {
    route {
        get -> LoggedIn $session {
            template 'gallery.crotmp', {
                gallery => $gallery.list(),
                title => "Gallery"
            };
        }

        get -> {
            redirect '/login', :see-other;
        }
        get -> *@path {
            static $gallery.directory.add(".crater/thumbnails"), @path;
        }
    }
}