]> Untitled Git - public.git/blobdiff - public
Added image version
[public.git] / public
diff --git a/public b/public
index 8c6f828d0ce69193198a4c1e2f32a1c702c8f2ef..2dd248138c56764610cf4d189cae94e961b09309 100755 (executable)
--- a/public
+++ b/public
@@ -5,18 +5,21 @@ use warnings;
 use File::Spec;
 use File::Path qw/ make_path /;
 
-my $root_dir = '/mnt/Shared/Personal/My art';
-my $link_dir = '/var/www/html/public';
-my $http_uri = 'http://136.63.171.222/public';
+my $root_dir = $ENV{PUBLIC_ROOT_DIR}
+       or die "Need PUBLIC_ROOT_DIR\n";
+my $link_dir = $ENV{PUBLIC_LINK_DIR}
+       or die "Need PUBLIC_LINK_DIR\n";
+my $http_uri = $ENV{PUBLIC_HTTP_URI}
+       or die "Need PUBLIC_HTTP_URI\n";
 
 
 sub nonce {
        my $n = shift;
-       $n = 10 unless $n;
+       $n = 10 unless $n > 0;
 
        my @chars = ( 'a' .. 'z', 'A' .. 'Z', '0' .. '9' );
        my @path = ();
-       push @path, $chars[ rand @chars ] for 1 .. 10;
+       push @path, $chars[ rand @chars ] for 1 .. $n;
 
        return join '', @path;
 }
@@ -33,7 +36,8 @@ sub addFiles {
        my $name = shift
                or die "Need filename!\n";
 
-       opendir DIR, $root_dir;
+       opendir DIR, $root_dir
+        or die $!;
        my @files = grep /$name/i, readdir(DIR);
        closedir DIR;
 
@@ -41,7 +45,7 @@ sub addFiles {
        die "No match: $name\n" unless @files;
 
        # create nonce dir and add symbolic links
-       my $nonce = nonce();
+       my $nonce = nonce(20);
        my $nonce_dir = makeNonceDir($nonce);
 
        for my $file (@files) {