summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-09-25 18:37:29 +0200
committerYorhel <git@yorhel.nl>2019-09-25 18:49:19 +0200
commitd735e66d7d9b2d8c9a965ec96753864ff8c306c2 (patch)
treece0214b9e3cc819252b9192e7518f7768e568c77 /util
parentc7642c03d99ed0255614a43fb82e55a1dde66753 (diff)
v2rw: Add Elm & db_edit framework + Convert doc page editing
Most of this is copied from v3. I did improve on a few aspects: - db_edit() and db_entry() use VNDB::Schema rather than dynamically querying the DB. This has the minor advantage of a faster startup. - The Elm code generator now writes to multiple files, this avoids the namespace pollution seen in v3's Lib.Gen and makes the dependency graph a bit more lean (i.e. faster incremental builds). - The Elm code generator doesn't update the timestamp of files that haven't been modified. This also speeds up incremental builds, the elm compiler can now skip rebuilding unmodified files. - The Elm API response generator code now uses plain functions rather than code references and all possible responses are now defined in Elm.pm. Turns out most API responses were used from more than a single place, so it makes sense to have them centrally defined. The doc page preview function is also much nicer; I'd like to apply this to all BBCode textareas as well. (Elm.pm itself is ugly as hell though. And we will prolly need some HTML form generation functions in Elm to make that part less verbose)
Diffstat (limited to 'util')
-rwxr-xr-xutil/vndb.pl38
1 files changed, 36 insertions, 2 deletions
diff --git a/util/vndb.pl b/util/vndb.pl
index d2b1a964..15db575a 100755
--- a/util/vndb.pl
+++ b/util/vndb.pl
@@ -13,7 +13,9 @@ BEGIN { ($ROOT = abs_path $0) =~ s{/util/vndb\.pl$}{}; }
use lib $ROOT.'/lib';
use SkinFile;
use VNDB::Config;
+use VNWeb::Auth;
use VNWeb::HTML ();
+use VNWeb::Validation ();
# load the skins
@@ -30,6 +32,10 @@ tuwf->{$_} = config->{$_} for keys %{ config() };
TUWF::set %{ config->{tuwf} };
+# Signal to VNWeb::Elm whether it should generate the Elm files.
+# Should be done before loading any more modules.
+tuwf->{elmgen} = $ARGV[0] && $ARGV[0] eq 'elmgen';
+
TUWF::hook before => sub {
# If we're running standalone, serve www/ and static/ too.
@@ -62,5 +68,33 @@ TUWF::set error_404_handler => sub {
};
-TUWF::load_recursive('VNDB::Util', 'VNDB::DB', 'VNDB::Handler', 'VNWeb');
-TUWF::run();
+sub TUWF::Object::resDenied {
+ tuwf->resStatus(403);
+ VNWeb::HTML::framework_ title => 'Access Denied', noindex => 1, sub {
+ div_ class => 'mainbox', sub {
+ h1_ 'Access Denied';
+ div_ class => 'warning', sub {
+ if(!auth) {
+ h2_ 'You need to be logged in to perform this action.';
+ p_ sub {
+ txt_ 'Please ';
+ a_ href => '/u/login', 'login';
+ txt_ ' or ';
+ a_ href => '/u/register', 'create an account';
+ txt_ " if you don't have one yet.";
+ }
+ } else {
+ h2_ 'You are not allowed to perform this action.';
+ p_ 'You do not have the proper rights to perform the action you wanted to perform.';
+ }
+ }
+ }
+ }
+}
+
+
+TUWF::load_recursive('VNDB::Util', 'VNDB::DB', 'VNDB::Handler');
+TUWF::set import_modules => 0;
+TUWF::load_recursive('VNWeb');
+
+TUWF::run if !tuwf->{elmgen};