summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-01-04 14:01:05 +0100
committerYorhel <git@yorhel.nl>2021-01-04 14:01:07 +0100
commit3fc190f1898342d63b1308a83152fe45a88f7c3f (patch)
treef1b14a2ea0ab4b8bb6013a0e75dfa146ba5dd004 /util
parentf78f37e369567c91896aeeb505e706df4b4c12ff (diff)
v2rw: Some cleanup; Move some functionality out of vndb.pl; Move config out of tuwf->{..}
Config had been in a separate config->{..} object for a while now, old code doesn't need it anymore so we can finally get rid of the tuwf->{..} compact. vndb.pl is not really the place for library code, so moved that around. The old imgpath() and imgurl() functions weren't used anymore, so could be safely replaced with the new functions that take the new vndbid format. (All this to make it easier to write separate scripts that call into VNDB::/VNWeb:: code as a library)
Diffstat (limited to 'util')
-rwxr-xr-xutil/vndb.pl24
1 files changed, 1 insertions, 23 deletions
diff --git a/util/vndb.pl b/util/vndb.pl
index cbd88389..982b33e8 100755
--- a/util/vndb.pl
+++ b/util/vndb.pl
@@ -30,12 +30,6 @@ use VNWeb::Validation ();
my $skin = SkinFile->new("$ROOT/static/s");
tuwf->{skins} = { map +($_ => [ $skin->get($_, 'name'), $skin->get($_, 'userid') ]), $skin->list };
-# Some global variables
-tuwf->{scr_size} = [ 136, 102 ]; # w*h of screenshot thumbnails
-tuwf->{ch_size} = [ 256, 300 ]; # max. w*h of char images
-tuwf->{cv_size} = [ 256, 400 ]; # max. w*h of cover images
-tuwf->{$_} = config->{$_} for keys %{ config() };
-
TUWF::set %{ config->{tuwf} };
# Signal to VNWeb::Elm whether it should generate the Elm files.
@@ -43,22 +37,6 @@ TUWF::set %{ config->{tuwf} };
tuwf->{elmgen} = $ARGV[0] && $ARGV[0] eq 'elmgen';
-sub _path {
- my($t, $id) = $_[1] =~ /([a-z]+)([0-9]+)/;
- $t = 'st' if $t eq 'sf' && $_[2];
- sprintf '%s/%s/%02d/%d.jpg', $_[0], $t, $id%100, $id;
-}
-
-# tuwf->imgpath($image_id, $thumb)
-sub TUWF::Object::imgpath { _path "$ROOT/static", $_[1], $_[2] }
-
-# tuwf->imgurl($image_id, $thumb)
-sub TUWF::Object::imgurl { _path $_[0]{url_static}, $_[1], $_[2] }
-
-# tuwf->samesite() - returns true if this request originated from the same site, i.e. not an external referer.
-sub TUWF::Object::samesite { !!tuwf->reqCookie('samesite') }
-
-
TUWF::hook before => sub {
# If we're running standalone, serve www/ and static/ too.
if(tuwf->{_TUWF}{http}) {
@@ -70,7 +48,7 @@ TUWF::hook before => sub {
# Use a 'SameSite=Strict' cookie to determine whether this page was loaded from internal or external.
# Ought to be more reliable than checking the Referer header, but it's unfortunately a bit uglier.
- tuwf->resCookie(samesite => 1, httponly => 1, samesite => 'Strict') if !tuwf->samesite;
+ tuwf->resCookie(samesite => 1, httponly => 1, samesite => 'Strict') if !VNWeb::Validation::samesite;
tuwf->req->{trace_start} = time if config->{trace_log};
};