backend: implement /random/media and /random/tag
This commit is contained in:
parent
88b5354529
commit
91d73cd314
@ -60,7 +60,7 @@ hook before_template_render => sub {
|
||||
$tokens->{uris}->{root} = uri_for("/");
|
||||
$tokens->{uris}->{login} = uri_for("/login");
|
||||
$tokens->{uris}->{logout} = uri_for("/logout");
|
||||
$tokens->{uris}->{random} = uri_for("/random");
|
||||
$tokens->{uris}->{random} = uri_for("/random/media");
|
||||
$tokens->{uris}->{tags} = uri_for("/tags");
|
||||
};
|
||||
|
||||
@ -148,12 +148,22 @@ get "/media/:media_id" => sub {
|
||||
};
|
||||
};
|
||||
|
||||
get "/random" => sub {
|
||||
my $res = api_get("/random");
|
||||
get "/random/media" => sub {
|
||||
my $res = api_get("/random/media");
|
||||
send_error("API error", 500) if !$res->{success};
|
||||
|
||||
my $data = decode_json($res->{content});
|
||||
forward "/media/" . $data->{id};
|
||||
# XXX body content.
|
||||
redirect "/media/" . $data->{id};
|
||||
};
|
||||
|
||||
get "/random/tag" => sub {
|
||||
my $res = api_get("/random/tag");
|
||||
send_error("API error", 500) if !$res->{success};
|
||||
|
||||
my $data = decode_json($res->{content});
|
||||
# XXX body content.
|
||||
redirect "/tag/" . $data->{id};
|
||||
};
|
||||
|
||||
true;
|
||||
|
Loading…
Reference in New Issue
Block a user