api: change the pager output
This commit is contained in:
parent
1ea50ed54f
commit
79a9173574
@ -10,12 +10,8 @@ my $MEDIA_SEARCH_OPTS = {
|
|||||||
rows => 5,
|
rows => 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
sub _pager_links ($c, $pager)
|
my @PAGER_KEYS = qw(first_page previous_page current_page next_page last_page);
|
||||||
{
|
sub _pager ($p) { +{ map +( $_ => $p->$_ ), @PAGER_KEYS } }
|
||||||
+{ map +( $_ => ($pager->$_ and
|
|
||||||
$c->url_with->query({page => $pager->$_})) ),
|
|
||||||
qw(first_page previous_page current_page next_page last_page) }
|
|
||||||
}
|
|
||||||
|
|
||||||
sub list ($self)
|
sub list ($self)
|
||||||
{
|
{
|
||||||
@ -35,7 +31,7 @@ sub list ($self)
|
|||||||
}, $paged_media->all;
|
}, $paged_media->all;
|
||||||
|
|
||||||
return $self->render(json => {
|
return $self->render(json => {
|
||||||
pager => _pager_links($self, $paged_media->pager),
|
pager => _pager($paged_media->pager),
|
||||||
media => \@media,
|
media => \@media,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -14,12 +14,8 @@ my $TAGS_COUNT_VIEW_SEARCH_OPTS = {
|
|||||||
rows => 5,
|
rows => 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
sub _pager_links ($c, $pager)
|
my @PAGER_KEYS = qw(first_page previous_page current_page next_page last_page);
|
||||||
{
|
sub _pager ($p) { +{ map +( $_ => $p->$_ ), @PAGER_KEYS } }
|
||||||
+{ map +( $_ => ($pager->$_ and
|
|
||||||
$c->url_with->query({page => $pager->$_})) ),
|
|
||||||
qw(first_page previous_page current_page next_page last_page) }
|
|
||||||
}
|
|
||||||
|
|
||||||
sub list ($self)
|
sub list ($self)
|
||||||
{
|
{
|
||||||
@ -40,7 +36,7 @@ sub list ($self)
|
|||||||
}, $paged_tags->all;
|
}, $paged_tags->all;
|
||||||
|
|
||||||
return $self->render(json => {
|
return $self->render(json => {
|
||||||
pager => _pager_links($self, $paged_tags->pager),
|
pager => _pager($paged_tags->pager),
|
||||||
tags => \@tags,
|
tags => \@tags,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -82,7 +78,7 @@ sub show ($self)
|
|||||||
return $self->render(json => {
|
return $self->render(json => {
|
||||||
id => $tag->tag_id,
|
id => $tag->tag_id,
|
||||||
name => $tag->name,
|
name => $tag->name,
|
||||||
pager => _pager_links($self, $paged_media->pager),
|
pager => _pager($paged_media->pager),
|
||||||
media => \@media,
|
media => \@media,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user