From 168379589bee5b5d1c46f749748c3d3b1fd80c9a Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 23 Dec 2012 15:52:40 +0100 Subject: [PATCH] Gallery2: Relativize original names --- gal2/UCW/Gallery.pm | 28 ++++++++++++++-------------- gal2/gal-scan | 11 ++++++++--- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/gal2/UCW/Gallery.pm b/gal2/UCW/Gallery.pm index ad0f35d..b2d41a6 100644 --- a/gal2/UCW/Gallery.pm +++ b/gal2/UCW/Gallery.pm @@ -21,24 +21,24 @@ our %CF; our $th; BEGIN { - $CF{"Title"} = "An Unnamed Gallery", - $CF{"HeadExtras"} = "", - $CF{"TopExtras"} = "", - $CF{"BotExtras"} = "", - $CF{"ParentURL"} = "../", - $CF{"BackURL"} = "", - $CF{"FwdURL"} = "", - $CF{"ImageSubpages"} = 1, - $CF{"AllowArchives"} = 1, - $CF{"PhotoUrlPrefix"} = "", - $CF{"ThumbUrlPrefix"} = "", - $CF{"MetaDataDir"} = ".", - $CF{"PhotoDir"} = ".", + $CF{'Title'} = 'An Unnamed Gallery', + $CF{'HeadExtras'} = "", + $CF{'TopExtras'} = "", + $CF{'BotExtras'} = "", + $CF{'ParentURL'} = '../', + $CF{'BackURL'} = "", + $CF{'FwdURL'} = "", + $CF{'ImageSubpages'} = 1, + $CF{'AllowArchives'} = 1, + $CF{'PhotoUrlPrefix'} = "", + $CF{'ThumbUrlPrefix'} = "", + $CF{'MetaDataDir'} = '.', + $CF{'PhotoDir'} = '.', $CF{'ScanDefaultTransform'} = 'n'; $CF{'OrigDir'} = '.'; $CF{'PhotoDir'} = 'photo'; - $CF{"CacheDir"} = "cache", + $CF{'CacheDir'} = "cache", } sub LoadConfig() { diff --git a/gal2/gal-scan b/gal2/gal-scan index c1b70d0..951a93c 100755 --- a/gal2/gal-scan +++ b/gal2/gal-scan @@ -47,12 +47,17 @@ if (@ARGV) { } UCW::Gallery::LoadConfig; +my $orig_prefix = $UCW::Gallery::CF{'OrigDir'}; +$orig_prefix =~ m{/$} or $orig_prefix .= '/'; print "Scanning photos\n"; my @images = (); foreach my $f (@files) { - my ($fv, $fd, $ff) = File::Spec->splitpath($f); - print "\t$ff: "; + my $rel_name = $f; + if (substr($rel_name, 0, length $orig_prefix) eq $orig_prefix) { + $rel_name = substr($rel_name, length $orig_prefix); + } + print "\t$rel_name: "; my $sha = Digest::SHA->new(1); $sha->addfile($f) or die "Cannot hash $f\n"; @@ -74,7 +79,7 @@ foreach my $f (@files) { $o = "."; } push @images, { - file => $f, + file => $rel_name, id => $id, orientation => $o, xfrm => $UCW::Gallery::CF{'ScanDefaultTransform'}, -- 2.39.2