mason/.perl-lib/TrivGal.pm: Append `/' to folder names.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 11 Jun 2023 16:51:46 +0000 (17:51 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 12 Jun 2023 10:48:39 +0000 (11:48 +0100)
Probably pedantically technical.  I was considering doing this anyway,
and then noticed that folders listed in an index file (a) must have a
trailing `/' to be recognized as a folder, and (b) this doesn't get
removed in the generated contact page.

mason/.perl-lib/TrivGal.pm
mason/dhandler

index 9b05723..600e9f5 100644 (file)
@@ -285,6 +285,7 @@ sub listdir ($) {
   my (@d, @f);
   my $ix = undef;
 
+  $path =~ s#/$##;
   if (-f "$path/.tgal.index") {
     open my $f, "<", "$path/.tgal.index";
     my $item = undef;
@@ -338,7 +339,7 @@ sub listdir ($) {
       my $st = stat "$path/$e";
       my $list = undef;
       if ($dotp) { }
-      elsif (-d $st) { $list = \@d; }
+      elsif (-d $st) { $list = \@d; $e .= "/"; }
       elsif ($TYPE{lc $ext} && -f $st) { $list = \@f; }
       $list and push @$list, TrivGal::Item->new($e);
     }
index ef7044c..014f5da 100755 (executable)
@@ -110,7 +110,7 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 %   for my $size (qw{medthumb}) {
 <div class="gallery <% $size %>">
 %     for my $d (@$dd) {
-  <& .thumbnail, target => $d->name . "/", comment => $d->comment,
+  <& .thumbnail, target => $d->name, comment => $d->comment,
                 img => $tn{$d}, size => $size,
                 caption => $m->interp->apply_escapes($d->name, "h") &>\
 %     }