backend: adapt to /media/tags/:media_id API change

This commit is contained in:
Lucas 2023-03-26 16:41:29 +00:00
parent 945770eb1b
commit 1a2e86d666
2 changed files with 10 additions and 4 deletions

View File

@ -42,17 +42,23 @@ sub show ($self)
my $media_id = $self->stash("media_id"); my $media_id = $self->stash("media_id");
my $poorbooru_api = $self->config("poorbooru_api"); my $poorbooru_api = $self->config("poorbooru_api");
my $res = $self->ua->get("$poorbooru_api/media/$media_id?page=$page") my $res = $self->ua->get("$poorbooru_api/media/$media_id")
->result; ->result;
return $self->render(status => $res->code) if $res->is_error; return $self->render(status => $res->code) if $res->is_error;
my $media = $res->json; my $media = $res->json;
$media->{download} = $self->seaweed->url_for($media->{download}); $media->{download} = $self->seaweed->url_for($media->{download});
$res = $self->ua->get("$poorbooru_api/media/tags/$media_id?page=$page")
->result;
my $tags = $res->json->{tags};
return $self->render(status => $res->code) if $res->is_error;
return $self->render( return $self->render(
template => "media", template => "media",
media => $media, media => $media,
tags => $tags,
pager => { $self->pager_links($res->json->{pager}) }, pager => { $self->pager_links($res->json->{pager}) },
); );
}; };

View File

@ -14,11 +14,11 @@
<dt>Content-Type</dt> <dt>Content-Type</dt>
<dd><%= $media->{content_type} %></dd> <dd><%= $media->{content_type} %></dd>
<dt>Tags</dt> <dt>Tags</dt>
% if ($media->{tags}->@* == 0) { % if ($tags->@* == 0) {
<dd>None yet.</dd> <dd>None yet.</dd>
% } else { % } else {
<dd> <dd>
% for my $tag ($media->{tags}->@*) { % for my $tag ($tags->@*) {
<%= link_to $tag => url_for("tag_show", tag_id_or_name => $tag) %> <%= link_to $tag => url_for("tag_show", tag_id_or_name => $tag) %>
% } % }
</dd> </dd>