summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-09-01 13:52:50 +0200
committerYorhel <git@yorhel.nl>2020-09-01 13:52:52 +0200
commitd019f3a2bc73e9513ec6489ac742faa0f8f560dc (patch)
treee88ff2b04b3bc68b0860a934303016e4fe594f5b /lib
parent5e523de0ef77aa4d44426bf1c01896475aed0fe9 (diff)
Reviews: Hide up/down vote counts
Experimenting a bit.
Diffstat (limited to 'lib')
-rw-r--r--lib/VNWeb/Reviews/Elm.pm2
-rw-r--r--lib/VNWeb/Reviews/Lib.pm20
-rw-r--r--lib/VNWeb/Reviews/List.pm6
-rw-r--r--lib/VNWeb/Reviews/Page.pm7
-rw-r--r--lib/VNWeb/Reviews/VNTab.pm5
5 files changed, 9 insertions, 31 deletions
diff --git a/lib/VNWeb/Reviews/Elm.pm b/lib/VNWeb/Reviews/Elm.pm
index 428da4dc..6bce7973 100644
--- a/lib/VNWeb/Reviews/Elm.pm
+++ b/lib/VNWeb/Reviews/Elm.pm
@@ -5,8 +5,6 @@ use VNWeb::Prelude;
my $VOTE = {
id => { vndbid => 'w' },
my => { required => 0, jsonbool => 1 },
- up => { _when => 'out', uint => 1 },
- down => { _when => 'out', uint => 1 },
};
my $VOTE_IN = form_compile in => $VOTE;
diff --git a/lib/VNWeb/Reviews/Lib.pm b/lib/VNWeb/Reviews/Lib.pm
deleted file mode 100644
index 3564464a..00000000
--- a/lib/VNWeb/Reviews/Lib.pm
+++ /dev/null
@@ -1,20 +0,0 @@
-package VNWeb::Reviews::Lib;
-
-use VNWeb::Prelude;
-use Exporter 'import';
-
-our @EXPORT = qw/review_vote_/;
-
-
-# Display the up/down vote counts for a review, optionally with the option for the user to vote.
-# Takes an object with the following fields: id, c_up, c_down, my, can
-sub review_vote_ {
- my($w) = @_;
- my sub plain_ {
- span_ sprintf '๐Ÿ‘ %d ๐Ÿ‘Ž %d', $w->{c_up}, $w->{c_down};
- };
- return plain_ if !auth || !$w->{can};
- elm_ 'Reviews.Vote' => $VNWeb::Reviews::Elm::VOTE_OUT, { id => $w->{id}, up => $w->{c_up}, down => $w->{c_down}, my => $w->{my} }, \&plain_;
-}
-
-1;
diff --git a/lib/VNWeb/Reviews/List.pm b/lib/VNWeb/Reviews/List.pm
index a9dc9b41..8d2d0903 100644
--- a/lib/VNWeb/Reviews/List.pm
+++ b/lib/VNWeb/Reviews/List.pm
@@ -1,7 +1,6 @@
package VNWeb::Reviews::List;
use VNWeb::Prelude;
-use VNWeb::Reviews::Lib;
sub tablebox_ {
@@ -18,7 +17,7 @@ sub tablebox_ {
td_ class => 'tc3', 'Vote';
td_ class => 'tc4', 'Type';
td_ class => 'tc5', 'Review';
- td_ class => 'tc6', sub { txt_ 'Score'; sortable_ 'rating', $opt, \&url if auth->isMod };
+ td_ class => 'tc6', sub { txt_ 'Score*'; sortable_ 'rating', $opt, \&url } if auth->isMod;
td_ class => 'tc7', 'C#';
td_ class => 'tc8', sub { txt_ 'Last comment'; sortable_ 'lastpost', $opt, \&url };
} };
@@ -28,7 +27,7 @@ sub tablebox_ {
td_ class => 'tc3', fmtvote $_->{vote};
td_ class => 'tc4', $_->{isfull} ? 'Full' : 'Mini';
td_ class => 'tc5', sub { a_ href => "/$_->{id}", $_->{title} };
- td_ class => 'tc6', sub { review_vote_ $_ };
+ td_ class => 'tc6', sprintf '๐Ÿ‘ %d ๐Ÿ‘Ž %d', $_->{c_up}, $_->{c_down} if auth->isMod;
td_ class => 'tc7', $_->{c_count};
td_ class => 'tc8', $_->{c_lastnum} ? sub {
user_ $_, 'lu_';
@@ -77,6 +76,7 @@ TUWF::get qr{/w}, sub {
if($u && !$count) {
p_ +(auth && $u->{id} == auth->uid ? 'You have' : user_displayname($u).' has').' not submitted any reviews yet.';
}
+ p_ 'Note: The score column is only visible to moderators.' if auth->isMod;
};
tablebox_ $opt, $lst, $count if $count;
};
diff --git a/lib/VNWeb/Reviews/Page.pm b/lib/VNWeb/Reviews/Page.pm
index cab028e4..36ed8ee2 100644
--- a/lib/VNWeb/Reviews/Page.pm
+++ b/lib/VNWeb/Reviews/Page.pm
@@ -2,7 +2,6 @@ package VNWeb::Reviews::Page;
use VNWeb::Prelude;
use VNWeb::Releases::Lib;
-use VNWeb::Reviews::Lib;
my $COMMENT = form_compile any => {
@@ -65,7 +64,9 @@ sub review_ {
};
tr_ sub {
td_ '';
- td_ style => 'text-align: right', sub { review_vote_ $w };
+ td_ style => 'text-align: right', sub {
+ elm_ 'Reviews.Vote' => $VNWeb::Reviews::Elm::VOTE_OUT, $w if auth && $w->{can};
+ };
};
}
}
@@ -74,7 +75,7 @@ sub review_ {
TUWF::get qr{/$RE{wid}(?:(?<sep>[\./])$RE{num})?}, sub {
my($id, $sep, $num) = (tuwf->capture('id'), tuwf->capture('sep')||'', tuwf->capture('num'));
my $w = tuwf->dbRowi(
- 'SELECT r.id, r.vid, r.rid, r.isfull, r.text, r.spoiler, COALESCE(c.count,0) AS count, r.c_up, r.c_down, uv.vote, rm.id IS NULL AS can
+ 'SELECT r.id, r.vid, r.rid, r.isfull, r.text, r.spoiler, COALESCE(c.count,0) AS count, uv.vote, rm.id IS NULL AS can
, v.title, rel.title AS rtitle, rel.original AS roriginal, rel.type AS rtype, rv.vote AS my
, ', sql_user(), ',', sql_totime('r.date'), 'AS date,', sql_totime('r.lastmod'), 'AS lastmod
FROM reviews r
diff --git a/lib/VNWeb/Reviews/VNTab.pm b/lib/VNWeb/Reviews/VNTab.pm
index cd729832..bd1ae870 100644
--- a/lib/VNWeb/Reviews/VNTab.pm
+++ b/lib/VNWeb/Reviews/VNTab.pm
@@ -1,7 +1,6 @@
package VNWeb::Reviews::VNTab;
use VNWeb::Prelude;
-use VNWeb::Reviews::Lib;
sub reviews_ {
@@ -9,7 +8,7 @@ sub reviews_ {
# TODO: Better order, pagination
my $lst = tuwf->dbAlli(
- 'SELECT r.id, r.rid, r.text, r.spoiler, r.c_up, r.c_down, r.c_count, uv.vote, rv.vote AS my, NOT r.isfull AND rm.id IS NULL AS can
+ 'SELECT r.id, r.rid, r.text, r.spoiler, r.c_count, uv.vote, rv.vote AS my, NOT r.isfull AND rm.id IS NULL AS can
, ', sql_totime('r.date'), 'AS date, ', sql_user(), '
FROM reviews r
LEFT JOIN users u ON r.uid = u.id
@@ -56,7 +55,7 @@ sub reviews_ {
div_ sub {
a_ href => "/$r->{id}#review", 'Full review ยป' if !$mini;
a_ href => "/$r->{id}#threadstart", $r->{c_count} == 1 ? '1 comment' : "$r->{c_count} comments";
- review_vote_ $r;
+ elm_ 'Reviews.Vote' => $VNWeb::Reviews::Elm::VOTE_OUT, $r if auth && $r->{can};
};
} for @$lst;
}