Factor out readability check in default entries().
[matthijs/upstream/blosxom.git] / blosxom.cgi
index fef5750e3d07ba7370ab01fac21bac8a6190c795..420a1b6e91ea9c7f4d600dcd240b0aa360cde077 100755 (executable)
@@ -550,11 +550,12 @@ sub load_template {
 # Define default entries subroutine
 $entries = sub {
     my ( %files, %indexes, %others );
+    my $param_all = param('-all');
     find(
         sub {
-            my $d;
             my $curr_depth = $File::Find::dir =~ tr[/][];
             return if $depth and $curr_depth > $depth;
+            return if !-r $File::Find::name;
 
             if (
 
@@ -563,7 +564,7 @@ $entries = sub {
                 =~ m!^$datadir/(?:(.*)/)?(.+)\.$file_extension$!
 
                 # not an index, .file, and is readable
-                and $2 ne 'index' and $2 !~ /^\./ and ( -r $File::Find::name )
+                and $2 ne 'index' and $2 !~ /^\./
                 )
             {
 
@@ -579,12 +580,12 @@ $entries = sub {
                 # static rendering bits
                 my $static_file
                     = "$static_dir/$1/index." . $static_flavours[0];
-                if (   param('-all')
+                if (   $param_all
                     or !-f $static_file
                     or stat($static_file)->mtime < $mtime )
                 {
                     $indexes{$1} = 1;
-                    $d = join( '/', ( nice_date($mtime) )[ 5, 2, 3 ] );
+                    my $d = join( '/', ( nice_date($mtime) )[ 5, 2, 3 ] );
                     $indexes{$d} = $d;
                     $indexes{ ( $1 ? "$1/" : '' ) . "$2.$file_extension" } = 1
                         if $static_entries;
@@ -592,7 +593,7 @@ $entries = sub {
             }
 
             # not an entries match
-            elsif ( !-d $File::Find::name and -r $File::Find::name ) {
+            elsif ( !-d $File::Find::name ) {
                 $others{$File::Find::name} = stat($File::Find::name)->mtime;
             }
         },
@@ -618,11 +619,7 @@ my ( $files, $indexes, $others ) = &$entries();
 %indexes = %$indexes;
 
 # Static
-if (    !$ENV{GATEWAY_INTERFACE}
-    and param('-password')
-    and $static_password
-    and param('-password') eq $static_password )
-{
+if ( $static_or_dynamic eq 'static' ) {
 
     param('-quiet') or print "Blosxom is generating static index pages...\n";