summaryrefslogtreecommitdiff
path: root/util/vndb.pl
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-11-24 09:53:18 +0100
committerYorhel <git@yorhel.nl>2010-11-24 09:53:18 +0100
commit7004c8352cda3c81e547aabc037fd9ec7f03172c (patch)
tree03dfb5dc752c4121b797586bb1381af1cfcc4810 /util/vndb.pl
parentb1020c34d67837194554388812a71aa5bf7db7e0 (diff)
vndb.pl: Use the Makefile to auto-update static files
Rather than trying to figure out what to update in the Perl code, duplicating the logic that's already present in the Makefile. This is only enabled when 'regen_static' is set to true in data/config.pl.
Diffstat (limited to 'util/vndb.pl')
-rwxr-xr-xutil/vndb.pl49
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]
- ));
-}
-