summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-03-23 16:48:21 +0100
committerYorhel <git@yorhel.nl>2021-03-23 16:48:24 +0100
commit51ab6421929c1322552f16f8da44828c2b858dcb (patch)
treeb641aa5fed180ac745d5000a9b329e6873349b8b /lib
parent72ae93702f23083d54cb2e1922cbee1caebe7252 (diff)
cleanup: Fully remove old "type" argument to framework_()
The type of the dbobj can be inferred from its id now that we use vndbid's for all database entries.
Diffstat (limited to 'lib')
-rw-r--r--lib/VNWeb/Discussions/Thread.pm2
-rw-r--r--lib/VNWeb/Discussions/UPosts.pm2
-rw-r--r--lib/VNWeb/HTML.pm22
-rw-r--r--lib/VNWeb/Producers/Graph.pm2
-rw-r--r--lib/VNWeb/Releases/VNTab.pm2
-rw-r--r--lib/VNWeb/User/Edit.pm2
6 files changed, 15 insertions, 17 deletions
diff --git a/lib/VNWeb/Discussions/Thread.pm b/lib/VNWeb/Discussions/Thread.pm
index 3836bd46..26cfcff8 100644
--- a/lib/VNWeb/Discussions/Thread.pm
+++ b/lib/VNWeb/Discussions/Thread.pm
@@ -194,7 +194,7 @@ TUWF::get qr{/$RE{tid}(?:(?<sep>[\./])$RE{num})?}, sub {
auth->notiRead($id, [ map $_->{num}, $posts->@* ]) if @$posts;
- framework_ title => $t->{title}, type => 't', dbobj => $t, $num ? (js => 1, pagevars => {sethash=>$num}) : (), sub {
+ framework_ title => $t->{title}, dbobj => $t, $num ? (js => 1, pagevars => {sethash=>$num}) : (), sub {
metabox_ $t;
elm_ 'Discussions.Poll' => $POLL_OUT, {
question => $t->{poll_question},
diff --git a/lib/VNWeb/Discussions/UPosts.pm b/lib/VNWeb/Discussions/UPosts.pm
index 955f0790..43571b20 100644
--- a/lib/VNWeb/Discussions/UPosts.pm
+++ b/lib/VNWeb/Discussions/UPosts.pm
@@ -61,7 +61,7 @@ TUWF::get qr{/$RE{uid}/posts}, sub {
my $own = auth && $u->{id} eq auth->uid;
my $title = $own ? 'My posts' : 'Posts by '.user_displayname $u;
- framework_ title => $title, type => 'u', dbobj => $u, tab => 'posts',
+ framework_ title => $title, dbobj => $u, tab => 'posts',
sub {
div_ class => 'mainbox', sub {
h1_ $title;
diff --git a/lib/VNWeb/HTML.pm b/lib/VNWeb/HTML.pm
index 92e976d6..c39ac20b 100644
--- a/lib/VNWeb/HTML.pm
+++ b/lib/VNWeb/HTML.pm
@@ -153,7 +153,7 @@ sub _head_ {
my $o = shift;
my $fancy = !(auth->pref('nodistract_can') && auth->pref('nodistract_nofancy'));
- my $pubskin = $fancy && $o->{type} && $o->{type} eq 'u' && $o->{dbobj} ? tuwf->dbRowi(
+ my $pubskin = $fancy && $o->{dbobj} && $o->{dbobj}{id} =~ /^u/ ? tuwf->dbRowi(
'SELECT customcss, skin FROM users WHERE pubskin_can AND pubskin_enabled AND id =', \$o->{dbobj}{id}
) : {};
my $skin = tuwf->reqGet('skin') || $pubskin->{skin} || auth->pref('skin') || '';
@@ -426,12 +426,12 @@ sub _maintabs_ {
}
-# Attempt to figure out the board id from a database entry ($type, $dbobj) combination
+# Attempt to figure out the board id from a database entry
sub _board_id {
- my($type, $obj) = @_;
- $type =~ /[vp]/ ? $obj->{id} :
- $type eq 'r' && $obj->{vn}->@* ? $obj->{vn}[0]{vid} :
- $type eq 'c' && $obj->{vns}->@* ? $obj->{vns}[0]{vid} : 'db';
+ my($obj) = @_;
+ $obj->{id} =~ /^[vp]/ ? $obj->{id} :
+ $obj->{id} =~ /^r/ && $obj->{vn} && $obj->{vn}->@* ? $obj->{vn}[0]{vid} :
+ $obj->{id} =~ /^c/ && $obj->{vns} && $obj->{vns}->@* ? $obj->{vns}[0]{vid} : 'db';
}
@@ -468,14 +468,14 @@ sub _hidden_msg_ {
div_ class => 'warning', sub {
h2_ 'Item deleted';
p_ sub {
- if($o->{type} eq 'r' && $o->{dbobj}{vn}) {
+ if($o->{dbobj}{id} =~ /^r/ && $o->{dbobj}{vn}) {
txt_ 'This was a release entry for ';
join_ ',', sub { a_ href => "/$_->{vid}", $_->{title} }, $o->{dbobj}{vn}->@*;
txt_ '.';
br_;
}
txt_ 'This item has been deleted from the database. You may file a request on the ';
- a_ href => '/t/'._board_id($o->{type}, $o->{dbobj}), "discussion board";
+ a_ href => '/t/'._board_id($o->{dbobj}), "discussion board";
txt_ ' if you believe that this entry should be restored.';
if($msg->{rev} > 1) {
br_;
@@ -496,19 +496,17 @@ sub _hidden_msg_ {
# js => 1/0, set to 1 to ensure 'plain.js' is included on the page even if no elm_() modules are loaded.
# search => $query
# og => { opengraph metadata }
-# type => Database entry type (used for the main tabs & hidden message) (obsolete, inferred from dbobj->{id})
# dbobj => Database entry object (used for the main tabs & hidden message)
# Recognized object fields: id, entry_hidden, entry_locked
# tab => Current tab, or empty for the main tab
# hiddenmsg => 1/0, if true and dbobj is 'hidden', a message will be displayed
-# and the content function will not be called.
+# and the content function may not be called.
# sub { content }
sub framework_ {
my $cont = pop;
my %o = @_;
tuwf->req->{pagevars} = { $o{pagevars}->%* } if $o{pagevars};
tuwf->req->{js} ||= $o{js};
- $o{type} ||= $1 if $o{dbobj} && $o{dbobj}{id} =~ /^([a-z])/;
html_ lang => 'en', sub {
head_ sub { _head_ \%o };
@@ -892,7 +890,7 @@ sub editmsg_ {
if($obj) {
li_ sub {
txt_ 'Check for any existing discussions on the ';
- a_ href => '/t/'._board_id($type, $obj), 'discussion board';
+ a_ href => '/t/'._board_id($obj), 'discussion board';
};
# TODO: Include a list of the most recent edits in this page.
li_ sub {
diff --git a/lib/VNWeb/Producers/Graph.pm b/lib/VNWeb/Producers/Graph.pm
index 005a2492..321f26fb 100644
--- a/lib/VNWeb/Producers/Graph.pm
+++ b/lib/VNWeb/Producers/Graph.pm
@@ -46,7 +46,7 @@ TUWF::get qr{/$RE{pid}/rg}, sub {
$rel = [ grep $nodes->{$_->{id0}} && $nodes->{$_->{id1}}, @$rel ];
my $dot = gen_dot \@lines, $nodes, $rel, \%PRODUCER_RELATION;
- framework_ title => "Relations for $p->{name}", type => 'p', dbobj => $p, tab => 'rg',
+ framework_ title => "Relations for $p->{name}", dbobj => $p, tab => 'rg',
sub {
div_ class => 'mainbox', style => 'float: left; min-width: 100%', sub {
h1_ "Relations for $p->{name}";
diff --git a/lib/VNWeb/Releases/VNTab.pm b/lib/VNWeb/Releases/VNTab.pm
index de8c1d66..36c69c27 100644
--- a/lib/VNWeb/Releases/VNTab.pm
+++ b/lib/VNWeb/Releases/VNTab.pm
@@ -247,7 +247,7 @@ TUWF::get qr{/$RE{vid}/releases} => sub {
my sub url { '?'.query_encode %$opt, @_ }
- framework_ title => "Releases for $v->{title}", type => 'v', dbobj => $v, tab => 'releases', sub {
+ framework_ title => "Releases for $v->{title}", dbobj => $v, tab => 'releases', sub {
div_ class => 'mainbox releases_compare', sub {
h1_ "Releases for $v->{title}";
if(!@$r) {
diff --git a/lib/VNWeb/User/Edit.pm b/lib/VNWeb/User/Edit.pm
index 59c0f0d0..54bce482 100644
--- a/lib/VNWeb/User/Edit.pm
+++ b/lib/VNWeb/User/Edit.pm
@@ -94,7 +94,7 @@ TUWF::get qr{/$RE{uid}/edit}, sub {
$u->{password} = undef;
$u->{title} = $u->{id} eq auth->uid ? 'My Account' : "Edit $u->{username}";
- framework_ title => $u->{title}, type => 'u', dbobj => $u, tab => 'edit',
+ framework_ title => $u->{title}, dbobj => $u, tab => 'edit',
sub {
elm_ 'User.Edit', $FORM_OUT, $u;
};