summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-09-15 08:54:55 +0200
committerYorhel <git@yorhel.nl>2020-09-15 08:55:02 +0200
commit8f9606495fd449c70e874274ae40090102a3997c (patch)
tree746ded0280a020692f73ce3634e1c66c86d61de7
parent58030654f5ac4298be3080bb8f74335a4b73a5fd (diff)
Reviews::VNTab: Put all reviews on a single page if there are 4 or less mini-reviews
Not that much value in splitting them into different pages if there's not many reviews in the first place.
-rw-r--r--lib/VNWeb/Reviews/VNTab.pm15
-rw-r--r--lib/VNWeb/VN/Page.pm8
2 files changed, 16 insertions, 7 deletions
diff --git a/lib/VNWeb/Reviews/VNTab.pm b/lib/VNWeb/Reviews/VNTab.pm
index 92d36a40..e575a6fa 100644
--- a/lib/VNWeb/Reviews/VNTab.pm
+++ b/lib/VNWeb/Reviews/VNTab.pm
@@ -21,7 +21,7 @@ sub reviews_ {
);
div_ class => 'mainbox', sub {
- h1_ $mini ? 'Mini reviews' : 'Reviews';
+ h1_ $mini ? 'Mini reviews' : 'Full reviews';
debug_ $lst;
div_ class => 'reviews', sub {
article_ class => 'reviewbox', sub {
@@ -64,8 +64,8 @@ sub reviews_ {
}
-TUWF::get qr{/$RE{vid}/(?<mini>mini)?reviews}, sub {
- my $mini = !!tuwf->capture('mini');
+TUWF::get qr{/$RE{vid}/(?<mini>mini|full)?reviews}, sub {
+ my $mini = !tuwf->capture('mini') ? undef : tuwf->capture('mini') eq 'mini' ? 1 : 0;
my $v = db_entry v => tuwf->capture('id');
return tuwf->resNotFound if !$v;
VNWeb::VN::Page::enrich_vn($v);
@@ -73,8 +73,13 @@ TUWF::get qr{/$RE{vid}/(?<mini>mini)?reviews}, sub {
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, ($mini?'minireviews':'reviews'));
- reviews_ $v, $mini;
+ VNWeb::VN::Page::tabs_($v, !defined $mini ? 'reviews' : $mini ? 'minireviews' : 'fullreviews');
+ if(defined $mini) {
+ reviews_ $v, $mini;
+ } else {
+ reviews_ $v, 1;
+ reviews_ $v, 0;
+ }
};
};
diff --git a/lib/VNWeb/VN/Page.pm b/lib/VNWeb/VN/Page.pm
index a8e5ea80..ae32ecf3 100644
--- a/lib/VNWeb/VN/Page.pm
+++ b/lib/VNWeb/VN/Page.pm
@@ -398,8 +398,12 @@ sub tabs_ {
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 '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};
+ if($reviews->{mini} > 4 || $tab eq 'minireviews' || $tab eq 'fullreviews') {
+ 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 'fullreviews'?' tabselected' : ''), sub { a_ href => "/v$v->{id}/fullreviews#review", name => 'review', "full reviews ($reviews->{full})" } if $reviews->{full};
+ } elsif($reviews->{mini} || $reviews->{full}) {
+ li_ class => ($tab =~ /reviews/ ?' tabselected':''), sub { a_ href => "/v$v->{id}/reviews#review", name => 'review', sprintf 'reviews (%d)', $reviews->{mini}+$reviews->{full} };
+ }
};
ul_ sub {
if(auth && canvote $v) {