mason/dhandler (.contact): Recurse into first folder to find index image.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 12 Jun 2023 10:30:35 +0000 (11:30 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 12 Jun 2023 10:48:39 +0000 (11:48 +0100)
This isn't always the best choice, but it's better than the plain folder
icon.

mason/dhandler

index d36722b..42b324c 100755 (executable)
@@ -88,10 +88,17 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
        for my $f (@$ff)
          { $tn{$f} = TrivGal::Image->new($path . $f->name); }
        for my $d (@$dd) {
-         my ($ddd, $fff, $iii) = listdir $real . "/" . $d->name;
-         $tn{$d} = $iii ?
-           TrivGal::Image->new(join_paths $path, $d->name, $iii->name) :
-           undef;
+         my $p = join_paths $path, $d->name;
+         DIR: for (;;) {
+           my ($ddd, $fff, $iii) = listdir join_paths $IMGROOT, $p;
+           if (defined $iii) {
+             my $index = join_paths $p, $iii->name;
+             $tn{$d} = TrivGal::Image->new($index);
+             last DIR;
+           }
+           if (!@$ddd) { $tn{$d} = undef; last DIR; }
+           $p = join_paths $p, $ddd->[0]->name;
+         }
        }
 </%perl>
 %