diff options
Diffstat (limited to 'util/vndb.pl')
-rwxr-xr-x | util/vndb.pl | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/util/vndb.pl b/util/vndb.pl index a9ac36b4..ca61836f 100755 --- a/util/vndb.pl +++ b/util/vndb.pl @@ -52,6 +52,9 @@ sub reqinit { $ENV{HTTP_REFERER} = $ENV{REQUEST_URI}; $ENV{REQUEST_URI} = '/we-dont-like-ie6'; } + + # load some stats (used for about all pageviews, anyway) + $self->{stats} = $self->dbStats; } @@ -80,26 +83,30 @@ sub handle404 { sub readskins { my %skins; # dirname => skin name - my $regen = 0; - my $lasttemplate = [stat "$ROOT/data/skingen/style.css"]->[9]; + my @regen; + my $lasttemplate = [stat "$ROOT/data/style.css"]->[9]; for my $f (glob "$ROOT/static/s/*") { + next if !-e "$f/conf"; my $n = $1 if $f =~ m{([^/]+)$}; open my $F, '<', "$f/conf" or die $!; while(<$F>) { chomp; + s/\r//; s{[\t\s]*//.*$}{}; next if !/^name[\t\s]+(.+)$/; $skins{$n} = $1; last; } close $F; + next if !$skins{$n}; - my $lastgen = [stat "$f/style.css"]->[9]; - $regen = 1 if (!-f "$f/style.css" && -x $f) - || ([stat "$f/conf"]->[9] > $lastgen || $lasttemplate > $lastgen) && -w "$f/style.css"; + my $css = -f "$f/style.css" && [stat "$f/style.css"]->[9] || 0; + my $boxbg = -f "$f/boxbg.png" && [stat "$f/boxbg.png"]->[9] || 0; + my $lastgen = $css < $boxbg ? $css : $boxbg; + push @regen, $n if (!$lastgen && -x $f && (!$css && !$boxbg || $css && -w "$f/style.css" || $boxbg && -w "$f/boxbg.png")) + || ([stat "$f/conf"]->[9] > $lastgen || $lasttemplate > $lastgen) && -w "$f/style.css" && -w "$f/boxbg.png"; } - # note: this only works if the current process has write access to the skins - `$ROOT/util/skingen.pl` if $regen; + system "$ROOT/util/skingen.pl", @regen if @regen; return \%skins; } |