summaryrefslogtreecommitdiff
path: root/lib/VNWeb
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-06-23 16:13:09 +0200
committerYorhel <git@yorhel.nl>2021-06-23 16:13:09 +0200
commit5c7f8d41a3f4ec9415708064352291ead97bab79 (patch)
tree1f889fb4402bb3e0b9416ec35d6f097b66397282 /lib/VNWeb
parent469e99d4481310468a084b0679d7622ede4662ab (diff)
Chars::List: Attempt to improve grid view
Diffstat (limited to 'lib/VNWeb')
-rw-r--r--lib/VNWeb/Chars/List.pm20
-rw-r--r--lib/VNWeb/Images/Lib.pm1
2 files changed, 10 insertions, 11 deletions
diff --git a/lib/VNWeb/Chars/List.pm b/lib/VNWeb/Chars/List.pm
index 4e4aaf66..1f7ef73c 100644
--- a/lib/VNWeb/Chars/List.pm
+++ b/lib/VNWeb/Chars/List.pm
@@ -55,18 +55,16 @@ sub listing_ {
} for @$list;
} if $opt->{s}->cards;
+
div_ class => 'mainbox charbgrid', sub {
- my($w,$h) = (170,210);
- div_ sub {
- a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
- div_ sub {
- if($_->{image}) {
- my($iw,$ih) = imgsize $_->{image}{width}*100, $_->{image}{height}*100, $w, $h;
- image_ $_->{image}, alt => $_->{name}, width => $iw, height => $ih, url => "/$_->{id}", overlay => undef;
- } else {
- txt_ 'no image';
- }
- };
+ # XXX: This logic is repeated in Images::Lib (and possibly elsewhere), might want to abstract it.
+ my $sexp = auth->pref('max_sexual')||0;
+ my $viop = auth->pref('max_violence')||0;
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{name},
+ $sexp < 0 || $_->{image}{sexual} > $sexp || $_->{image}{violence} > $viop || (!$_->{image}{votecount} && ($sexp < 2 || $viop < 2))
+ ? () : (style => 'background-image: url("'.imgurl($_->{image}{id}).'")'),
+ sub {
+ span_ $_->{name};
} for @$list;
} if $opt->{s}->grid;
diff --git a/lib/VNWeb/Images/Lib.pm b/lib/VNWeb/Images/Lib.pm
index 74366390..a5d42386 100644
--- a/lib/VNWeb/Images/Lib.pm
+++ b/lib/VNWeb/Images/Lib.pm
@@ -83,6 +83,7 @@ sub image_flagging_display {
# height -> if different from original image
# url -> link the image to a page (if not hidden by settings)
# overlay -> CODE ref, html to replace the overlay with.
+# XXX: Not all of these options are used, could clean up a few.
sub image_ {
my($img, %opt) = @_;
return p_ 'No image' if !$img;