Add a new and very hip fullscreen interface; not exposed to the users just yet,
[pr0n] / perl / Sesse / pr0n / Index.pm
index 178245369e346eb6e6bdeeb758899a778ed46db6..52766ab3a435513cbf568ba3401bd65391e2fdd5 100644 (file)
@@ -50,13 +50,14 @@ sub handler {
        }
                
        my %settings = %defsettings;
+       my $fullscreen = (defined($apr->param('fullscreen')) && $apr->param('fullscreen') eq '1');
 
        for my $s qw(thumbxres thumbyres xres yres start num all infobox rot sel) {
                my $val = $apr->param($s);
                if (defined($val) && $val =~ /^(\d+)$/) {
                        $settings{$s} = $val;
                }
-               if ($s eq "num" && defined($val) && $val == -1) {
+               if (($s eq "num" || $s eq "xres" || $s eq "yres") && defined($val) && $val == -1) {
                        $settings{$s} = $val;
                }
        }
@@ -102,136 +103,151 @@ sub handler {
                or dberror($r, "image enumeration");
 
        # Print the page itself
-       Sesse::pr0n::Common::header($r, "$name [$event]");
-       Sesse::pr0n::Templates::print_template($r, "date", { date => $date });
-
-       if (Sesse::pr0n::Overload::is_in_overload($r)) {
-               Sesse::pr0n::Templates::print_template($r, "overloadmode");
-       }
-
-       print_thumbsize($r, $event, \%settings, \%defsettings);
-       print_viewres($r, $event, \%settings, \%defsettings);
-       print_pagelimit($r, $event, \%settings, \%defsettings);
-       print_infobox($r, $event, \%settings, \%defsettings);
-       print_nextprev($r, $event, \%settings, \%defsettings);
-       print_selected($r, $event, \%settings, \%defsettings) if ($num_selected > 0);
-
-       my $toclose = 0;
-       my $lastupl = "";
-       
-       # Print out all thumbnails
-       if ($rot == 1) {
-               $r->print("    <form method=\"post\" action=\"/rotate\">\n");
-       
+       if ($fullscreen) {
+               $r->content_type("text/html; charset=utf-8");
+               Sesse::pr0n::Templates::print_template($r, "fullscreen-header", { title => "$name [$event]" });
                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;
-                               Sesse::pr0n::Templates::print_template($r, "submittedby", { author => $lastupl });
-                       }
-                       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 = $filename;
-                       if (defined($xres) && defined($yres)) {
-                               $uri = "${xres}x$yres/$infobox$filename";
-                       }
-
-                       $r->print("    <p><a href=\"$uri\"><img src=\"${thumbxres}x${thumbyres}/$filename\" alt=\"\"$imgsz /></a>\n");
-                       $r->print("      90 <input type=\"checkbox\" name=\"rot-" .
-                               $ref->{'id'} . "-90\" />\n");
-                       $r->print("      180 <input type=\"checkbox\" name=\"rot-" .
-                               $ref->{'id'} . "-180\" />\n");
-                       $r->print("      270 <input type=\"checkbox\" name=\"rot-" .
-                               $ref->{'id'} . "-270\" />\n");
-                       $r->print("      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" .
-                               "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Del <input type=\"checkbox\" name=\"del-" . $ref->{'id'} . "\" /></p>\n");
+                       $r->print("        \"" . $ref->{'filename'} . "\",\n");
                }
-               $r->print("      <input type=\"submit\" value=\"Rotate\" />\n");
-               $r->print("    </form>\n");
-       } elsif ($sel == 1) {
-               $r->print("    <form method=\"post\" action=\"/select\">\n");
-               $r->print("      <input type=\"hidden\" name=\"event\" value=\"$event\" />\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;
-                               Sesse::pr0n::Templates::print_template($r, "submittedby", { author => $lastupl });
-                       }
-                       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 = $filename;
-                       if (defined($xres) && defined($yres)) {
-                               $uri = "${xres}x$yres/$infobox$filename";
-                       }
-
-                       my $selected = $ref->{'selected'} ? ' checked="checked"' : '';
+               Sesse::pr0n::Templates::print_template($r, "fullscreen-footer", { vhost => $r->get_server_name, event => $event, start => $settings{'start'} - 1 });
+       } else {
+               Sesse::pr0n::Common::header($r, "$name [$event]");
+               Sesse::pr0n::Templates::print_template($r, "date", { date => $date });
 
-                       $r->print("    <p><a href=\"$uri\"><img src=\"${thumbxres}x${thumbyres}/$filename\" alt=\"\"$imgsz /></a>\n");
-                       $r->print("      <input type=\"checkbox\" name=\"sel-" .
-                               $ref->{'id'} . "\"$selected /></p>\n");
+               if (Sesse::pr0n::Overload::is_in_overload($r)) {
+                       Sesse::pr0n::Templates::print_template($r, "overloadmode");
                }
-               $r->print("      <input type=\"submit\" value=\"Select\" />\n");
-               $r->print("    </form>\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("    </p>\n\n") if ($lastupl ne "");
-                               $lastupl = $takenby;
-                               Sesse::pr0n::Templates::print_template($r, "submittedby", { author => $lastupl });
-                               $r->print("    <p>\n");
+               print_thumbsize($r, $event, \%settings, \%defsettings);
+               print_viewres($r, $event, \%settings, \%defsettings);
+               print_pagelimit($r, $event, \%settings, \%defsettings);
+               print_infobox($r, $event, \%settings, \%defsettings);
+               print_nextprev($r, $event, \%settings, \%defsettings);
+               print_selected($r, $event, \%settings, \%defsettings) if ($num_selected > 0);
+
+               my $toclose = 0;
+               my $lastupl = "";
+               
+               # Print out all thumbnails
+               if ($rot == 1) {
+                       $r->print("    <form method=\"post\" action=\"/rotate\">\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;
+                                       Sesse::pr0n::Templates::print_template($r, "submittedby", { author => $lastupl });
+                               }
+                               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 = $filename;
+                               if (defined($xres) && defined($yres) && $xres != -1) {
+                                       $uri = "${xres}x$yres/$infobox$filename";
+                               } elsif (defined($xres) && $xres == -1) {
+                                       $uri = "original/$infobox$filename";
+                               }
+
+                               $r->print("    <p><a href=\"$uri\"><img src=\"${thumbxres}x${thumbyres}/$filename\" alt=\"\"$imgsz /></a>\n");
+                               $r->print("      90 <input type=\"checkbox\" name=\"rot-" .
+                                       $ref->{'id'} . "-90\" />\n");
+                               $r->print("      180 <input type=\"checkbox\" name=\"rot-" .
+                                       $ref->{'id'} . "-180\" />\n");
+                               $r->print("      270 <input type=\"checkbox\" name=\"rot-" .
+                                       $ref->{'id'} . "-270\" />\n");
+                               $r->print("      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" .
+                                       "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Del <input type=\"checkbox\" name=\"del-" . $ref->{'id'} . "\" /></p>\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("      <input type=\"submit\" value=\"Rotate\" />\n");
+                       $r->print("    </form>\n");
+               } elsif ($sel == 1) {
+                       $r->print("    <form method=\"post\" action=\"/select\">\n");
+                       $r->print("      <input type=\"hidden\" name=\"event\" value=\"$event\" />\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;
+                                       Sesse::pr0n::Templates::print_template($r, "submittedby", { author => $lastupl });
+                               }
+                               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 = $filename;
+                               if (defined($xres) && defined($yres) && $xres != -1) {
+                                       $uri = "${xres}x$yres/$infobox$filename";
+                               } elsif (defined($xres) && $xres == -1) {
+                                       $uri = "original/$infobox$filename";
+                               }
+
+                               my $selected = $ref->{'selected'} ? ' checked="checked"' : '';
+
+                               $r->print("    <p><a href=\"$uri\"><img src=\"${thumbxres}x${thumbyres}/$filename\" alt=\"\"$imgsz /></a>\n");
+                               $r->print("      <input type=\"checkbox\" name=\"sel-" .
+                                       $ref->{'id'} . "\"$selected /></p>\n");
                        }
-
-                       my $filename = $ref->{'filename'};
-                       my $uri = $filename;
-                       if (defined($xres) && defined($yres)) {
-                               $uri = "${xres}x$yres/$infobox$filename";
+                       $r->print("      <input type=\"submit\" value=\"Select\" />\n");
+                       $r->print("    </form>\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("    </p>\n\n") if ($lastupl ne "");
+                                       $lastupl = $takenby;
+                                       Sesse::pr0n::Templates::print_template($r, "submittedby", { author => $lastupl });
+                                       $r->print("    <p>\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 = $filename;
+                               if (defined($xres) && defined($yres) && $xres != -1) {
+                                       $uri = "${xres}x$yres/$infobox$filename";
+                               } elsif (defined($xres) && $xres == -1) {
+                                       $uri = "original/$infobox$filename";
+                               }
+                               
+                               $r->print("      <a href=\"$uri\"><img src=\"${thumbxres}x${thumbyres}/$filename\" alt=\"\"$imgsz /></a>\n");
                        }
-                       
-                       $r->print("      <a href=\"$uri\"><img src=\"${thumbxres}x${thumbyres}/$filename\" alt=\"\"$imgsz /></a>\n");
+                       $r->print("    </p>\n");
                }
-               $r->print("    </p>\n");
-       }
 
-       print_nextprev($r, $event, \%settings, \%defsettings);
-       Sesse::pr0n::Common::footer($r);
+               print_nextprev($r, $event, \%settings, \%defsettings);
+               Sesse::pr0n::Common::footer($r);
+       }
 
        return Apache2::Const::OK;
 }
@@ -252,16 +268,23 @@ sub print_changes {
        $r->print("    <p>$title:\n");
 
        for my $a (@$alternatives) {
-               # Parse the current alternative
-               my ($v1, $v2) = split /x/, $a;
+               my $text;
                my %newsettings = %$settings;
 
-               if (defined($v1) && defined($v2)) {
+               if (ref $a) {
+                       my ($v1, $v2);
+                       ($text, $v1, $v2) = @$a;
+                       
                        $newsettings{$var1} = $v1;
                        $newsettings{$var2} = $v2;
                } else {
-                       $newsettings{$var1} = undef;
-                       $newsettings{$var2} = undef;
+                       $text = $a;
+
+                       # Parse the current alternative
+                       my ($v1, $v2) = split /x/, $a;
+
+                       $newsettings{$var1} = $v1;
+                       $newsettings{$var2} = $v2;
                }
 
                $r->print("      ");
@@ -269,9 +292,9 @@ sub print_changes {
                # Check if these settings are current (print only label)
                if (eq_with_undef($settings->{$var1}, $newsettings{$var1}) &&
                    eq_with_undef($settings->{$var2}, $newsettings{$var2})) {
-                       $r->print($a);
+                       $r->print($text);
                } else {
-                       Sesse::pr0n::Common::print_link($r, $a, "/$event/", \%newsettings, $defsettings);
+                       Sesse::pr0n::Common::print_link($r, $text, "/$event/", \%newsettings, $defsettings);
                }
                $r->print("\n");
        }
@@ -289,7 +312,9 @@ sub print_viewres {
        my ($r, $event, $settings, $defsettings) = @_;
        my @alternatives = qw(320x256 512x384 640x480 800x600 1024x768 1280x960);
        chomp (my $unlimited = Sesse::pr0n::Templates::fetch_template($r, 'viewres-unlimited'));
-       push @alternatives, $unlimited;
+       chomp (my $original = Sesse::pr0n::Templates::fetch_template($r, 'viewres-original'));
+       push @alternatives, [ $unlimited, undef, undef ];
+       push @alternatives, [ $original, -1, -1 ];
 
        print_changes($r, $event, 'viewres', $settings, $defsettings,
                      'xres', 'yres', \@alternatives);