summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--css/v2.css5
-rw-r--r--elm/Tagmod.elm8
-rw-r--r--lib/VNWeb/TT/TagLinks.pm4
-rw-r--r--lib/VNWeb/VN/Page.pm13
-rw-r--r--lib/VNWeb/VN/Tagmod.pm13
-rw-r--r--sql/schema.sql3
-rw-r--r--util/updates/2022-06-21-tags-vn-lie.sql1
7 files changed, 31 insertions, 16 deletions
diff --git a/css/v2.css b/css/v2.css
index 7057aff6..109cb06c 100644
--- a/css/v2.css
+++ b/css/v2.css
@@ -556,6 +556,9 @@ div#vntags { margin: 0 30px 0 30px; border-top: 1px solid $bo
#tag_spoil_none:checked ~ #vntags .tagspl2 { display: none; }
#tag_spoil_some:checked ~ #vntags .tagspl2 { display: none; }
+#tag_spoil_all:checked ~ #vntags .lie,
+#tag_spoil_some:checked ~ #vntags .lie { text-decoration: line-through }
+
/* end of tag filter machinery */
#screenshots table { width: 100%; }
@@ -621,6 +624,7 @@ div#vntags { margin: 0 30px 0 30px; border-top: 1px solid $bo
.vntaglist li.tagvnlist-inherited a { color: $grayedout }
.vntaglist li:not(.tagvnlist-inherited) b.grayedout { color: $link }
.vntaglist h3 a { color: $maintext }
+.vntaglist .lie { text-decoration: line-through }
.vntaglist li { list-style-type: none; padding-right: 30px }
.vntaglist li .tagscore { margin-right: 10px }
@@ -1115,6 +1119,7 @@ table.tgl .buts a.sn { border: none; background-color: $border }
table.tgl .buts a.s0 { border: none; background-color: #0f0 }
table.tgl .buts a.s1 { border: none; background-color: #f80 }
table.tgl .buts a.s2 { border: none; background-color: #f40 }
+table.tgl .buts a.s3 { border: none; background-color: #cf0 }
table.tgl .tc_allvote { border-left: 1px solid $border; padding: 1px 0 0 30px; }
table.tgl .tc_allvote i { font-style: normal; font-size: 10px }
table.tgl .tc_allspoil { text-align: right; padding-right: 15px }
diff --git a/elm/Tagmod.elm b/elm/Tagmod.elm
index 4b7a8626..7a09cad2 100644
--- a/elm/Tagmod.elm
+++ b/elm/Tagmod.elm
@@ -157,7 +157,8 @@ viewTag t sel vid mod =
, td [ class "tc_myover" ] [ if mod && t.vote /= 0 then inputCheck "" t.overrule (SetOver t.id) else text "" ]
, td [ class "tc_myspoil buts" ] <|
if t.vote <= 0 then [] else
- [ a [ href "#", onMouseOver (SetSel t.id (Spoil Nothing)), onMouseOut (SetSel "" NoSel), onClickD (SetSpoil t.id Nothing), classList [("sn", spoil == Nothing)], title "Unknown" ] []
+ [ a [ href "#", onMouseOver (SetSel t.id (Spoil (Just 3))), onMouseOut (SetSel "" NoSel), onClickD (SetSpoil t.id (Just 3)), classList [("s3", spoil == Just 3 )], title "False" ] []
+ , a [ href "#", onMouseOver (SetSel t.id (Spoil Nothing)), onMouseOut (SetSel "" NoSel), onClickD (SetSpoil t.id Nothing), classList [("sn", spoil == Nothing)], title "Unknown" ] []
, a [ href "#", onMouseOver (SetSel t.id (Spoil (Just 0))), onMouseOut (SetSel "" NoSel), onClickD (SetSpoil t.id (Just 0)), classList [("s0", spoil == Just 0 )], title "Not a spoiler" ] []
, a [ href "#", onMouseOver (SetSel t.id (Spoil (Just 1))), onMouseOut (SetSel "" NoSel), onClickD (SetSpoil t.id (Just 1)), classList [("s1", spoil == Just 1 )], title "Minor spoiler" ] []
, a [ href "#", onMouseOver (SetSel t.id (Spoil (Just 2))), onMouseOut (SetSel "" NoSel), onClickD (SetSpoil t.id (Just 2)), classList [("s2", spoil == Just 2 )], title "Major spoiler" ] []
@@ -178,8 +179,9 @@ viewTag t sel vid mod =
Vote 2 -> [ td [ colspan 3 ] [ text "Vote +2" ] ]
Vote 3 -> [ td [ colspan 3 ] [ text "Vote +3" ] ]
Vote _ -> [ td [ colspan 3 ] [ text "Downvote (-3)" ] ]
+ Spoil (Just 3) -> [ td [ colspan 3 ] [ text "This eventually turns out to be false" ] ]
Spoil Nothing -> [ td [ colspan 3 ] [ text "Spoiler status not known" ] ]
- Spoil (Just 0) -> [ td [ colspan 3 ] [ text "This is not spoiler" ] ]
+ Spoil (Just 0) -> [ td [ colspan 3 ] [ text "This is not a spoiler" ] ]
Spoil (Just 1) -> [ td [ colspan 3 ] [ text "This is a minor spoiler" ] ]
Spoil (Just 2) -> [ td [ colspan 3 ] [ text "This is a major spoiler" ] ]
Note -> [ td [ colspan 3 ] [ if t.notes == "" then text "Set note" else div [ class "noteview" ] [ text t.notes ] ] ]
@@ -198,7 +200,7 @@ viewTag t sel vid mod =
, if not t.overruled then text ""
else b [ class "standout", style "font-weight" "bold", title "Tag overruled. All votes other than that of the moderator who overruled it will be ignored." ] [ text "!" ]
]
- , td [ class "tc_allspoil"] [ text <| Ffi.fmtFloat t.spoiler 2 ]
+ , td [ class "tc_allspoil"] [ text <| if t.spoiler < 0 then "False" else Ffi.fmtFloat t.spoiler 2 ]
, td [ class "tc_allwho" ]
[ span [ style "opacity" <| if t.othnotes == "" then "0" else "1", style "cursor" "default", title t.othnotes ] [ text "💬 " ]
, a [ href <| "/g/links?v="++vid++"&t="++t.id ] [ text "Who?" ]
diff --git a/lib/VNWeb/TT/TagLinks.pm b/lib/VNWeb/TT/TagLinks.pm
index 36d6a378..efe3e8b2 100644
--- a/lib/VNWeb/TT/TagLinks.pm
+++ b/lib/VNWeb/TT/TagLinks.pm
@@ -32,7 +32,7 @@ sub listing_ {
a_ href => "/$i->{tag}", $i->{name};
};
td_ class => 'tc5', sub {
- my $s = !defined $i->{spoiler} ? '' : fmtspoil $i->{spoiler};
+ my $s = !defined $i->{spoiler} ? '' : $i->{lie} ? 'False' : fmtspoil $i->{spoiler};
b_ class => 'grayedout', $s if $i->{ignore};
txt_ $s if !$i->{ignore};
};
@@ -67,7 +67,7 @@ TUWF::get qr{/g/links}, sub {
my $count = $filt && tuwf->dbVali('SELECT COUNT(*) FROM tags_vn tv WHERE', $where);
my($lst, $np) = tuwf->dbPagei({ page => $opt->{p}, results => 50 }, '
- SELECT tv.vid, tv.uid, tv.tag, tv.vote, tv.spoiler,', sql_totime('tv.date'), 'as date
+ SELECT tv.vid, tv.uid, tv.tag, tv.vote, tv.spoiler, tv.lie,', sql_totime('tv.date'), 'as date
, tv.ignore OR (u.id IS NOT NULL AND NOT u.perm_tag) AS ignore, tv.notes, v.title, v.alttitle, ', sql_user(), ', t.name
FROM tags_vn tv
JOIN vnt v ON v.id = tv.vid
diff --git a/lib/VNWeb/VN/Page.pm b/lib/VNWeb/VN/Page.pm
index 4fb3a383..4b820145 100644
--- a/lib/VNWeb/VN/Page.pm
+++ b/lib/VNWeb/VN/Page.pm
@@ -37,16 +37,17 @@ sub enrich_vn {
$v->{reviews} = tuwf->dbRowi('SELECT COUNT(*) FILTER(WHERE isfull) AS full, COUNT(*) FILTER(WHERE NOT isfull) AS mini, COUNT(*) AS total FROM reviews WHERE NOT c_flagged AND vid =', \$v->{id});
- my $rating = 'avg(CASE WHEN tv.ignore OR (u.id IS NOT NULL AND NOT u.perm_tag) THEN NULL ELSE tv.vote END)';
$v->{tags} = tuwf->dbAlli("
- SELECT t.id, t.name, t.cat, $rating as rating
- , coalesce(avg(CASE WHEN tv.ignore OR (u.id IS NOT NULL AND NOT u.perm_tag) THEN NULL ELSE tv.spoiler END), t.defaultspoil) as spoiler
+ SELECT t.id, t.name, t.cat, avg(tv.vote) as rating
+ , coalesce(avg(tv.spoiler), t.defaultspoil) as spoiler
+ , count(lie) filter(where lie) > 0 AND count(lie) filter (where lie) >= count(lie)>>1 AS lie
FROM tags t
JOIN tags_vn tv ON tv.tag = t.id
LEFT JOIN users u ON u.id = tv.uid
WHERE NOT t.hidden AND tv.vid =", \$v->{id}, "
+ AND NOT tv.ignore AND (u.id IS NULL OR u.perm_tag)
GROUP BY t.id, t.name, t.cat
- HAVING $rating > 0
+ HAVING avg(tv.vote) > 0
ORDER BY rating DESC, t.name"
);
}
@@ -366,7 +367,7 @@ sub infobox_tags_ {
$cnt->[0]++ if $spoil < 1;
my $cut = $cnt->[0] > 15 ? ' cut cut2 cut1 cut0' : $cnt->[1] > 15 ? ' cut cut2 cut1' : $cnt->[2] > 15 ? ' cut cut2' : '';
span_ class => "tagspl$spoil cat_$_->{cat} $cut", sub {
- a_ href => "/$_->{id}", style => sprintf('font-size: %dpx', $_->{rating}*3.5+6), $_->{name};
+ a_ href => "/$_->{id}", class => $_->{lie}?'lie':undef, style => sprintf('font-size: %dpx', $_->{rating}*3.5+6), $_->{name};
spoil_ $spoil;
b_ class => 'grayedout', sprintf ' %.1f', $_->{rating};
}
@@ -859,7 +860,7 @@ sub tags_ {
li_ $lvl == 1 ? (class => 'tagvnlist-parent') : $t->{inherited} ? (class => 'tagvnlist-inherited') : (), sub {
VNWeb::TT::Lib::tagscore_($t->{rating}, $t->{inherited});
b_ class => 'grayedout', '━━'x($lvl-1).' ' if $lvl > 1;
- a_ href => "/$t->{id}", $t->{rating} ? () : (class => 'parent'), $t->{name};
+ a_ href => "/$t->{id}", class => $view->{spoilers} > 0 && $t->{lie} ? 'lie' : $t->{rating} ? undef : 'parent', $t->{name};
spoil_ $t->{spoiler};
} if $lvl;
diff --git a/lib/VNWeb/VN/Tagmod.pm b/lib/VNWeb/VN/Tagmod.pm
index 767f9ab5..a20d96ad 100644
--- a/lib/VNWeb/VN/Tagmod.pm
+++ b/lib/VNWeb/VN/Tagmod.pm
@@ -9,7 +9,7 @@ my $FORM = {
tags => { sort_keys => 'id', aoh => {
id => { vndbid => 'g' },
vote => { int => 1, enum => [ -3..3 ] },
- spoil => { required => 0, uint => 1, enum => [ 0..2 ] },
+ spoil => { required => 0, uint => 1, enum => [ 0..3 ] },
overrule => { anybool => 1 },
notes => { required => 0, default => '', maxlength => 1000 },
cat => { _when => 'out' },
@@ -57,7 +57,11 @@ elm_api Tagmod => $FORM_OUT, $FORM_IN, sub {
# Add & update tags
for(@$tags) {
- my $row = { uid => auth->uid, vid => $id, tag => $_->{id}, vote => $_->{vote}, spoiler => $_->{spoil}, ignore => ($_->{overruled} && !$_->{overrule})?1:0, notes => $_->{notes} };
+ my $row = { uid => auth->uid, vid => $id, tag => $_->{id}, vote => $_->{vote}, notes => $_->{notes}
+ , spoiler => !defined $_->{spoil} ? undef : $_->{spoil} == 3 ? 0 : $_->{spoil}
+ , lie => !defined $_->{spoil} ? undef : $_->{spoil} == 3 ? 1 : 0
+ , ignore => ($_->{overruled} && !$_->{overrule})?1:0
+ };
tuwf->dbExeci('INSERT INTO tags_vn', $row, 'ON CONFLICT (uid, tag, vid) DO UPDATE SET', $row);
tuwf->dbExeci('UPDATE tags_vn SET ignore = TRUE WHERE uid IS DISTINCT FROM (', \auth->uid, ') AND vid =', \$id, 'AND tag =', \$_->{id}) if $_->{overrule};
}
@@ -79,7 +83,8 @@ TUWF::get qr{/$RE{vid}/tagmod}, sub {
my $tags = tuwf->dbAlli('
SELECT t.id, t.name, t.cat, count(*) as count, t.hidden, t.locked, t.applicable
, coalesce(avg(CASE WHEN tv.ignore OR (u.id IS NOT NULL AND NOT u.perm_tag) THEN NULL ELSE tv.vote END), 0) as rating
- , coalesce(avg(CASE WHEN tv.ignore OR (u.id IS NOT NULL AND NOT u.perm_tag) THEN NULL ELSE tv.spoiler END), t.defaultspoil) as spoiler
+ , CASE WHEN count(lie) filter(where lie) > 0 and count(lie) filter (where lie) >= count(lie)>>1 THEN -1
+ ELSE coalesce(avg(CASE WHEN tv.ignore OR (u.id IS NOT NULL AND NOT u.perm_tag) THEN NULL ELSE tv.spoiler END), t.defaultspoil) END as spoiler
, bool_or(tv.ignore) as overruled
FROM tags t
JOIN tags_vn tv ON tv.tag = t.id
@@ -88,7 +93,7 @@ TUWF::get qr{/$RE{vid}/tagmod}, sub {
GROUP BY t.id, t.name, t.cat
ORDER BY t.name'
);
- enrich_merge id => sub { sql 'SELECT tag AS id, vote, spoiler AS spoil, ignore, notes FROM tags_vn WHERE', { uid => auth->uid, vid => $v->{id} } }, $tags;
+ enrich_merge id => sub { sql 'SELECT tag AS id, vote, CASE WHEN lie THEN', \3, 'ELSE spoiler END AS spoil, ignore, notes FROM tags_vn WHERE', { uid => auth->uid, vid => $v->{id} } }, $tags;
enrich othnotes => id => tag => sub {
sql('SELECT tv.tag, ', sql_user(), ', tv.notes FROM tags_vn tv JOIN users u ON u.id = tv.uid WHERE tv.notes <> \'\' AND uid IS DISTINCT FROM (', \auth->uid, ') AND vid=', \$v->{id})
}, $tags;
diff --git a/sql/schema.sql b/sql/schema.sql
index 817e70b6..f9156de3 100644
--- a/sql/schema.sql
+++ b/sql/schema.sql
@@ -841,7 +841,8 @@ CREATE TABLE tags_vn (
spoiler smallint CHECK(spoiler >= 0 AND spoiler <= 2), -- [pub]
date timestamptz NOT NULL DEFAULT NOW(), -- [pub]
ignore boolean NOT NULL DEFAULT false, -- [pub]
- notes text NOT NULL DEFAULT '' -- [pub]
+ notes text NOT NULL DEFAULT '', -- [pub]
+ lie boolean -- [pub] implies spoiler=0
);
-- tags_vn_inherit
diff --git a/util/updates/2022-06-21-tags-vn-lie.sql b/util/updates/2022-06-21-tags-vn-lie.sql
new file mode 100644
index 00000000..b4aafad9
--- /dev/null
+++ b/util/updates/2022-06-21-tags-vn-lie.sql
@@ -0,0 +1 @@
+ALTER TABLE tags_vn ADD COLUMN lie boolean;