]> git.sesse.net Git - pr0n/blobdiff - perl/Sesse/pr0n/Index.pm
Fix an (irrelevant) confusion about addEventListener.
[pr0n] / perl / Sesse / pr0n / Index.pm
index 3f9e52498e9be02a5338a611c75c5e960d2dbf3f..d72be98bc82799abc98e5f01d1d8a9171eb5fb81 100644 (file)
@@ -58,13 +58,13 @@ sub handler {
        
        my $where;
        if ($event eq '+all') {
-               $where = '';
+               $where = ' AND (event,vhost) IN ( SELECT event,vhost FROM events WHERE NOT hidden )';
        } else {
                $where = ' AND event=' . $dbh->quote($event);
        }
        
-       # Any NEF files => default to processing
-       my $ref = $dbh->selectrow_hashref("SELECT * FROM images WHERE vhost=? $where AND ( LOWER(filename) LIKE '%.nef' OR LOWER(filename) LIKE '%.cr2' ) LIMIT 1",
+       # Any NEF files with no non-NEF renders => default to processing
+       my $ref = $dbh->selectrow_hashref("SELECT * FROM images WHERE vhost=? $where AND ( LOWER(filename) LIKE '%.nef' OR LOWER(filename) LIKE '%.cr2' ) AND render_id IS NULL LIMIT 1",
                undef, Sesse::pr0n::Common::get_server_name($r))
                and $defsettings{'xres'} = $defsettings{'yres'} = undef;
        
@@ -122,9 +122,8 @@ sub handler {
                }
        }
        if (defined($author)) {
-               my $aq = $dbh->quote($author);
-
-               $where .= " AND takenby=$aq";
+               my @authors = split /,/, $author;
+               $where .= " AND takenby IN (" . join(', ', map { $dbh->quote($_) } @authors) . ")";
        }
 
        if (defined($num) && $num == -1) {
@@ -156,13 +155,57 @@ sub handler {
        # }
        
        # Count the number of selected images.
-       $ref = $dbh->selectrow_hashref("SELECT COUNT(*) AS num_selected FROM images WHERE vhost=? $where AND selected=\'t\'", undef, Sesse::pr0n::Common::get_server_name($r));
+       $ref = $dbh->selectrow_hashref("SELECT COUNT(*) AS num_selected FROM images WHERE vhost=? $where AND selected AND NOT is_render", undef, Sesse::pr0n::Common::get_server_name($r));
        my $num_selected = $ref->{'num_selected'};
 
        # Find all images related to this event.
        my $limit = (defined($start) && defined($num) && !$settings{'fullscreen'}) ? (" LIMIT $num OFFSET " . ($start-1)) : "";
 
-       my $q = $dbh->prepare("SELECT *, (date - INTERVAL '6 hours')::date AS day FROM images WHERE vhost=? $where ORDER BY (date - INTERVAL '6 hours')::date $datesort,takenby,date,filename $limit")
+       my $extra_joins = "";
+       my $extra_fields = "";
+       if ($settings{'fullscreen'}) {
+               $extra_joins = <<"EOF";
+    LEFT JOIN exif_info exif_prog ON images.id=exif_prog.image AND exif_prog.key = 'ExposureProgram'
+    LEFT JOIN exif_info exif_focal ON images.id=exif_focal.image AND exif_focal.key = 'FocalLength'
+    LEFT JOIN exif_info exif_shutter ON images.id=exif_shutter.image AND exif_shutter.key = 'ExposureTime'
+    LEFT JOIN exif_info exif_fnum ON images.id=exif_fnum.image AND exif_fnum.key = 'FNumber'
+    LEFT JOIN exif_info exif_iso1 ON images.id=exif_iso1.image AND exif_iso1.key = 'ISO'
+    LEFT JOIN exif_info exif_iso2 ON images.id=exif_iso2.image AND exif_iso2.key = 'ISOSetting'
+    LEFT JOIN exif_info exif_ev1 ON images.id=exif_ev1.image AND exif_ev1.key = 'ExposureBiasValue'
+    LEFT JOIN exif_info exif_ev2 ON images.id=exif_ev2.image AND exif_ev2.key = 'ExposureCompensation'
+    LEFT JOIN exif_info exif_date ON images.id=exif_date.image AND exif_date.key = 'DateTimeOriginal'
+    LEFT JOIN exif_info exif_model ON images.id=exif_model.image AND exif_model.key = 'Model'
+    LEFT JOIN exif_info exif_flash ON images.id=exif_flash.image AND exif_flash.key = 'Flash'
+EOF
+               $extra_fields = <<"EOF";
+    exif_prog.value AS "ExposureProgram",
+    exif_focal.value AS "FocalLength",
+    exif_shutter.value AS "ExposureTime",
+    exif_fnum.value AS "FNumber",
+    exif_iso1.value AS "ISO",
+    exif_iso2.value AS "ISOSetting",
+    exif_ev1.value AS "ExposureBiasValue",
+    exif_ev2.value AS "ExposureCompensation",
+    exif_date.value AS "DateTimeOriginal",
+    exif_model.value AS "Model",
+    exif_flash.value AS "Flash",
+EOF
+       }
+
+       my $q = $dbh->prepare(<<"EOF")
+SELECT *,
+  $extra_fields
+  (date - INTERVAL '6 hours')::date AS day
+FROM
+  images
+  $extra_joins
+WHERE
+  vhost=?
+  $where
+  AND NOT is_render
+ORDER BY (date - INTERVAL '6 hours')::date $datesort,takenby,date,filename
+$limit
+EOF
                or return dberror($r, "prepare()");
        $q->execute(Sesse::pr0n::Common::get_server_name($r))
                or return dberror($r, "image enumeration");
@@ -179,11 +222,13 @@ sub handler {
                while (my $ref = $q->fetchrow_hashref()) {
                        my $width = defined($ref->{'width'}) ? $ref->{'width'} : -1;
                        my $height = defined($ref->{'height'}) ? $ref->{'height'} : -1;
-                       push @files, [ $ref->{'event'}, $ref->{'filename'}, $width, $height ];
+                       my @parts = Sesse::pr0n::Common::make_infobox_parts($ref);
+                       @parts = map { $_->[1] ? "<strong>" . HTML::Entities::encode_entities($_->[0]) . "</strong>" : HTML::Entities::encode_entities($_->[0]) } @parts;
+                       push @files, [ $ref->{'event'}, $ref->{'filename'}, $width, $height, join('', @parts) ];
                }
                
                for my $i (0..$#files) {
-                       my $line = sprintf "        [ \"%s\", \"%s\", %d, %d ]", @{$files[$i]};
+                       my $line = sprintf "        [ \"%s\", \"%s\", %d, %d, \"%s\" ]", @{$files[$i]};
                        $line .= "," unless ($i == $#files);
                        $io->print($line . "\n");
                }
@@ -225,6 +270,7 @@ sub handler {
                                        COUNT(*) AS num
                                FROM images
                                WHERE vhost=? $where
+                               AND NOT is_render
                                GROUP BY 1,2
                                ORDER BY 1,2")
                                or die "Couldn't prepare to find equipment: $!";
@@ -455,7 +501,7 @@ sub print_nextprev {
        return unless (defined($start) && defined($num));
 
        # determine total number
-       my $ref = $dbh->selectrow_hashref("SELECT count(*) AS num_images FROM images WHERE vhost=? $where",
+       my $ref = $dbh->selectrow_hashref("SELECT count(*) AS num_images FROM images WHERE vhost=? $where AND NOT is_render",
                undef, Sesse::pr0n::Common::get_server_name($r))
                or return dberror($r, "image enumeration");
        my $num_images = $ref->{'num_images'};