summary refs log tree commit diff stats
path: root/lib/Crater/Routes/Gallery.rakumod
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Crater/Routes/Gallery.rakumod')
-rw-r--r--lib/Crater/Routes/Gallery.rakumod25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/Crater/Routes/Gallery.rakumod b/lib/Crater/Routes/Gallery.rakumod
new file mode 100644
index 0000000..04c8d74
--- /dev/null
+++ b/lib/Crater/Routes/Gallery.rakumod
@@ -0,0 +1,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, @path;
+        }
+    }
+}