X-Git-Url: https://git.distorted.org.uk/~mdw/tgal/blobdiff_plain/6ac5dde2c2826f066d96e167f6f1fcdc46d5fab4..62ee1c09a43f22ade7b5f75e3cae56c38aa7b84f:/mason/dhandler
diff --git a/mason/dhandler b/mason/dhandler
index 4355b7a..d36722b 100755
--- a/mason/dhandler
+++ b/mason/dhandler
@@ -67,9 +67,9 @@ Failed to find ‘<% $path |h %>’.
%###-------------------------------------------------------------------------
<%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;
@@ -82,9 +82,21 @@ Failed to find ‘<% $path |h %>’.
urlencode "$SCRIPTURL/$uplink";
}
(my $nosl = $path) =~ s!/$!!;
+
+ my $size = "medthumb";
+ my %tn;
+ for my $f (@$ff)
+ { $tn{$f} = TrivGal::Image->new($path . $f->name); }
+ for my $d (@$dd) {
+ my ($ddd, $fff, $iii) = listdir $real . "/" . $d->name;
+ $tn{$d} = $iii ?
+ TrivGal::Image->new(join_paths $path, $d->name, $iii->name) :
+ undef;
+ }
%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 &>
%
@@ -97,26 +109,22 @@ Failed to find ‘<% $path |h %>’.
%
% if (@$dd) {
+
% 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,
+ img => $tn{$d}, size => $size,
+ caption => $m->interp->apply_escapes($d->name, "h") &>\
% }
% }
%
% if (@$ff) {
Images
-
+
% 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,
+ img => $tn{$f}, size => $size,
+ caption => $m->interp->apply_escapes($f->name, "h") &>\
% }
% }
@@ -135,11 +143,15 @@ Failed to find ‘<% $path |h %>’.
<%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++)
@@ -189,18 +201,22 @@ Failed to find ‘<% $path |h %>’.
% }
%
-
-% 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}) {
+
+% for my $f (@$ff) {
+ <& .thumbnail, target => $f->name, img => $img{$f}, size => $size,
caption => $m->interp->apply_escapes($f->name, "h"),
- focus => $f->name eq "$base$ext" &>\
-% }
+ focus => $f eq $this &>\
+% }
+% }
<& .footer, path => $dir &>
&>
%
<%args>
$path
+ $scale => undef
%args>
%def>
%
@@ -235,29 +251,30 @@ Failed to find ‘<% $path |h %>’.
%###-------------------------------------------------------------------------
<%def .thumbnail>\
% my $tn;
-% if (defined $img) { $tn = scaled "thumb", $img; }
+% if (defined $img) { $tn = $img->scale($size); }
% else { $tn = "$STATICURL/folder.svg"; }
% if ($focus) {
-
-
![](<% $tn |u %>)
-
<% $caption %>
+
+
+ <% $caption %>
% } else {
-
+
%
<%args>
$target
$img
+ $size
$caption
$comment => undef
$focus => 0
@@ -274,10 +291,9 @@ Failed to find ‘<% $path |h %>’.
Trivial Gallery, copyright © 2021 Mark Wooding.
Free software: you can modify it and/or redistribute it under the
terms of the
-
GNU Affero
+ GNU Affero
General Public License version 3.
- Browse or download
- the
source code.
+ Browse or download the
source code.
% my $user =
% find_covering_file $IMGROOT, $path, ".tgal-footer.html";
@@ -295,7 +311,6 @@ Failed to find ‘<% $path |h %>’.
%###-------------------------------------------------------------------------
<%once>
use autodie;
-use Data::Dumper;
use File::stat;
use TrivGal;
@@ -311,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 -------------------------------------------------