From 02daff90e4849847aebbfd8f4ccc56958e760ea5 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 26 Dec 2012 14:28:28 +0100 Subject: [PATCH] Gallery2: Titles are cached by gal-cache instead of gal-gen This makes title changes much easier. --- gal2/FORMAT | 3 ++- gal2/gal-cache | 11 +++++++++++ gal2/gal-gen | 5 +---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gal2/FORMAT b/gal2/FORMAT index 2f4a1ba..67118ec 100644 --- a/gal2/FORMAT +++ b/gal2/FORMAT @@ -25,9 +25,10 @@ $meta->{photo}->{$identifier} is a hash of: h height after scaling title photo title +The rest is present in cache.meta only: + $meta->{sequence} is an array of photo IDs as they appear in the gallery. -[CacheDir only] $meta->{thumb}->{$format}->{$identifier} is a hash of: w thumbnail width h thumbnail height diff --git a/gal2/gal-cache b/gal2/gal-cache index 591a1ce..9909507 100755 --- a/gal2/gal-cache +++ b/gal2/gal-cache @@ -18,6 +18,9 @@ STDOUT->autoflush(1); UCW::Gallery::LoadConfig; +print "Reading gallery.list\n"; +my $orig_list = UCW::Gallery::ReadList('gallery.list') or die "Cannot read gallery.list: $!\n"; + my $photo_dir = $CF{'PhotoDir'}; my $photo_meta = File::Spec->catfile($photo_dir, 'gallery.meta'); print "Reading meta-data from $photo_meta\n"; @@ -32,6 +35,14 @@ if (-d $cache_dir) { print "Creating cache directory: $cache_dir\n"; File::Path::mkpath($cache_dir) or die "Unable to create $cache_dir: $!\n"; +# Construct sequence and store photo titles +$meta->{sequence} = []; +for my $f (@$orig_list) { + push @{$meta->{sequence}}, $f->{id}; + my $m = $meta->{photo}->{$f->{id}} or die; + $m->{title} = $f->{title}; +} + for my $thumb_fmt (keys %{$CF{'ThumbFormats'}}) { my ($tw, $th) = ($thumb_fmt =~ m{^(\d+)x(\d+)$}) or die "Cannot parse thumbnail format $thumb_fmt\n"; print "Generating $thumb_fmt thumbnails\n"; diff --git a/gal2/gal-gen b/gal2/gal-gen index 1e7c3dd..96bd65f 100755 --- a/gal2/gal-gen +++ b/gal2/gal-gen @@ -18,7 +18,6 @@ STDOUT->autoflush(1); UCW::Gallery::LoadConfig; -my $orig_dir = $CF{'OrigDir'}; my $orig_list = UCW::Gallery::ReadList('gallery.list') or die "Cannot read gallery.list: $!\n"; my $photo_dir = $CF{'PhotoDir'}; @@ -36,7 +35,7 @@ if (-f $photo_meta) { $old_meta = UCW::Gallery::ReadMeta($photo_meta); # use Data::Dumper; print "Read old meta: ", Dumper($old_meta), "\n"; } -my $meta = { 'photo' => {}, 'sequence' => [] }; +my $meta = { 'photo' => {} }; for my $f (@$orig_list) { my $id = $f->{id}; @@ -69,10 +68,8 @@ for my $f (@$orig_list) { 'xf' => $xfrm, 'w' => $w, 'h' => $h, - 'title' => $f->{title}, }; $meta->{photo}->{$id} = $m; - push @{$meta->{sequence}}, $id; my $om = $old_meta->{photo}->{$id}; if ($om && -- 2.39.2