diff --git a/lib/PoorBooru.pm b/lib/PoorBooru.pm index 78f7011..56d849c 100644 --- a/lib/PoorBooru.pm +++ b/lib/PoorBooru.pm @@ -107,9 +107,12 @@ get "/tags" => sub { }; get "/tag/:tag_id_or_name" => sub { + my $page = query_parameters->get("page") // 1; + send_error("Invalid page number", 400) if !validate_page_number($page); + my $tag_id_or_name = route_parameters->get("tag_id_or_name"); - my $res = api_get("/tag/$tag_id_or_name"); + my $res = api_get("/tag/$tag_id_or_name", { page => $page }); send_error("API error", 500) if !$res->{success}; my $data = decode_json($res->{content}); @@ -122,6 +125,7 @@ get "/tag/:tag_id_or_name" => sub { template "gallery" => { title => $data->{name}, media => \@media, + pager => nav_pager($data->{pager}, "/tag/$tag_id_or_name"), }; };