| 1 | package Jifty::Plugin::SinglePage::Dispatcher; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use Jifty::Dispatcher -base; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Jifty::Plugin::SinglePage::Dispatcher - Dispatcher for SinglePage plugin | ||
| 9 | |||
| 10 | =head1 DESCRIPTION | ||
| 11 | |||
| 12 | Dispatcher for L<Jifty::Plugin::SinglePage> | ||
| 13 | |||
| 14 | =cut | ||
| 15 | |||
| 16 | before '__jifty/webservices/*' => run { | ||
| 17 | my (@actions) = grep { $_->class eq 'Jifty::Action::Redirect' } values %{ Jifty->web->request->{'actions'} }; | ||
| 18 | $_->active(0) for @actions; | ||
| 19 | |||
| 20 | # XXX: shouldn't have multiple redirect | ||
| 21 | # Simply ignore Redirect from webservice if we are not in SPA | ||
| 22 | Jifty->web->request->argument( '_webservice_redirect' => [map { $_->arguments->{url} } @actions] ) | ||
| 23 | if Jifty->find_plugin('Jifty::Plugin::SinglePage'); | ||
| 24 | |||
| 25 | }; | ||
| 26 | |||
| 27 | on qr{(__jifty/webservices/.*)} => run { | ||
| 28 | my $actions = get '_webservice_redirect'; | ||
| 29 | for my $act (@$actions) { | ||
| 30 | if ($act =~ m{^https?://}) { | ||
| 31 | Jifty->web->request->argument( '_webservice_external_redirect' => $act ); | ||
| 32 | } | ||
| 33 | else { | ||
| 34 | Jifty->web->webservices_redirect($act); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | show $1; | ||
| 38 | }; | ||
| 39 | |||
| 40 | 1; |