Add an “equipment used” header on top of all image listings.
authorSteinar H. Gunderson <sesse@debian.org>
Mon, 26 Mar 2007 19:57:46 +0000 (21:57 +0200)
committerSteinar H. Gunderson <sesse@debian.org>
Mon, 26 Mar 2007 19:57:46 +0000 (21:57 +0200)
13 files changed:
perl/Sesse/pr0n/Index.pm
templates/bilder.knatten.com/equipment-end [new file with mode: 0644]
templates/bilder.knatten.com/equipment-start [new file with mode: 0644]
templates/default/equipment-end [new file with mode: 0644]
templates/default/equipment-start [new file with mode: 0644]
templates/images.tg05.gathering.org/equipment-end [new file with mode: 0644]
templates/images.tg05.gathering.org/equipment-start [new file with mode: 0644]
templates/itk-bilder.samfundet.no/equipment-end [new file with mode: 0644]
templates/itk-bilder.samfundet.no/equipment-start [new file with mode: 0644]
templates/skoyen.bilder.knatten.com/equipment-end [new file with mode: 0644]
templates/skoyen.bilder.knatten.com/equipment-start [new file with mode: 0644]
templates/skoyen.bildereks.knatten.com/equipment-end [new file with mode: 0644]
templates/skoyen.bildereks.knatten.com/equipment-start [new file with mode: 0644]

index ca02b75003ed4bb54f04d801978ed1e7da8072f1..f8f44048ff385a6bdfaa3ed5f506b84fcd8d0f7f 100644 (file)
@@ -152,6 +152,51 @@ 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 DISTINCT
+                               model.value AS model,
+                               coalesce(lens_spec.value, lens.value) AS lens
+                       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\'
+                       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 ignore entries without a lens.
+                               #
+                               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) {
+                               $r->print("  <li>" . $e->{'model'});
+                               if (defined($e->{'lens'})) {
+                                       $r->print(", " . $e->{'lens'} . "</li>\n");
+                               } else {
+                                       $r->print("</li>\n");
+                               }
+                       }
+                       Sesse::pr0n::Templates::print_template($r, "equipment-end");
+               }
+
 
                my $toclose = 0;
                my $lastupl = "";
diff --git a/templates/bilder.knatten.com/equipment-end b/templates/bilder.knatten.com/equipment-end
new file mode 100644 (file)
index 0000000..3d3a44c
--- /dev/null
@@ -0,0 +1 @@
+</ul>
diff --git a/templates/bilder.knatten.com/equipment-start b/templates/bilder.knatten.com/equipment-start
new file mode 100644 (file)
index 0000000..d803172
--- /dev/null
@@ -0,0 +1,3 @@
+<h2>Utstyr brukt</h2>
+
+<ul>
diff --git a/templates/default/equipment-end b/templates/default/equipment-end
new file mode 100644 (file)
index 0000000..3d3a44c
--- /dev/null
@@ -0,0 +1 @@
+</ul>
diff --git a/templates/default/equipment-start b/templates/default/equipment-start
new file mode 100644 (file)
index 0000000..c97efd8
--- /dev/null
@@ -0,0 +1,3 @@
+<h2>Equipment used</h2>
+
+<ul>
diff --git a/templates/images.tg05.gathering.org/equipment-end b/templates/images.tg05.gathering.org/equipment-end
new file mode 100644 (file)
index 0000000..3d3a44c
--- /dev/null
@@ -0,0 +1 @@
+</ul>
diff --git a/templates/images.tg05.gathering.org/equipment-start b/templates/images.tg05.gathering.org/equipment-start
new file mode 100644 (file)
index 0000000..c97efd8
--- /dev/null
@@ -0,0 +1,3 @@
+<h2>Equipment used</h2>
+
+<ul>
diff --git a/templates/itk-bilder.samfundet.no/equipment-end b/templates/itk-bilder.samfundet.no/equipment-end
new file mode 100644 (file)
index 0000000..3d3a44c
--- /dev/null
@@ -0,0 +1 @@
+</ul>
diff --git a/templates/itk-bilder.samfundet.no/equipment-start b/templates/itk-bilder.samfundet.no/equipment-start
new file mode 100644 (file)
index 0000000..d803172
--- /dev/null
@@ -0,0 +1,3 @@
+<h2>Utstyr brukt</h2>
+
+<ul>
diff --git a/templates/skoyen.bilder.knatten.com/equipment-end b/templates/skoyen.bilder.knatten.com/equipment-end
new file mode 100644 (file)
index 0000000..3d3a44c
--- /dev/null
@@ -0,0 +1 @@
+</ul>
diff --git a/templates/skoyen.bilder.knatten.com/equipment-start b/templates/skoyen.bilder.knatten.com/equipment-start
new file mode 100644 (file)
index 0000000..d803172
--- /dev/null
@@ -0,0 +1,3 @@
+<h2>Utstyr brukt</h2>
+
+<ul>
diff --git a/templates/skoyen.bildereks.knatten.com/equipment-end b/templates/skoyen.bildereks.knatten.com/equipment-end
new file mode 100644 (file)
index 0000000..3d3a44c
--- /dev/null
@@ -0,0 +1 @@
+</ul>
diff --git a/templates/skoyen.bildereks.knatten.com/equipment-start b/templates/skoyen.bildereks.knatten.com/equipment-start
new file mode 100644 (file)
index 0000000..d803172
--- /dev/null
@@ -0,0 +1,3 @@
+<h2>Utstyr brukt</h2>
+
+<ul>