mason/dhandler (.contact): Strip out the multiple-size machinery.
[tgal] / mason / dhandler
index 24b5026..979419d 100755 (executable)
@@ -67,9 +67,9 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 %###-------------------------------------------------------------------------
 <%def .contact>\
 <%perl>
-       unless ($r->path_info =~ m!/$!) {
-         $m->redirect(join_paths($SCRIPTURL, $path) . "/");
-       }
+       unless ($r->path_info =~ m!/$!)
+         { $m->redirect(join_paths($SCRIPTURL, $path) . "/"); }
+
        my $real = join_paths $IMGROOT, $path;
        my $url = join_paths $SCRIPTURL, $path;
        my ($dd, $ff, $ii) = listdir $real;
@@ -83,6 +83,7 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
        }
        (my $nosl = $path) =~ s!/$!!;
 
+       my $size = "medthumb";
        my %tn;
        for my $f (@$ff)
          { $tn{$f} = TrivGal::Image->new($path . $f->name); }
@@ -94,7 +95,8 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
        }
 </%perl>
 %
-<&| .html, title => "Folder " . $m->interp->apply_escapes($nosl || "[top]", "h"),
+<&| .html, title =>
+            "Folder " . $m->interp->apply_escapes($nosl || "[top]", "h"),
           head => $links &>
 <& .breadcrumbs, what => "Folder", path => $path &>
 %
@@ -107,28 +109,24 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 %
 % if (@$dd) {
 <h2>Subfolders</h2>
-%   for my $size (qw{medthumb}) {
 <div class="gallery <% $size %>">
-%     for my $d (@$dd) {
-  <& .thumbnail, target => $d->name . "/", comment => $d->comment,
+%   for my $d (@$dd) {
+  <& .thumbnail, target => $d->name, comment => $d->comment,
                 img => $tn{$d}, size => $size,
                 caption => $m->interp->apply_escapes($d->name, "h") &>\
-%     }
-</div>
 %   }
+</div>
 % }
 %
 % if (@$ff) {
 <h2>Images</h2>
-%   for my $size (qw{medthumb}) {
 <div class="gallery <% $size %>">
-%     for my $f (@$ff) {
+%   for my $f (@$ff) {
   <& .thumbnail, target => $f->name, comment => $f->comment,
-                img => $tn{$f}, size => "bigthumb",
+                img => $tn{$f}, size => $size,
                 caption => $m->interp->apply_escapes($f->name, "h") &>\
-%     }
-</div>
 %   }
+</div>
 % }
 %
 <div class=fill></div>
@@ -145,11 +143,15 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 <%perl>
        my ($dir, $base, $ext) = split_path $path;
        my $real = join_paths $IMGROOT, $path;
+       my $img = TrivGal::Image->new($path);
+
+       if (defined $scale) { $m->redirect($img->scale($scale)); }
+
        my $url = join_paths $IMGURL, $path;
        my $realdir = join_paths $IMGROOT, $dir;
        my $urldir = join_paths $SCRIPTURL, $dir;
        my ($dd, $ff, $ii) = listdir $realdir;
-       my $vw = TrivGal::Image->new($path)->scale("view");
+       my $vw = $img->scale("view");
 
        my $fi = undef;
        FILE: for (my $i = 0; $i < @$ff; $i++)
@@ -214,6 +216,7 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 %
 <%args>
        $path
+       $scale => undef
 </%args>
 </%def>
 %
@@ -290,8 +293,7 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
     terms of the
     <a rel=license href="https://www.gnu.org/licenses/agpl-3.0.en.html">GNU Affero
     General Public License version 3</a>.
-    Browse or download
-    the <a href="https://git.distorted.org.uk/~mdw/tgal/">source code</a>.
+    Browse or download the <a href="<% $SRCURL %>">source code</a>.
   </div>
 % my $user =
 %   find_covering_file $IMGROOT, $path, ".tgal-footer.html";
@@ -309,7 +311,6 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 %###-------------------------------------------------------------------------
 <%once>
        use autodie;
-use Data::Dumper;
        use File::stat;
 
        use TrivGal;
@@ -325,7 +326,8 @@ use Data::Dumper;
        elsif (-d $st) { $comp = ".contact"; }
        elsif (-f $st) { $comp = ".image"; }
        else { $comp = ".not-found"; }
-       $m->comp($comp, path => $path);
+        $r->header_out("X-AGPL-Source" => $SRCURL);
+       $m->comp($comp, path => $path, %ARGS);
 </%init>
 %
 %###----- That's all, folks -------------------------------------------------