summaryrefslogtreecommitdiff
path: root/util/vndb.pl
diff options
context:
space:
mode:
Diffstat (limited to 'util/vndb.pl')
-rwxr-xr-xutil/vndb.pl30
1 files changed, 30 insertions, 0 deletions
diff --git a/util/vndb.pl b/util/vndb.pl
index 5ef0bf40..a9ac36b4 100755
--- a/util/vndb.pl
+++ b/util/vndb.pl
@@ -22,6 +22,11 @@ use YAWF ':html';
our(%O, %S);
+# load and (if required) regenerate the skins
+# NOTE: $S{skins} can be modified in data/config.pl, allowing deletion of skins or forcing only one skin
+$S{skins} = readskins();
+
+
# load settings from global.pl
require $ROOT.'/data/global.pl';
@@ -73,3 +78,28 @@ sub handle404 {
}
+sub readskins {
+ my %skins; # dirname => skin name
+ my $regen = 0;
+ my $lasttemplate = [stat "$ROOT/data/skingen/style.css"]->[9];
+ for my $f (glob "$ROOT/static/s/*") {
+ my $n = $1 if $f =~ m{([^/]+)$};
+ open my $F, '<', "$f/conf" or die $!;
+ while(<$F>) {
+ chomp;
+ s{[\t\s]*//.*$}{};
+ next if !/^name[\t\s]+(.+)$/;
+ $skins{$n} = $1;
+ last;
+ }
+ close $F;
+
+ 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";
+ }
+ # note: this only works if the current process has write access to the skins
+ `$ROOT/util/skingen.pl` if $regen;
+ return \%skins;
+}
+