($ENV{ZK_DO_BACKS} eq q{1})) ? 1 : 0;
my %Mtimes;
-my %Lines;
my %CatFiles;
my %CatDirs;
-sub noindex {
- $_ = shift;
- /(.*\/)index$/;
- if (defined $1) {
- return $1;
- }
- return $_;
-}
+use File::Basename;
{
my @ignores;
}
close $fh or croak "$!";
}
- sub isignored {
- my $p = shift;
- foreach my $re (@ignores) {
- return 1 if $p =~ m/$re/;
- }
- return 0;
- }
use File::Find;
use POSIX qw(strftime);
my $pth;
+ my $cat;
my $mtime;
sub wanted {
my $fn = $_;
- return if (($fn =~ /^[.]/) && ($fn ne q{.}));
- $pth = $File::Find::name;
- $pth = decode q{UTF-8}, $pth;
+ $pth = decode q{UTF-8}, $File::Find::name;
$pth =~ s/^[.]\/?//;
+ foreach (split /\//, $pth) {
+ return if (/^[.]/);
+ }
if (-d $fn) {
- return if isignored "$pth/";
- opendir my $dh, $fn or croak "$!";
- my @_files;
- my @_dirs;
- while (readdir $dh) {;
- next if /^[.]/;
- $_ = decode q{UTF-8}, $_;
- if (-d "$fn/$_") {
- $_ = "$pth/$_/";
- s/^\///;
- next if isignored $_;
- push @_dirs, $_;
- } else {
- $_ = "$pth/$_";
- s/^\///;
- next if isignored $_;
- push @_files, $_;
- }
+ $pth .= q{/};
+ }
+ foreach (@ignores) {
+ return if $pth =~ /$_/;
+ }
+ $cat = dirname $pth;
+ $cat = ($cat eq q{.}) ? q{/} : "$cat/";
+ if (-d $fn) {
+ if (not defined $CatFiles{$pth}) {
+ my @files;
+ my @dirs;
+ $CatFiles{$pth} = \@files;
+ $CatDirs{$pth} = \@dirs;
}
- closedir $dh or croak "$!";
- $CatFiles{"$pth/"} = \@_files;
- $CatDirs{"$pth/"} = \@_dirs;
+ return if $pth eq q{/};
+ push @{$CatDirs{$cat}}, $pth;
} else {
- return if isignored $pth;
+ push @{$CatFiles{$cat}}, $pth;
(undef, undef, undef, undef, undef, undef, undef, undef, undef,
$mtime, undef, undef, undef) = stat $fn or croak "$!";
$Mtimes{$pth} = strftime q{%Y-%m-%d %H:%M:%S}, gmtime $mtime;
find(\%opts, q{.});
}
+sub noindex {
+ my $l = shift;
+ if ($l =~ /(.*\/)index$/) {
+ return $1;
+ }
+ return $l;
+}
+
+my %Lines;
my %Links;
my %Backs;
for my $pth (keys %Mtimes) {
}
sub htmlescape {
- $_ = shift;
- s/&/\&/g;
- s/</\</g;
- s/>/\>/g;
- return $_;
+ my $s = shift;
+ $s =~ s/&/\&/g;
+ $s =~ s/</\</g;
+ $s =~ s/>/\>/g;
+ return $s;
}
use File::Spec;
-use File::Basename;
sub genHTML {
my $out = shift;
my sub makerels {
@rels = ();
my $rel;
- foreach (@links) {
- $rel = ($page eq q{/}) ? "$_" : File::Spec->abs2rel($_, $page);
- if ($page !~ /\/$/) {
- $rel = (length $rel > 2) ? (substr $rel, 3) : q{};
- }
+ my $base = $page;
+ if ($page =~ /\/$/) {
+ $base .= q{index};
+ }
+ $base = dirname $base;
+ foreach (sort @links) {
+ $rel = File::Spec->abs2rel($_, $base);
if (-d) {
- if ($rel !~ /\/$/) {
- $rel .= q{/};
+ if ($rel eq q{.}) {
+ $rel = q{index};
+ } else {
+ $rel .= q{/index};
}
- $rel .= q{index};
}
push @rels, $rel;
}
}
sub nodename {
- $_ = shift;
- tr'():,.'-----';
- return $_;
+ my $n = shift;
+ $n =~ tr'():,.'-----';
+ return $n;
}
sub printMenuEntry {