diff options
Diffstat (limited to 'util')
-rwxr-xr-x | util/jsgen.pl | 1 | ||||
-rw-r--r-- | util/sql/func.sql | 1 | ||||
-rw-r--r-- | util/sql/schema.sql | 1 | ||||
-rw-r--r-- | util/updates/update_2.17.sql | 8 | ||||
-rwxr-xr-x | util/vndb.pl | 47 |
5 files changed, 42 insertions, 16 deletions
diff --git a/util/jsgen.pl b/util/jsgen.pl index 58b0ac9a..75a77504 100755 --- a/util/jsgen.pl +++ b/util/jsgen.pl @@ -13,7 +13,6 @@ BEGIN { ($ROOT = abs_path $0) =~ s{/util/jsgen\.pl$}{}; } require $ROOT.'/data/global.pl'; use lib "$ROOT/lib"; -use lib "$ROOT/yawf/lib"; use LangFile; # The VNDB::L10N module is not really suited to be used outside the VNDB::* diff --git a/util/sql/func.sql b/util/sql/func.sql index 0248c69a..2f87bdb9 100644 --- a/util/sql/func.sql +++ b/util/sql/func.sql @@ -103,6 +103,7 @@ BEGIN WITH RECURSIVE tags_vn_all(lvl, tag, vid, uid, vote, spoiler, meta) AS ( SELECT 15, tag, vid, uid, vote, spoiler, false FROM tags_vn + WHERE NOT ignore UNION ALL SELECT lvl-1, tp.parent, ta.vid, ta.uid, ta.vote, ta.spoiler, t.meta FROM tags_vn_all ta diff --git a/util/sql/schema.sql b/util/sql/schema.sql index 676d6400..2a3a394a 100644 --- a/util/sql/schema.sql +++ b/util/sql/schema.sql @@ -217,6 +217,7 @@ CREATE TABLE tags_vn ( vote smallint NOT NULL DEFAULT 3 CHECK (vote >= -3 AND vote <= 3 AND vote <> 0), spoiler smallint CHECK(spoiler >= 0 AND spoiler <= 2), date timestamptz NOT NULL DEFAULT NOW(), + ignore boolean NOT NULL DEFAULT false, PRIMARY KEY(tag, vid, uid) ); diff --git a/util/updates/update_2.17.sql b/util/updates/update_2.17.sql new file mode 100644 index 00000000..54487d0a --- /dev/null +++ b/util/updates/update_2.17.sql @@ -0,0 +1,8 @@ + +-- tag overrule feature +ALTER TABLE tags_vn ADD COLUMN ignore boolean NOT NULL DEFAULT false; + + +-- load new function(s) +\i util/sql/func.sql + diff --git a/util/vndb.pl b/util/vndb.pl index 0fd6e08d..b6056dd4 100755 --- a/util/vndb.pl +++ b/util/vndb.pl @@ -12,11 +12,10 @@ our $ROOT; BEGIN { ($ROOT = abs_path $0) =~ s{/util/vndb\.pl$}{}; } -use lib $ROOT.'/yawf/lib'; use lib $ROOT.'/lib'; -use YAWF ':html'; +use TUWF ':html'; use VNDB::L10N; use SkinFile; @@ -42,13 +41,23 @@ require $ROOT.'/data/global.pl'; system "make -sC $ROOT" if $S{regen_static}; -YAWF::init( +$TUWF::OBJ->{$_} = $S{$_} for (keys %S); +TUWF::set( %O, - namespace => 'VNDB', - object_data => \%S, pre_request_handler => \&reqinit, error_404_handler => \&handle404, + log_format => \&logformat, + # for compatibility with YAWF + validate_templates => { + mail => { regex => qr/^[^@<>]+@[^@.<>]+(?:\.[^@.<>]+)+$/ }, + url => { regex => qr/^(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/ }, + asciiprint => { regex => qr/^[\x20-\x7E]*$/ }, + int => { regex => qr/^-?\d+$/ }, + pname => { regex => qr/^[a-z0-9-]*$/ }, + }, ); +TUWF::load_recursive('VNDB::Util', 'VNDB::DB', 'VNDB::Handler'); +TUWF::run(); sub reqinit { @@ -85,20 +94,16 @@ sub reqinit { $rmcookie = 1 if $cookie && $cookie eq $browser; $handle = VNDB::L10N->get_handle($cookie) if $cookie && $browser ne $cookie; } - $self->resHeader('Set-Cookie', "l10n= ; expires=Sat, 01-Jan-2000 00:00:00 GMT; path=/; domain=$self->{cookie_domain}") - if $rmcookie; + $self->resCookie(l10n => undef) if $rmcookie; $self->{l10n} = $handle; # check for IE - if($self->reqHeader('User-Agent') && $self->reqHeader('User-Agent') =~ /MSIE [67]/ - && !$self->reqCookie('ie-sucks') && $self->reqPath ne 'we-dont-like-ie') { - # act as if we're opening /we-dont-like-ie6 (ugly hack, until YAWF supports preventing URL handlers from firing) - $ENV{HTTP_REFERER} = $ENV{REQUEST_URI}; - $ENV{REQUEST_URI} = '/we-dont-like-ie'; - } + return 0 if !$self->ieCheck; # load some stats (used for about all pageviews, anyway) $self->{stats} = $self->dbStats; + + return 1; } @@ -110,10 +115,22 @@ sub handle404 { h1 'Page not found'; div class => 'warning'; h2 'Oops!'; - p "It seems the page you were looking for does not exist,\n". - "you may want to try using the menu on your left to find what you are looking for."; + p; + txt 'It seems the page you were looking for does not exist,'; + br; + txt 'you may want to try using the menu on your left to find what you are looking for.'; + end; end; end; $self->htmlFooter; } + +# log user IDs (necessary for determining performance issues, user preferences +# have a lot of influence in this) +sub logformat { + my($self, $uri, $msg) = @_; + sprintf "[%s] %s %s: %s\n", scalar localtime(), $uri, + $self->authInfo->{id} ? 'u'.$self->authInfo->{id} : '-', $msg; +} + |