diff options
author | Yorhel <git@yorhel.nl> | 2020-08-24 16:41:20 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-08-24 16:41:22 +0200 |
commit | a8a97a6a0bcb4ff36804b79280ba5c9263fe233b (patch) | |
tree | 4f20acfa90d79dcda6b66ac73f2c155dddca1b57 /lib | |
parent | dda6647d207ea26800c5dbf3b326c88eccaa2c66 (diff) |
reviews: Get rid of summary field & split mini/full reviews
Much to my disappointment, people don't write proper summaries and, as
such, summaries are not useful to be considered a "short review" on
their own right. This necessitates splitting the reviews onto different
pages.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VNDB/BBCode.pm | 14 | ||||
-rw-r--r-- | lib/VNDB/Handler/Misc.pm | 2 | ||||
-rw-r--r-- | lib/VNWeb/Discussions/UPosts.pm | 2 | ||||
-rw-r--r-- | lib/VNWeb/Misc/History.pm | 2 | ||||
-rw-r--r-- | lib/VNWeb/Reviews/Edit.pm | 6 | ||||
-rw-r--r-- | lib/VNWeb/Reviews/List.pm | 24 | ||||
-rw-r--r-- | lib/VNWeb/Reviews/Page.pm | 12 | ||||
-rw-r--r-- | lib/VNWeb/Reviews/VNTab.pm | 23 | ||||
-rw-r--r-- | lib/VNWeb/VN/Page.pm | 7 |
9 files changed, 46 insertions, 46 deletions
diff --git a/lib/VNDB/BBCode.pm b/lib/VNDB/BBCode.pm index f6ab93d9..fe3a43d7 100644 --- a/lib/VNDB/BBCode.pm +++ b/lib/VNDB/BBCode.pm @@ -179,7 +179,7 @@ FINAL: # 2: Just output 'hidden by spoiler setting' message # 3: Just output the spoilers, unmarked sub bb2html { - my($input, $maxlength, $charspoil) = @_; + my($input, $maxlength, $charspoil, $nobreak) = @_; my $incode = 0; my $rmnewline = 0; @@ -202,8 +202,8 @@ sub bb2html { s/&/&/g; s/>/>/g; s/</</g; - s/\n/<br>/g if !$maxlength; - s/\n/ /g if $maxlength; + s/\n/<br>/g if !$nobreak; + s/\n/ /g if $nobreak; $_; }; @@ -233,18 +233,18 @@ sub bb2html { $charspoil == 2 ? '-->' : ''; } elsif($tag eq 'quote_start') { - $ret .= '<div class="quote">' if !$maxlength; + $ret .= '<div class="quote">' if !$nobreak; $rmnewline = 1; } elsif($tag eq 'quote_end') { - $ret .= '</div>' if !$maxlength; + $ret .= '</div>' if !$nobreak; $rmnewline = 1; } elsif($tag eq 'code_start') { - $ret .= '<pre>' if !$maxlength; + $ret .= '<pre>' if !$nobreak; $rmnewline = 1; $incode = 1; } elsif($tag eq 'code_end') { - $ret .= '</pre>' if !$maxlength; + $ret .= '</pre>' if !$nobreak; $rmnewline = 1; $incode = 0; diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm index c316999d..b4827da2 100644 --- a/lib/VNDB/Handler/Misc.pm +++ b/lib/VNDB/Handler/Misc.pm @@ -105,7 +105,7 @@ sub homepage { a href => "/$_->{id}", $_->{title}; end; p; - lit bb2html $post->{msg}, 150; + lit bb2html $post->{msg}, 150, 0, 1; end; } end 'td'; diff --git a/lib/VNWeb/Discussions/UPosts.pm b/lib/VNWeb/Discussions/UPosts.pm index 0a0165d0..46bb0977 100644 --- a/lib/VNWeb/Discussions/UPosts.pm +++ b/lib/VNWeb/Discussions/UPosts.pm @@ -24,7 +24,7 @@ sub listing_ { td_ class => 'tc3', fmtdate $_->{date}; td_ class => 'tc4', sub { a_ href => $url, $_->{title}; - b_ class => 'grayedout', sub { lit_ bb2html $_->{msg}, 150 }; + b_ class => 'grayedout', sub { lit_ bb2html $_->{msg}, 150, 0, 1 }; }; } for @$list; } diff --git a/lib/VNWeb/Misc/History.pm b/lib/VNWeb/Misc/History.pm index 7ce5584f..0959eb91 100644 --- a/lib/VNWeb/Misc/History.pm +++ b/lib/VNWeb/Misc/History.pm @@ -80,7 +80,7 @@ sub tablebox_ { td_ class => 'tc3', sub { user_ $i }; td_ class => 'tc4', sub { a_ href => $revurl, title => $i->{original}, shorten $i->{title}, 80; - b_ class => 'grayedout', sub { lit_ bb2html $i->{comments}, 150 }; + b_ class => 'grayedout', sub { lit_ bb2html $i->{comments}, 150, 0, 1 }; }; } for @$lst; }; diff --git a/lib/VNWeb/Reviews/Edit.pm b/lib/VNWeb/Reviews/Edit.pm index fc1e1964..f32b6b8d 100644 --- a/lib/VNWeb/Reviews/Edit.pm +++ b/lib/VNWeb/Reviews/Edit.pm @@ -10,7 +10,7 @@ my $FORM = { vntitle => { _when => 'out' }, rid => { id => 1, required => 0 }, spoiler => { anybool => 1 }, - summary => { maxlength => 700 }, + isfull => { anybool => 1 }, text => { maxlength => 100_000, required => 0, default => '' }, releases => { _when => 'out', $VNWeb::Elm::apis{Releases}[0]->%* }, @@ -36,7 +36,7 @@ TUWF::get qr{/$RE{vid}/addreview}, sub { TUWF::get qr{/$RE{wid}/edit}, sub { my $e = tuwf->dbRowi( - 'SELECT r.id, r.uid AS user_id, r.vid, r.rid, r.summary, r.text, r.spoiler, v.title AS vntitle + 'SELECT r.id, r.uid AS user_id, r.vid, r.rid, r.isfull, r.text, r.spoiler, v.title AS vntitle FROM reviews r JOIN vn v ON v.id = r.vid WHERE r.id =', \tuwf->capture('id') ); return tuwf->resNotFound if !$e->{id}; @@ -60,7 +60,7 @@ elm_api ReviewsEdit => $FORM_OUT, $FORM_IN, sub { validate_dbid 'SELECT id FROM vn WHERE id IN', $data->{vid}; validate_dbid 'SELECT id FROM releases WHERE id IN', $data->{rid} if defined $data->{rid}; - $data->{summary} = bb_subst_links $data->{summary}; + die "Review too long" if !$data->{isfull} && length $data->{text} > 700; $data->{text} = bb_subst_links $data->{text}; if($id) { diff --git a/lib/VNWeb/Reviews/List.pm b/lib/VNWeb/Reviews/List.pm index 04f932bd..5ab5a133 100644 --- a/lib/VNWeb/Reviews/List.pm +++ b/lib/VNWeb/Reviews/List.pm @@ -15,20 +15,22 @@ sub tablebox_ { thead_ sub { tr_ sub { td_ class => 'tc1', sub { txt_ 'Date'; sortable_ 'id', $opt, \&url }; td_ class => 'tc2', 'By'; - td_ class => 'tc3', 'Review'; - td_ class => 'tc4', 'Vote'; - td_ class => 'tc5', sub { txt_ 'Score'; sortable_ 'rating', $opt, \&url if auth->isMod }; - td_ class => 'tc6', 'C#'; - td_ class => 'tc7', sub { txt_ 'Last comment'; sortable_ 'lastpost', $opt, \&url }; + 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 => 'tc7', 'C#'; + td_ class => 'tc8', sub { txt_ 'Last comment'; sortable_ 'lastpost', $opt, \&url }; } }; tr_ sub { td_ class => 'tc1', fmtdate $_->{date}, 'compact'; td_ class => 'tc2', sub { user_ $_ }; - td_ class => 'tc3', sub { a_ href => "/$_->{id}", $_->{title} }; - td_ class => 'tc4', fmtvote $_->{vote}; - td_ class => 'tc5', sub { review_vote_ $_ }; - td_ class => 'tc6', $_->{c_count}; - td_ class => 'tc7', $_->{c_lastnum} ? sub { + 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 => 'tc7', $_->{c_count}; + td_ class => 'tc8', $_->{c_lastnum} ? sub { user_ $_, 'lu_'; txt_ ' @ '; a_ href => "/$_->{id}.$_->{c_lastnum}#last", fmtdate $_->{ldate}, 'full'; @@ -55,7 +57,7 @@ TUWF::get qr{/w}, sub { my $count = tuwf->dbVali('SELECT COUNT(*) FROM reviews'); my $lst = tuwf->dbPagei({results => 50, page => $opt->{p}}, ' - SELECT w.id, w.vid, w.c_up, w.c_down, w.c_count, w.c_lastnum, v.title, uv.vote + SELECT w.id, w.vid, w.isfull, w.c_up, w.c_down, w.c_count, w.c_lastnum, v.title, uv.vote , ', sql_user(), ',', sql_totime('w.date'), 'as date , ', sql_user('wpu','lu_'), ',', sql_totime('wp.date'), 'as ldate FROM reviews w diff --git a/lib/VNWeb/Reviews/Page.pm b/lib/VNWeb/Reviews/Page.pm index 23c62cf1..4a8d6b6b 100644 --- a/lib/VNWeb/Reviews/Page.pm +++ b/lib/VNWeb/Reviews/Page.pm @@ -56,13 +56,9 @@ sub review_ { }; } if $w->{spoiler}; tr_ @spoil, sub { - td_ length $w->{text} ? 'Summary' : 'Review'; - td_ sub { lit_ bb2html $w->{summary} } - }; - tr_ @spoil, sub { - td_ 'Full review'; + td_ 'Review'; td_ sub { lit_ bb2html $w->{text} } - } if length $w->{text}; + }; tr_ sub { td_ ''; td_ style => 'text-align: right', sub { review_vote_ $w }; @@ -75,7 +71,7 @@ TUWF::get qr{/$RE{wid}(?:(?<sep>[\./])$RE{num})?}, sub { return tuwf->resNotFound if !auth->permReview; #XXX:While in beta 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.summary, r.text, r.spoiler, COALESCE(c.count,0) AS count, r.c_up, r.c_down, uv.vote, r2.id IS NULL AS can + '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, r2.id IS NULL AS can , 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 @@ -114,7 +110,7 @@ TUWF::get qr{/$RE{wid}(?:(?<sep>[\./])$RE{num})?}, sub { pagevars => {sethash=>$num?$num:$page>1?'threadstart':'review'}, sub { VNWeb::VN::Page::infobox_($v); - VNWeb::VN::Page::tabs_($v, 'reviews'); + VNWeb::VN::Page::tabs_($v, $w->{isfull}?'reviews':'minireviews'); div_ class => 'mainbox', id => 'review', sub { p_ class => 'mainopts', sub { if(can_edit w => $w) { diff --git a/lib/VNWeb/Reviews/VNTab.pm b/lib/VNWeb/Reviews/VNTab.pm index c2a6dee6..0201c75c 100644 --- a/lib/VNWeb/Reviews/VNTab.pm +++ b/lib/VNWeb/Reviews/VNTab.pm @@ -5,24 +5,24 @@ use VNWeb::Reviews::Lib; sub reviews_ { - my($v) = @_; + my($v, $mini) = @_; - # TODO: Filters for upvote threshold, isfull and maybe vote + # TODO: Filters for upvote threshold # TODO: Order my $lst = tuwf->dbAlli( - 'SELECT r.id, r.rid, r.summary, r.text <> \'\' AS isfull, r.spoiler, r.c_up, r.c_down, r.c_count, uv.vote, rv.vote AS my, r2.id IS NULL AS can + '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 r2.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 LEFT JOIN ulist_vns uv ON uv.uid = r.uid AND uv.vid = r.vid LEFT JOIN reviews_votes rv ON rv.uid =', \auth->uid, ' AND rv.id = r.id LEFT JOIN reviews r2 ON r2.vid = r.vid AND r2.uid =', \auth->uid, ' - WhERE r.vid =', \$v->{id} + WhERE r.vid =', \$v->{id}, 'AND', ($mini ? 'NOT' : ''), 'r.isfull' ); div_ class => 'mainbox', sub { - h1_ 'Reviews'; + h1_ $mini ? 'Mini reviews' : 'Reviews'; debug_ $lst; div_ class => 'reviews', sub { article_ class => 'reviewbox', sub { @@ -45,11 +45,11 @@ sub reviews_ { if($r->{spoiler}) { label_ class => 'review_spoil', sub { input_ type => 'checkbox', class => 'visuallyhidden', (auth->pref('spoilers')||0) == 2 ? ('checked', 'checked') : (), undef; - div_ sub { lit_ bb2html $r->{summary} }; + div_ sub { lit_ bb2html $r->{text}, 700 }; span_ class => 'fake_link', 'This review contains spoilers, click to view.'; } } else { - lit_ bb2html $r->{summary}; + lit_ bb2html $r->{text}, 700; } }; div_ sub { @@ -63,17 +63,18 @@ sub reviews_ { } -TUWF::get qr{/$RE{vid}/reviews}, sub { +TUWF::get qr{/$RE{vid}/(?<mini>mini)?reviews}, sub { return tuwf->resNotFound if !auth->permReview; #XXX:While in beta + my $mini = !!tuwf->capture('mini'); my $v = db_entry v => tuwf->capture('id'); return tuwf->resNotFound if !$v; VNWeb::VN::Page::enrich_vn($v); - framework_ title => "Reviews for $v->{title}", index => 1, type => 'v', dbobj => $v, hiddenmsg => 1, + framework_ title => ($mini?'Mini reviews':'Reviews')." for $v->{title}", index => 1, type => 'v', dbobj => $v, hiddenmsg => 1, sub { VNWeb::VN::Page::infobox_($v); - VNWeb::VN::Page::tabs_($v, 'reviews'); - reviews_ $v; + VNWeb::VN::Page::tabs_($v, ($mini?'minireviews':'reviews')); + reviews_ $v, $mini; }; }; diff --git a/lib/VNWeb/VN/Page.pm b/lib/VNWeb/VN/Page.pm index 5f24296a..3e48437d 100644 --- a/lib/VNWeb/VN/Page.pm +++ b/lib/VNWeb/VN/Page.pm @@ -387,15 +387,16 @@ sub infobox_ { sub tabs_ { my($v, $tab) = @_; my $chars = tuwf->dbVali('SELECT COUNT(DISTINCT c.id) FROM chars c JOIN chars_vns cv ON cv.id = c.id WHERE NOT c.hidden AND cv.vid =', \$v->{id}); - my $reviews = auth->permReview ? tuwf->dbVali('SELECT COUNT(*) FROM reviews WHERE vid =', \$v->{id}) : 0; + my $reviews = auth->permReview ? tuwf->dbRowi('SELECT COUNT(*) FILTER(WHERE isfull) AS full, COUNT(*) FILTER(WHERE NOT isfull) AS mini FROM reviews WHERE vid =', \$v->{id}) : {}; - return if !$chars && !$reviews && !auth->permEdit && !auth->permReview; + return if !$chars && !$reviews->{full} && !$reviews->{mini} && !auth->permEdit && !auth->permReview; $tab ||= ''; div_ class => 'maintabs', sub { ul_ sub { li_ class => ($tab eq '' ? ' tabselected' : ''), sub { a_ href => "/v$v->{id}#main", name => 'main', 'main' } if $chars || $reviews; li_ class => ($tab eq 'chars' ? ' tabselected' : ''), sub { a_ href => "/v$v->{id}/chars#chars", name => 'chars', "characters ($chars)" } if $chars; - li_ class => ($tab eq 'reviews' ? ' tabselected' : ''), sub { a_ href => "/v$v->{id}/reviews#review", name => 'review', "reviews ($reviews)" } if $reviews; + li_ class => ($tab eq 'minireviews'?' tabselected':''), sub { a_ href => "/v$v->{id}/minireviews#review", name => 'review', "mini reviews ($reviews->{mini})" } if $reviews->{mini}; + li_ class => ($tab eq 'reviews' ? ' tabselected' : ''), sub { a_ href => "/v$v->{id}/reviews#review", name => 'review', "full reviews ($reviews->{full})" } if $reviews->{full}; }; ul_ sub { if(auth && canvote $v) { |