]> mj.ucw.cz Git - gallery.git/commitdiff
Gallery2: Relativize original names
authorMartin Mares <mj@ucw.cz>
Sun, 23 Dec 2012 14:52:40 +0000 (15:52 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 8 Feb 2015 20:14:08 +0000 (21:14 +0100)
gal2/UCW/Gallery.pm
gal2/gal-scan

index ad0f35dac944980b259c4cbc1666a9e491e3fbc0..b2d41a6ed84851f632e996a1323a43c1ea578f11 100644 (file)
@@ -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() {
index c1b70d09f843b178154a55dbef6094f436372f2a..951a93c646376f9d6908e4da3ec2704986f171c3 100755 (executable)
@@ -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'},