summaryrefslogtreecommitdiff
path: root/lib/VNWeb/Prelude.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-09-23 11:01:17 +0200
committerYorhel <git@yorhel.nl>2019-09-23 11:01:17 +0200
commit9ccafba60b8de37b0c2a202d22df5c3e25b78026 (patch)
treeae150b0c25282a646e1d71868022ad4a5789e60a /lib/VNWeb/Prelude.pm
parent4542d952f782ee193dbf279cd8186cba0e9d87a4 (diff)
v2rw: Convert doc pages + add framework for item fetching & display & revisions
This bumps the minimum Perl version to 5.26 in order to make use of lexical subroutines - a feature I've been wanting for a while. This should be the last version bump, 5.26 is the highest version in Ubuntu LTS at the moment. Not that I use Ubuntu, but it's used by the Docker container and it's a sensible reference. I merged the 'maintabs' and 'hiddenmsg' features into the primary framework_ function; It fits quite well there, removes a little bit of boilerplate from the DB entry page code and reduces the reliance on common "dbSomethingGet()" methods. I was hoping I'd be able to reduce the boilerplate required for defining revisions, but I don't think that's going to happen. What I did do was reimplement the diffing to handle item and text diffs separately, with sensible defaults for the old split/join/diff options. Diffing is now performed on the raw structured data rather than on formatted HTML, which, combined with the db_entry() functions, ought to be less brittle.
Diffstat (limited to 'lib/VNWeb/Prelude.pm')
-rw-r--r--lib/VNWeb/Prelude.pm76
1 files changed, 76 insertions, 0 deletions
diff --git a/lib/VNWeb/Prelude.pm b/lib/VNWeb/Prelude.pm
new file mode 100644
index 00000000..ecc5a606
--- /dev/null
+++ b/lib/VNWeb/Prelude.pm
@@ -0,0 +1,76 @@
+# Importing this module is equivalent to:
+#
+# use v5.26;
+# use warnings;
+# use utf8;
+#
+# use TUWF ':html5_', 'mkclass';
+# use Exporter 'import';
+# use Time::HiRes 'time';
+#
+# use VNDBUtil;
+# use VNDB::Types;
+# use VNDB::Config;
+# use VNWeb::Auth;
+# use VNWeb::HTML;
+# use VNWeb::DB;
+#
+# WARNING: This should not be used from the above modules.
+package VNWeb::Prelude;
+
+use strict;
+use warnings;
+use feature ':5.26';
+use utf8;
+
+sub import {
+ my $c = caller;
+
+ strict->import;
+ warnings->import;
+ feature->import(':5.26');
+ utf8->import;
+
+ die $@ if !eval <<" EOM;";
+ package $c;
+
+ use TUWF ':html5_', 'mkclass';
+ use Exporter 'import';
+ use Time::HiRes 'time';
+
+ use VNDBUtil;
+ use VNDB::Types;
+ use VNDB::Config;
+ use VNWeb::Auth;
+ use VNWeb::HTML;
+ use VNWeb::DB;
+ 1;
+ EOM;
+
+ no strict 'refs';
+ *{$c.'::RE'} = *RE;
+}
+
+
+# Regular expressions for use in path registration
+my $num = qr{[1-9][0-9]{0,6}};
+my $id = qr{(?<id>$num)};
+my $rev = qr{(?:\.(?<rev>$num))};
+our %RE = (
+ uid => qr{u$id},
+ vid => qr{v$id},
+ rid => qr{r$id},
+ sid => qr{s$id},
+ cid => qr{c$id},
+ pid => qr{p$id},
+ iid => qr{i$id},
+ did => qr{d$id},
+ vrev => qr{v$id$rev?},
+ rrev => qr{r$id$rev?},
+ prev => qr{p$id$rev?},
+ srev => qr{s$id$rev?},
+ crev => qr{c$id$rev?},
+ drev => qr{d$id$rev?},
+);
+
+1;