summary refs log tree commit diff stats
path: root/lib/Crater/Gallery.rakumod
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2022-06-09 21:12:03 +0530
committerAndinus <andinus@nand.sh>2022-06-09 21:12:03 +0530
commit2085b4cac3a86d59360531d48251c8ab39dec0dd (patch)
tree53cabc820312da2abff2bbb9b44132b61302cad1 /lib/Crater/Gallery.rakumod
parent48df36de5aa962b32d3313d6a9d2ace6a5fdac11 (diff)
downloadcrater-2085b4cac3a86d59360531d48251c8ab39dec0dd.tar.gz
Initial Gallery version
- Handles login, logout, simple directories.
Diffstat (limited to 'lib/Crater/Gallery.rakumod')
-rw-r--r--lib/Crater/Gallery.rakumod25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/Crater/Gallery.rakumod b/lib/Crater/Gallery.rakumod
new file mode 100644
index 0000000..ea92c47
--- /dev/null
+++ b/lib/Crater/Gallery.rakumod
@@ -0,0 +1,25 @@
+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;
+    }
+}