mason/dhandler: Make `.breadcrumbs' be a filter.
[tgal] / mason / dhandler
index de50cd8..f523432 100755 (executable)
@@ -35,8 +35,8 @@ of the GNU Affero General Public License.
 <html>
 <head>
   <meta name=viewport content="width=device-width initial-scale=1.0">
-  <script type="text/javascript" src="<% "$STATICURL/tgal.js" |u %>" defer></script>
-  <link rel=stylesheet type=text/css href="<% "$STATICURL/tgal.css" |u %>">
+  <script type="text/javascript" src="<% "$STATICURL/tgal.js" |hu %>" defer></script>
+  <link rel=stylesheet type=text/css href="<% "$STATICURL/tgal.css" |hu %>">
 <% $head %>\
   <title><% $title %></title>
 </head>
@@ -85,12 +85,15 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 
        my $size = "medthumb";
        my %tn;
+       my (%nd, %nf);
        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;
          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)->scale($size);
@@ -98,6 +101,7 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
            }
            if (!@$ddd) { $tn{$d} = undef; last DIR; }
            $p = join_paths $p, $ddd->[0]->name;
+           ($ddd, $fff, $iii) = listdir join_paths $IMGROOT, $p;
          }
        }
 </%perl>
@@ -118,9 +122,13 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 <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") &>\
+                caption =>
+                  $m->interp->apply_escapes($d->name, "h") . " [$count]" &>\
 %   }
 </div>
 % }
@@ -207,13 +215,13 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 %
 <div class=viewnav>
 % if ($link{prev}) {
-  <div class=prev><a class=prev href="<% "$pre/$link{prev}" |u %>">&lsaquo;</a></div>
+  <div class=prev><a class=prev href="<% "$pre/$link{prev}" |hu %>">&lsaquo;</a></div>
 % }
   <a class=view href="<% $url |h %>">
     <img src="<% $vw |h %>">
   </a>
 % if ($link{next}) {
-  <div class=next><a class=next href="<% "$pre/$link{next}" |u %>">&rsaquo;</a></div>
+  <div class=next><a class=next href="<% "$pre/$link{next}" |hu %>">&rsaquo;</a></div>
 % }
 </div>
 %
@@ -246,17 +254,21 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 % if (!@p) {
 [top]
 % } else {
-<a href="<% $SCRIPTURL |u %>/">[top]</a>&thinsp;/&thinsp;\
+<a href="<% $SCRIPTURL |hu %>/">[top]</a>&thinsp;/&thinsp;\
 %   STEP: for my $p (@p) {
 %     if (defined $prev) {
 %       $pp .= "$prev/";
-<a href="<% join_paths($SCRIPTURL, $pp) |u %>/">\
+<a href="<% join_paths($SCRIPTURL, $pp) |hu %>/">\
 <% $prev %></a>&thinsp;/&thinsp;\
 %     }
 %     $prev = $p;
 %   }
 <% $prev %>\
 % }
+% if ($m->has_content) {
+
+<% $m->content %>\
+% }
 </h1>
 <%args>
        $what
@@ -269,12 +281,12 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 % $tn //= "$STATICURL/folder.svg";
 % if ($focus) {
   <figure class="thumb focusthumb <% $size %>">
-    <img class="thumb <% $size %>" load=lazy src="<% $tn |h %>">
+    <img class="thumb <% $size %>" loading=lazy src="<% $tn |h %>">
     <figcaption><span class=name><% $caption %></span></figcaption>
 % } else {
   <figure class="thumb <% $size %>">
-    <a class=thumb href="<% $target |u %>">
-      <img class="thumb <% $size %>" load=lazy src="<% $tn |h %>">
+    <a class=thumb href="<% $target |hu %>">
+      <img class="thumb <% $size %>" loading=lazy src="<% $tn |h %>">
       <figcaption>
        <span class=name><% $caption %></span>
 % if (defined $comment) {
@@ -301,7 +313,7 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
 </%perl>
 <div class=footer>
   <div class=footitem>
-    <a href="https://www.gnu.org/licenses/agpl-3.0.en.html"><img class=licence src="<% "$STATICURL/agpl.png" |u %>"></a>
+    <a href="https://www.gnu.org/licenses/agpl-3.0.en.html"><img class=licence src="<% "$STATICURL/agpl.png" |hu %>"></a>
     Trivial Gallery, copyright &copy; 2021 Mark Wooding.
     Free software: you can modify it and/or redistribute it under the
     terms of the