]> mj.ucw.cz Git - gallery.git/commitdiff
Unify photo_name
authorMartin Mares <mj@ucw.cz>
Sat, 19 Jan 2013 14:21:43 +0000 (15:21 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 8 Feb 2015 20:14:17 +0000 (21:14 +0100)
gal/UCW/Gallery.pm
gal/UCW/Gallery/Web.pm
gal/UCW/Gallery/Web/HighSlide.pm
gal/bin/gal-cache
gal/bin/gal-gen

index ad1117f51e86a162fadf29becf597164c17cd7cc..c2afc82a57a5bb6f21f62bd15b0e326e0898acea 100644 (file)
@@ -160,9 +160,15 @@ sub thumb_fmt_to_size($$) {
        return ($tw, $th);
 }
 
-sub photo_name($$$) {
+sub photo_file_name($$$) {
        my ($self, $photo_meta, $id) = @_;
        return $id . '.' . ($photo_meta->{fmt} // 'jpg');
 }
 
+sub photo_name($$$) {
+       my ($self, $photo_meta, $id) = @_;
+       return File::Spec->catfile($self->get('PhotoDir'), $self->photo_file_name($photo_meta, $id));
+}
+
+
 1;
index 3a5536338ee97b549fe1fa2093e89d9b931bd7d9..ccca477e8007fb11e0ef7cc2918c26c8b7e4b946 100644 (file)
@@ -96,7 +96,7 @@ sub show_img($) {
        my $w = $m->{w};
        my $h = $m->{h};
        print "<h1>$t</h1>\n" if $t ne "";
-       my $img = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_name($m, $id);
+       my $img = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_file_name($m, $id);
        print "<p class=large><img src='$img' width=$w height=$h alt='$t'>\n";
 
        $self->html_bot;
@@ -128,7 +128,7 @@ sub show_list($) {
                if ($self->get('WebImageSubpages')) {
                        $click_url = "?i=$idx";
                } else {
-                       $click_url = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_name($m, $id);
+                       $click_url = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_file_name($m, $id);
                }
                $self->show_thumb($meta, $id, $click_url);
        }
index 90700aeddf7c8c37cb9e1a9b91b81a4e450b98f1..ecf6a3a4e4a829ae564efb6a19fd5da14b80a6f6 100644 (file)
@@ -62,7 +62,7 @@ sub show_thumb($) {
        # Highslide requires title either for all images, or for none
        my $tit = " title=\"$annot\"";
        my $aid = $self->{hs_thumb_counter}++ ? "" : " id=thumb1";
-       my $photo_url = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_name($m, $photo_id);
+       my $photo_url = $self->get('PhotoUrlPrefix') . $self->{gal}->photo_file_name($m, $photo_id);
        print "<li><a$aid href='$click_url' class=highslide onclick='return hs.expand(this, { src: \"$photo_url\" })'>";
        print "<img src='$thumb' width=$tw height=$th alt='Photo'$tit></a>\n";
 }
index f5792214c32986a8fda19b70d041a7baa041b44d..73c97db80dfdf0ad4b34d537e6b234dda5801834 100755 (executable)
@@ -18,7 +18,6 @@ my $gal = UCW::Gallery->load_config;
 print "Reading gallery.list\n";
 my $orig_list = $gal->read_list('gallery.list') or die "Cannot read gallery.list: $!\n";
 
-my $photo_dir = $gal->get('PhotoDir');
 my $photo_meta = $gal->photo_meta_name;
 print "Reading meta-data from $photo_meta\n";
 -f $photo_meta or die "Cannot load $photo_meta\n";
@@ -53,7 +52,7 @@ for my $thumb_fmt (@{$gal->get('ThumbFormats')}) {
                print "\t$id: ";
 
                my $p = new Image::Magick;
-               my $photo = File::Spec->catfile($photo_dir, $gal->photo_name($m, $id));
+               my $photo = $gal->photo_name($m, $id);
                my $e;
                $e = $p->Read($photo) and die "Error reading $photo: $e";
 
index f190bee132d2bde02af8dc87fec69a7fab5da751..2a1e0caa0b4ada805babf8f345b7bb71a6f922b3 100755 (executable)
@@ -110,7 +110,7 @@ for my $f (@$orig_list) {
                $p->Resize(width=>$w, height=>$h);
        }
 
-       my $photo = File::Spec->catfile($photo_dir, $gal->photo_meta($m, $id));
+       my $photo = $gal->photo_name($m, $id);
        my $tmp = "$photo.new";
        $e = $p->Write($tmp) and die "Unable to write $tmp: $e";
        rename $tmp, $photo or die "Cannot rename $tmp to $photo: $!\n";