api: always return a list of media_ids

This commit is contained in:
Lucas 2023-02-18 17:14:40 +00:00
parent 0876464b5b
commit 216422f50a
2 changed files with 4 additions and 10 deletions

View File

@ -63,8 +63,8 @@ get "/tag/:tag_id_or_name" => sub {
my $data = decode_json($res->{content});
my @media = map +( {
# XXX point to a cache
image_src => $POORBOORU_API . $_->{download_path},
view_uri => uri_for("/view/" . $_->{id}),
image_src => "$POORBOORU_API/download/$_",
view_uri => uri_for("/view/$_"),
} ), @{$data->{media}};
template "gallery" => {

View File

@ -73,13 +73,7 @@ get "/tag/:tag_id_or_name" => sub {
return {
id => $tag->tag_id,
name => $tag->name,
media => [
map +( {
id => $_,
path => "/media/$_",
download_path => "/download/$_",
} ), @media,
],
media => \@media,
};
};
@ -92,7 +86,7 @@ get "/media" => sub {
->page($page);
my ($prev, $next) = surrounding_pages($paged_media);
my @media = map { "/media/" . $_->media_id } $paged_media->all;
my @media = map { $_->media_id } $paged_media->all;
return {
next => ($next and "/media?page=$next"),