%###-------------------------------------------------------------------------
<%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;
urlencode "$SCRIPTURL/$uplink";
}
(my $nosl = $path) =~ s!/$!!;
+
+ my $size = "medthumb";
+ my %tn;
+ 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;
+ 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);
+ last DIR;
+ }
+ if (!@$ddd) { $tn{$d} = undef; last DIR; }
+ $p = join_paths $p, $ddd->[0]->name;
+ }
+ }
</%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 &>
%
%
% if (@$dd) {
<h2>Subfolders</h2>
-<div class=gallery>
+<div class="gallery <% $size %>">
% for my $d (@$dd) {
-% my ($ddd, $fff, $iii) = listdir $real . "/" . $d->name;
-% my $tn;
-% if ($iii) { $tn = join_paths $path, $d->name . "/" . $iii->name; }
-% else { $tn = undef; }
- <& .thumbnail, target => $d->name . "/", img => $tn,
- caption => $m->interp->apply_escapes($d->name, "h"),
- comment => $d->comment &>\
+ <& .thumbnail, target => $d->name, comment => $d->comment,
+ tn => $tn{$d}, size => $size,
+ caption => $m->interp->apply_escapes($d->name, "h") &>\
% }
</div>
% }
%
% if (@$ff) {
<h2>Images</h2>
-<div class=gallery>
+<div class="gallery <% $size %>">
% for my $f (@$ff) {
- <& .thumbnail, target => $f->name, img => $path . $f->name,
- caption => $m->interp->apply_escapes($f->name, "h"),
- comment => $f->comment &>\
+ <& .thumbnail, target => $f->name, comment => $f->comment,
+ tn => $tn{$f}, size => $size,
+ caption => $m->interp->apply_escapes($f->name, "h") &>\
% }
</div>
% }
<%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 = scaled "view", $path;
+ my $vw = $img->scale("view");
my $fi = undef;
FILE: for (my $i = 0; $i < @$ff; $i++)
% }
</div>
%
-<div class=thumbstrip>
-% for my $f (@$ff) {
- <& .thumbnail, target => $f->name, img => $dir . "/" . $f->name,
+% my %img = map { $_ => TrivGal::Image->new($dir . "/" . $_->name) } @$ff;
+% for my $size (qw{smallthumb medthumb bigthumb}) {
+<div class="thumbstrip <% $size %>">
+% for my $f (@$ff) {
+ <& .thumbnail, target => $f->name,
+ img => $img{$f}->scale($size), size => $size,
caption => $m->interp->apply_escapes($f->name, "h"),
- focus => $f->name eq "$base$ext" &>\
-% }
+ focus => $f eq $this &>\
+% }
</div>
+% }
<& .footer, path => $dir &>
</&>
%
<%args>
$path
+ $scale => undef
</%args>
</%def>
%
%
%###-------------------------------------------------------------------------
<%def .thumbnail>\
-% my $tn;
-% if (defined $img) { $tn = scaled "thumb", $img; }
-% else { $tn = "$STATICURL/folder.svg"; }
+% $tn //= "$STATICURL/folder.svg";
% if ($focus) {
- <div class=thumb id=focusthumb>
- <img class=thumb src="<% $tn |u %>">
- <div class=caption><span class=name><% $caption %></span></div>
+ <figure class="thumb focusthumb <% $size %>">
+ <img class="thumb <% $size %>" load=lazy src="<% $tn |h %>">
+ <figcaption><span class=name><% $caption %></span></figcaption>
% } else {
- <div class=thumb>
+ <figure class="thumb <% $size %>">
<a class=thumb href="<% $target |u %>">
- <img class=thumb src="<% $tn |u %>">
- <div class=caption>
+ <img class="thumb <% $size %>" load=lazy src="<% $tn |h %>">
+ <figcaption>
<span class=name><% $caption %></span>
% if (defined $comment) {
<span class=comment><% $comment %></span>
% }
- </div>
+ </figcaption>
</a>
% }
- </div>
+ </figure>
%
<%args>
$target
- $img
+ $tn
+ $size
$caption
$comment => undef
$focus => 0
Trivial Gallery, copyright © 2021 Mark Wooding.
Free software: you can modify it and/or redistribute it under the
terms of the
- <a href="https://www.gnu.org/licenses/agpl-3.0.en.html">GNU Affero
+ <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";
%###-------------------------------------------------------------------------
<%once>
use autodie;
-use Data::Dumper;
use File::stat;
use TrivGal;
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 -------------------------------------------------