chiark / gitweb /
mason/dhandler (.contact), static/tgal.css: Adaptive thumbnail sizes.
[tgal] / mason / dhandler
index 78f0f951fe2aa02e44d02b7a1eb8ec30a54b731d..c6f0f33ac480068d074c0c9f1148006ef9e0f575 100755 (executable)
@@ -83,11 +83,13 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
        }
        (my $nosl = $path) =~ s!/$!!;
 
-       my $size = "medthumb";
+       my @size = ("smallthumb", "medthumb", "bigthumb");
        my %tn;
        my %count;
-       for my $f (@$ff)
-         { $tn{$f} = TrivGal::Image->new($path . $f->name)->scale($size); }
+       for my $f (@$ff) {
+         my $img = TrivGal::Image->new($path . $f->name);
+         for my $size (@size) { $tn{$f}{$size} = $img->scale($size); }
+       }
        for my $d (@$dd) {
          my $p = join_paths $path, $d->name;
          my ($ddd, $fff, $iii);
@@ -101,7 +103,8 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
          DIR: for (;;) {
            if (defined $iii) {
              my $index = join_paths $p, $iii->name;
-             $tn{$d} = TrivGal::Image->new($index)->scale($size);
+             my $img = TrivGal::Image->new($index);
+             for my $size (@size) { $tn{$d}{$size} = $img->scale($size); }
              last DIR;
            }
            if (!@$ddd) { $tn{$d} = undef; last DIR; }
@@ -129,25 +132,30 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 %
 % if (@$dd) {
 <h2>Subfolders</h2>
+%   for my $size (@size) {
 <div class="gallery <% $size %>">
+%     for my $d (@$dd) {
   <& .thumbnail, target => $d->name, comment => $d->comment,
-                tn => $tn{$d}, size => $size,
+                tn => $tn{$d}{$size}, size => $size,
                 caption =>
                   $m->interp->apply_escapes($d->name, "h") .
                   " [$count{$d}]" &>\
-%   }
+%     }
 </div>
+%   }
 % }
 %
 % if (@$ff) {
 <h2>Images</h2>
+%   for my $size (@size) {
 <div class="gallery <% $size %>">
-%   for my $f (@$ff) {
+%     for my $f (@$ff) {
   <& .thumbnail, target => $f->name, comment => $f->comment,
-                tn => $tn{$f}, size => $size,
+                tn => $tn{$f}{$size}, size => $size,
                 caption => $m->interp->apply_escapes($f->name, "h") &>\
-%   }
+%     }
 </div>
+%   }
 % }
 %
 <div class=fill></div>