diff options
Diffstat (limited to 'util')
-rwxr-xr-x | util/vndb.pl | 49 |
1 files changed, 7 insertions, 42 deletions
diff --git a/util/vndb.pl b/util/vndb.pl index 29c2648c..b8988fd5 100755 --- a/util/vndb.pl +++ b/util/vndb.pl @@ -24,13 +24,10 @@ use SkinFile; our(%O, %S); -# load and (if required) regenerate the skins +# load the skins # NOTE: $S{skins} can be modified in data/config.pl, allowing deletion of skins or forcing only one skin -$S{skins} = readskins(); - - -# automatically regenerate script.js when required and possible -checkjs(); +my $skin = SkinFile->new("$ROOT/static/s"); +$S{skins} = { map +($_ => [ $skin->get($_, 'name'), $skin->get($_, 'userid') ]), $skin->list }; # load lang.dat @@ -41,6 +38,10 @@ VNDB::L10N::loadfile(); require $ROOT.'/data/global.pl'; +# automatically regenerate the skins and script.js and whatever else should be done +system "make -sC $ROOT" if $S{regen_static}; + + YAWF::init( %O, namespace => 'VNDB', @@ -96,39 +97,3 @@ sub handle404 { $self->htmlFooter; } - -sub readskins { - my %skins; # dirname => skin name - my @regen; - my $lasttemplate = [stat "$ROOT/data/style.css"]->[9]; - my $skin = SkinFile->new("$ROOT/static/s"); - for my $n ($skin->list) { - $skins{$n} = [ $skin->get($n, 'name'), $skin->get($n, 'userid') ]; - next if !$skins{$n}[0]; - - my $f = "$ROOT/static/s/$n"; - 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"; - } - system "$ROOT/util/skingen.pl", @regen if @regen; - return \%skins; -} - - -sub checkjs { - my $script = "$ROOT/static/f/script.js"; - my $lastmod = [stat $script]->[9]; - system "$ROOT/util/jsgen.pl" if - (!-e $script && -x "$ROOT/static/f") - || (-e $script && -w $script && ( - $lastmod < [stat "$ROOT/data/script.js"]->[9] - || $lastmod < [stat "$ROOT/data/lang.txt"]->[9] - || (-e "$ROOT/data/config.pl" && $lastmod < [stat "$ROOT/data/config.pl"]->[9]) - || $lastmod < [stat "$ROOT/data/global.pl"]->[9] - || $lastmod < [stat "$ROOT/util/jsgen.pl"]->[9] - )); -} - |