summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-12-23 11:35:36 +0100
committerYorhel <git@yorhel.nl>2008-12-23 11:35:36 +0100
commitc435aa0b2b60e785d2b5447e751c761736f8852c (patch)
tree41af1940c81b072df27c57cbd1f013022f3f462f /util
parent4ff5526f73bca33933cbff1e1cc7fee61da4327c (diff)
Read the available skins in memory at vndb.pl startup
Skins are automatically regenerated if necessary. This, however, requires the vndb.pl process to have write access to the skins, which is most often not the case. To do this, simply do a: chmod 777 static/s/*; chmod 666 static/s/*/{boxbg.png,style.css} (and make sure to repeat that each time a new skin is added)
Diffstat (limited to 'util')
-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;
+}
+