summaryrefslogtreecommitdiff
path: root/lib/VNWeb/Chars/List.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-02-20 17:36:14 +0100
committerYorhel <git@yorhel.nl>2021-02-20 17:38:37 +0100
commit27e8a4f2727a05de48fe52d92bc4b4648af3fe5d (patch)
tree11742084323cfd25425d7bbc60fc368dac40aceb /lib/VNWeb/Chars/List.pm
parent506f8470c57feeefb27869a29d4193d9fd33ad31 (diff)
Chars::List: Add experimental grid mode
Diffstat (limited to 'lib/VNWeb/Chars/List.pm')
-rw-r--r--lib/VNWeb/Chars/List.pm23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/VNWeb/Chars/List.pm b/lib/VNWeb/Chars/List.pm
index ab6ee691..f0bbc724 100644
--- a/lib/VNWeb/Chars/List.pm
+++ b/lib/VNWeb/Chars/List.pm
@@ -9,6 +9,8 @@ use VNWeb::Images::Lib;
# Also used by VNWeb::TT::TraitPage
sub listing_ {
my($opt, $list, $count) = @_;
+ $opt->{card} //= 0;
+
my sub url { '?'.query_encode %$opt, @_ }
paginate_ \&url, $opt->{p}, [$count, 50], 't';
@@ -48,7 +50,22 @@ sub listing_ {
};
};
} for @$list;
- } if $opt->{card};
+ } if $opt->{card} == 1;
+
+ div_ class => 'mainbox charbgrid', sub {
+ my($w,$h) = (160,200);
+ div_ sub {
+ a_ href => "/c$_->{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 => "/c$_->{id}";
+ } else {
+ txt_ 'no image';
+ }
+ };
+ } for @$list;
+ } if $opt->{card} == 2;
paginate_ \&url, $opt->{p}, [$count, 50], 'b';
}
@@ -73,7 +90,7 @@ TUWF::get qr{/c(?:/(?<char>all|[a-z0]))?}, sub {
f => { advsearch_err => 'c' },
ch=> { onerror => [], type => 'array', scalar => 1, values => { onerror => undef, enum => ['0', 'a'..'z'] } },
fil => { required => 0 },
- card => { anybool => 1 }, # XXX: Experimental option, will be consolidated into a merged "display settings" field
+ card => { onerror => 0, enum => [0..2] }, # XXX: Experimental option, will be consolidated into a merged "display settings" field
)->data;
$opt->{ch} = $opt->{ch}[0];
@@ -112,7 +129,7 @@ TUWF::get qr{/c(?:/(?<char>all|[a-z0]))?}, sub {
} || (($count, $list) = (undef, []));
enrich_listing $list;
- enrich_image_obj image => $list;
+ enrich_image_obj image => $list if $opt->{card};
$time = time - $time;
framework_ title => 'Browse characters', sub {