summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2022-06-11 17:21:46 +0530
committerAndinus <andinus@nand.sh>2022-06-11 17:21:46 +0530
commit02f8885f05f09dcb57a358fcd3440eaf679c8c02 (patch)
treef194b467501e2f3c9981574952291bbd22906044 /lib
parent79aa4269eccfc6afdb6347b37956b16e7603f0b0 (diff)
downloadcrater-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.rakumod2
-rw-r--r--lib/Crater/Routes/Gallery.rakumod14
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
             };
         }
 
amp;id=7817fdb29c46419e22ddcbd9f75a5be6308c9776'>7817fdb2 ^
9a524793 ^









































































16f2bd11 ^

9a524793 ^
16f2bd11 ^
9a524793 ^
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165