From 670bd68a82722a268c03eaada0a3938f988b9987 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 19 Jan 2013 15:21:43 +0100 Subject: [PATCH] Unify photo_name --- gal/UCW/Gallery.pm | 8 +++++++- gal/UCW/Gallery/Web.pm | 4 ++-- gal/UCW/Gallery/Web/HighSlide.pm | 2 +- gal/bin/gal-cache | 3 +-- gal/bin/gal-gen | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gal/UCW/Gallery.pm b/gal/UCW/Gallery.pm index ad1117f..c2afc82 100644 --- a/gal/UCW/Gallery.pm +++ b/gal/UCW/Gallery.pm @@ -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; diff --git a/gal/UCW/Gallery/Web.pm b/gal/UCW/Gallery/Web.pm index 3a55363..ccca477 100644 --- a/gal/UCW/Gallery/Web.pm +++ b/gal/UCW/Gallery/Web.pm @@ -96,7 +96,7 @@ sub show_img($) { my $w = $m->{w}; my $h = $m->{h}; print "

$t

\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 "

$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); } diff --git a/gal/UCW/Gallery/Web/HighSlide.pm b/gal/UCW/Gallery/Web/HighSlide.pm index 90700ae..ecf6a3a 100644 --- a/gal/UCW/Gallery/Web/HighSlide.pm +++ b/gal/UCW/Gallery/Web/HighSlide.pm @@ -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 "

  • "; print "Photo\n"; } diff --git a/gal/bin/gal-cache b/gal/bin/gal-cache index f579221..73c97db 100755 --- a/gal/bin/gal-cache +++ b/gal/bin/gal-cache @@ -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"; diff --git a/gal/bin/gal-gen b/gal/bin/gal-gen index f190bee..2a1e0ca 100755 --- a/gal/bin/gal-gen +++ b/gal/bin/gal-gen @@ -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"; -- 2.39.2