From 82aeb0c536ee960e1e3d542e199c1114133bf979 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 19 Feb 2023 18:17:59 +0000 Subject: [PATCH] backend: handle paged /tag/:tag_id_or_name from API --- lib/PoorBooru.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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"), }; };