mason/.perl-lib/TrivGal.pm (listdir): Delete redundant package qualifier.
[tgal] / mason / .perl-lib / TrivGal.pm
index eb82db2..ec011f3 100644 (file)
@@ -219,11 +219,13 @@ package TrivGal::Image {
 
   sub scale ($$) {
     my ($me, $scale) = @_;
+    my $m = HTML::Mason::Request->instance;
 
     my $path = $me->{path};
     my $sz = $SIZE{$scale} or die "unknown scale `$scale'";
     my $thumb = "$CACHE/scale.$sz/$path";
-    my $thumburl = "$CACHEURL/scale.$sz/$path";
+    my $thumburl =
+      $m->interp->apply_escapes("$CACHEURL/scale.$sz/$path", "u");
     my $st = stat $thumb;
     if (defined $st && $st->mtime > $me->{mtime}) { return $thumburl; }
 
@@ -252,7 +254,7 @@ package TrivGal::Image {
 
     $scaled->image_set_format($ty->imlibfmt);
     $scaled->set_quality(90);
-    my $new = "$TMP/t${$}$ext";
+    my $new = "$TMP/t$$-$ext";
     make_path $TMP;
     $scaled->save($new);
     make_path $dir;
@@ -285,6 +287,7 @@ sub listdir ($) {
   my (@d, @f);
   my $ix = undef;
 
+  $path =~ s#/$##;
   if (-f "$path/.tgal.index") {
     open my $f, "<", "$path/.tgal.index";
     my $item = undef;
@@ -311,7 +314,7 @@ sub listdir ($) {
          die "can't index a folder" if $indexp;
        } else {
          $list = \@f;
-         my ($dir, $base, $ext) = TrivGal::split_path $name;
+         my ($dir, $base, $ext) = split_path $name;
          die "unknown image type" unless $TYPE{lc $ext};
          if ($indexp) {
            die "two index images" if defined $ix;
@@ -338,7 +341,7 @@ sub listdir ($) {
       my $st = stat "$path/$e";
       my $list = undef;
       if ($dotp) { }
-      elsif (-d $st) { $list = \@d; }
+      elsif (-d $st) { $list = \@d; $e .= "/"; }
       elsif ($TYPE{lc $ext} && -f $st) { $list = \@f; }
       $list and push @$list, TrivGal::Item->new($e);
     }