From ec14c563960e82427aa290a9c66d217cbcb9274a Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 26 Jul 2007 01:43:31 +0200 Subject: [PATCH] Fuse rot=1 and rot=0 arms into a single loop, reducing the amount of identical code. --- perl/Sesse/pr0n/Index.pm | 126 ++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 75 deletions(-) diff --git a/perl/Sesse/pr0n/Index.pm b/perl/Sesse/pr0n/Index.pm index 4ec1426..fab7971 100644 --- a/perl/Sesse/pr0n/Index.pm +++ b/perl/Sesse/pr0n/Index.pm @@ -316,43 +316,57 @@ sub handler { if ($rot == 1) { $r->print("
\n"); $r->print(" \n"); - - while (my $ref = $q->fetchrow_hashref()) { - my $imgsz = ""; - my $takenby = $ref->{'takenby'}; - if (defined($ref->{'day'})) { - $takenby .= ", " . $ref->{'day'}; - } + } - if ($takenby ne $lastupl) { - $lastupl = $takenby; - $r->print("

"); - Sesse::pr0n::Templates::print_template($r, "submittedby", { author => $lastupl }); - print_fullscreen_fromhere($r, $event, \%settings, \%defsettings, $img_num); - $r->print("

\n"); - } - if ($ref->{'width'} != -1 && $ref->{'height'} != -1) { - my $width = $ref->{'width'}; - my $height = $ref->{'height'}; - - ($width, $height) = Sesse::pr0n::Common::scale_aspect($width, $height, $thumbxres, $thumbyres); - $imgsz = " width=\"$width\" height=\"$height\""; - } + while (my $ref = $q->fetchrow_hashref()) { + my $imgsz = ""; + my $takenby = $ref->{'takenby'}; + if (defined($ref->{'day'})) { + $takenby .= ", " . $ref->{'day'}; + } - my $filename = $ref->{'filename'}; - my $uri = $infobox . $filename; - if (defined($xres) && defined($yres) && $xres != -1) { - $uri = "${xres}x$yres/$infobox$filename"; - } elsif (defined($xres) && $xres == -1) { - $uri = "original/$infobox$filename"; - } + if ($takenby ne $lastupl) { + $r->print("

\n\n") if ($lastupl ne "" && $rot != 1); + $lastupl = $takenby; + $r->print("

"); + Sesse::pr0n::Templates::print_template($r, "submittedby", { author => $lastupl }); + print_fullscreen_fromhere($r, $event, \%settings, \%defsettings, $img_num); + $r->print("

\n"); - my $prefix = ""; - if ($abspath) { - $prefix = "/" . $ref->{'event'} . "/"; + if ($rot != 1) { + $r->print("

\n"); } + } + + if ($ref->{'width'} != -1 && $ref->{'height'} != -1) { + my $width = $ref->{'width'}; + my $height = $ref->{'height'}; + + ($width, $height) = Sesse::pr0n::Common::scale_aspect($width, $height, $thumbxres, $thumbyres); + $imgsz = " width=\"$width\" height=\"$height\""; + } - $r->print("

\"\"$imgsz\n"); + my $filename = $ref->{'filename'}; + my $uri = $infobox . $filename; + if (defined($xres) && defined($yres) && $xres != -1) { + $uri = "${xres}x$yres/$infobox$filename"; + } elsif (defined($xres) && $xres == -1) { + $uri = "original/$infobox$filename"; + } + + my $prefix = ""; + if ($abspath) { + $prefix = "/" . $ref->{'event'} . "/"; + } + + if ($rot == 1) { + $r->print("

"); + } else { + $r->print(" "); + } + $r->print("\"\"$imgsz\n"); + + if ($rot == 1) { $r->print(" 90 {'id'} . "-90\" />\n"); $r->print(" 180 {'id'} . "-270\" />\n"); $r->print("        " . "     Del {'id'} . "\" />

\n"); - - ++$img_num; } + + ++$img_num; + } + + if ($rot == 1) { $r->print(" \n"); $r->print("
\n"); } else { - while (my $ref = $q->fetchrow_hashref()) { - my $imgsz = ""; - my $takenby = $ref->{'takenby'}; - if (defined($ref->{'day'})) { - $takenby .= ", " . $ref->{'day'}; - } - - if ($takenby ne $lastupl) { - $r->print("

\n\n") if ($lastupl ne ""); - $lastupl = $takenby; - $r->print("

"); - Sesse::pr0n::Templates::print_template($r, "submittedby", { author => $lastupl }); - print_fullscreen_fromhere($r, $event, \%settings, \%defsettings, $img_num); - $r->print("

\n"); - $r->print("

\n"); - } - if ($ref->{'width'} != -1 && $ref->{'height'} != -1) { - my $width = $ref->{'width'}; - my $height = $ref->{'height'}; - - ($width, $height) = Sesse::pr0n::Common::scale_aspect($width, $height, $thumbxres, $thumbyres); - $imgsz = " width=\"$width\" height=\"$height\""; - } - - my $filename = $ref->{'filename'}; - my $uri = $infobox . $filename; - if (defined($xres) && defined($yres) && $xres != -1) { - $uri = "${xres}x$yres/$infobox$filename"; - } elsif (defined($xres) && $xres == -1) { - $uri = "original/$infobox$filename"; - } - - my $prefix = ""; - if ($abspath) { - $prefix = "/" . $ref->{'event'} . "/"; - } - - $r->print(" \"\"$imgsz\n"); - - ++$img_num; - } $r->print("

\n"); } -- 2.39.2