X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=gal2%2Fgal-cache;h=99095075e1b216f81f1993ca550d11045086a3b3;hb=9616a1f03e8290d15f0d15def6c8fb6d4e9420bf;hp=d6ee3537987833da0b414968c739d76d156de6da;hpb=11e566792f70153b513d4916f0540addcb0147ae;p=gallery.git diff --git a/gal2/gal-cache b/gal2/gal-cache index d6ee353..9909507 100755 --- a/gal2/gal-cache +++ b/gal2/gal-cache @@ -5,7 +5,8 @@ use strict; use warnings; -use lib '/home/mj/web/gal2'; +use FindBin; +use lib $FindBin::Bin; use UCW::Gallery qw(%CF); use Image::Magick; @@ -17,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"; @@ -31,9 +35,16 @@ if (-d $cache_dir) { print "Creating cache directory: $cache_dir\n"; File::Path::mkpath($cache_dir) or die "Unable to create $cache_dir: $!\n"; -for my $t (@{$CF{'ThumbSizes'}}) { - my ($tw, $th) = @$t; - my $thumb_fmt = $tw . 'x' . $th; +# 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"; my $thumb_meta = {}; $meta->{thumb}->{$thumb_fmt} = $thumb_meta;