mason/dhandler (.contact): Determine the `count' strings in advance.
[tgal] / mason / dhandler
index 0c834b9..78f0f95 100755 (executable)
@@ -85,14 +85,19 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 
        my $size = "medthumb";
        my %tn;
-       my (%nd, %nf);
+       my %count;
        for my $f (@$ff)
          { $tn{$f} = TrivGal::Image->new($path . $f->name)->scale($size); }
        for my $d (@$dd) {
          my $p = join_paths $path, $d->name;
          my ($ddd, $fff, $iii);
          ($ddd, $fff, $iii) = listdir join_paths $IMGROOT, $p;
-         $nd{$d} = @$ddd; $nf{$d} = @$fff;
+
+         my $count = "";
+         $count .= scalar(@$ddd) . "/" if @$ddd;
+         $count .= scalar(@$fff) if @$fff;
+         $count{$d} = $count;
+
          DIR: for (;;) {
            if (defined $iii) {
              my $index = join_paths $p, $iii->name;
@@ -125,14 +130,11 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 % if (@$dd) {
 <h2>Subfolders</h2>
 <div class="gallery <% $size %>">
-%   for my $d (@$dd) {
-%     my $count = "";
-%     $count .= "$nd{$d}/" if $nd{$d};
-%     $count .= "$nf{$d}" if $nf{$d};
   <& .thumbnail, target => $d->name, comment => $d->comment,
                 tn => $tn{$d}, size => $size,
                 caption =>
-                  $m->interp->apply_escapes($d->name, "h") . " [$count]" &>\
+                  $m->interp->apply_escapes($d->name, "h") .
+                  " [$count{$d}]" &>\
 %   }
 </div>
 % }