X-Git-Url: https://git.sesse.net/?p=pr0n;a=blobdiff_plain;f=perl%2FSesse%2Fpr0n%2FIndex.pm;h=fab7971956a166bf54f4ed5431c727bc08f0e2df;hp=39c5da43f97000fef1a96b401ebd3239efece9e5;hb=ec14c563960e82427aa290a9c66d217cbcb9274a;hpb=42d4fc8288f205794e964cacb04871ef04f01043 diff --git a/perl/Sesse/pr0n/Index.pm b/perl/Sesse/pr0n/Index.pm index 39c5da4..fab7971 100644 --- a/perl/Sesse/pr0n/Index.pm +++ b/perl/Sesse/pr0n/Index.pm @@ -11,13 +11,20 @@ sub handler { my $apr = Apache2::Request->new($r); my $dbh = Sesse::pr0n::Common::get_dbh(); - my ($event, $abspath, $datesort); + my ($event, $abspath, $datesort, $tag); if ($r->uri =~ /^\/\+all\/?/) { $event = '+all'; $abspath = 1; + $tag = undef; # augh, this needs 8.3, so we'll have to fiddle around a bit instead # $datesort = 'DESC NULLS LAST'; + $datesort = 'DESC'; + } elsif ($r->uri =~ /^\/\+tags\/([a-zA-Z0-9-]+)\/?$/) { + $tag = $1; + $event = "+tags/$tag"; + $abspath = 1; + $datesort = 'DESC'; } else { # Find the event @@ -25,12 +32,13 @@ sub handler { or error($r, "Could not extract event"); $event = $1; $abspath = 0; + $tag = undef; $datesort = 'ASC'; } # Fix common error: pr0n.sesse.net/event -> pr0n.sesse.net/event/ if ($r->uri !~ /\/$/) { - $r->headers_out->{'location'} = "/$event/"; + $r->headers_out->{'location'} = $r->uri . "/"; return Apache2::Const::REDIRECT; } @@ -60,7 +68,10 @@ sub handler { ); my $where; - if ($event eq '+all') { + if (defined($tag)) { + my $tq = $dbh->quote($tag); + $where = " AND id IN ( SELECT image FROM tags WHERE tag=$tq )"; + } elsif ($event eq '+all') { $where = ''; } else { $where = ' AND event=' . $dbh->quote($event); @@ -87,8 +98,7 @@ sub handler { $settings{$s} = $val; } if ($s eq "model" || $s eq "lens") { - $val =~ s/_/ /g; - $settings{$s} = $val; + $settings{$s} = Sesse::pr0n::Common::pretty_unescape($val); } } @@ -135,7 +145,7 @@ sub handler { my ($date, $name); - if ($event eq '+all') { + if ($event eq '+all' || defined($tag)) { $ref = $dbh->selectrow_hashref("SELECT EXTRACT(EPOCH FROM MAX(last_update)) AS last_update FROM events WHERE vhost=?", undef, $r->get_server_name) or error($r, "Could not list events", 404, "File not found"); @@ -172,9 +182,23 @@ sub handler { # Print the page itself if ($settings{'fullscreen'}) { $r->content_type("text/html; charset=utf-8"); - Sesse::pr0n::Templates::print_template($r, "fullscreen-header", { title => "$name [$event]" }); + + if (defined($tag)) { + my $title = Sesse::pr0n::Templates::process_template($r, "tag-title", { tag => $tag }); + Sesse::pr0n::Templates::print_template($r, "fullscreen-header", { title => $title }); + } else { + Sesse::pr0n::Templates::print_template($r, "fullscreen-header", { title => "$name [$event]" }); + } + + my @files = (); while (my $ref = $q->fetchrow_hashref()) { - $r->print(" [ \"" . $ref->{'event'} . "\", \"" . $ref->{'filename'} . "\" ],\n"); + push @files, [ $ref->{'event'}, $ref->{'filename'} ]; + } + + for my $i (0..$#files) { + $r->print(" [ \"" . $files[$i]->[0] . "\", \"" . $files[$i]->[1] . "\" ]"); + $r->print(",") unless ($i == $#files); + $r->print("\n"); } my %settings_no_fullscreen = %settings; @@ -194,7 +218,12 @@ sub handler { infobox => $infobox }); } else { - Sesse::pr0n::Common::header($r, "$name [$event]"); + if (defined($tag)) { + my $title = Sesse::pr0n::Templates::process_template($r, "tag-title", { tag => $tag }); + Sesse::pr0n::Common::header($r, $title); + } else { + Sesse::pr0n::Common::header($r, "$name [$event]"); + } if (defined($date)) { Sesse::pr0n::Templates::print_template($r, "date", { date => $date }); } @@ -287,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"); } + } - $r->print("

\"\"$imgsz\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'} . "/"; + } + + 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"); }