X-Git-Url: https://git.sesse.net/?p=pr0n;a=blobdiff_plain;f=perl%2FSesse%2Fpr0n%2FIndex.pm;h=5a635d4c190aac8a5fff7e9fc3a05c1ae4aa25b8;hp=ca02b75003ed4bb54f04d801978ed1e7da8072f1;hb=6b6a6afa90a6be24ae430324ec5ca7fd83f4fe93;hpb=aebd301b01c9b4e75e382fb7c1fcb9347c48ffd0 diff --git a/perl/Sesse/pr0n/Index.pm b/perl/Sesse/pr0n/Index.pm index ca02b75..5a635d4 100644 --- a/perl/Sesse/pr0n/Index.pm +++ b/perl/Sesse/pr0n/Index.pm @@ -152,6 +152,57 @@ sub handler { print_nextprev($r, $event, \%settings, \%defsettings); print_selected($r, $event, \%settings, \%defsettings) if ($num_selected > 0); print_fullscreen($r, $event, \%settings, \%defsettings); + + # Find the equipment used + my $eq = $dbh->prepare(' + SELECT + TRIM(model.value) AS model, + coalesce(TRIM(lens_spec.value), TRIM(lens.value)) AS lens, + COUNT(*) AS num + FROM images i + LEFT JOIN exif_info model ON i.id=model.image + LEFT JOIN ( SELECT * FROM exif_info WHERE tag=\'Lens\' ) lens ON i.id=lens.image + LEFT JOIN ( SELECT * FROM exif_info WHERE tag=\'LensSpec\') lens_spec ON i.id=lens_spec.image + WHERE event=? AND model.tag=\'Model\' + GROUP BY 1,2 + ORDER BY 1,2') + or die "Couldn't prepare to find equipment: $!"; + $eq->execute($event) + or die "Couldn't find equipment: $!"; + + my @equipment = (); + my %cameras_seen = (); + while (my $ref = $eq->fetchrow_hashref) { + if (!defined($ref->{'lens'}) && exists($cameras_seen{$ref->{'model'}})) { + # + # Some compact cameras seem to add lens info sometimes and not at other + # times; if we have seen a camera with at least one specific lens earlier, + # just combine entries without a lens with the previous one. + # + $equipment[$#equipment]->{'num'} += $ref->{'num'}; + next; + } + push @equipment, $ref; + $cameras_seen{$ref->{'model'}} = 1; + } + $eq->finish; + + if (scalar @equipment > 0) { + Sesse::pr0n::Templates::print_template($r, "equipment-start"); + for my $e (@equipment) { + my $eqspec = $e->{'model'}; + $eqspec .= ', ' . $e->{'lens'} if (defined($e->{'lens'})); + + # This isn't correct for all languages. Fix if we ever need to care. :-) + if ($e->{'num'} == 1) { + Sesse::pr0n::Templates::print_template($r, "equipment-item-singular", { eqspec => $eqspec }); + } else { + Sesse::pr0n::Templates::print_template($r, "equipment-item", { eqspec => $eqspec, num => $e->{'num'} }); + } + } + Sesse::pr0n::Templates::print_template($r, "equipment-end"); + } + my $toclose = 0; my $lastupl = "";