summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-09-12 00:41:16 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-09-12 00:41:16 +0200
commit88b2cb36297ad2dcd661040b79a04c6fb34ed319 (patch)
tree0f7b32acf71ae5598793fd942cb9283c354bc1e3 /index.pl
parent65634e360e73592369616093ce5b49da38f28796 (diff)
support all known EFA entry points0.09
Diffstat (limited to 'index.pl')
-rw-r--r--index.pl33
1 files changed, 32 insertions, 1 deletions
diff --git a/index.pl b/index.pl
index 9ed5c56..2eeb4be 100644
--- a/index.pl
+++ b/index.pl
@@ -6,6 +6,7 @@ use utf8;
use DateTime;
use DateTime::Format::Strptime;
use Encode qw(decode);
+use List::Util qw(first);
use List::MoreUtils qw(any);
use App::VRR::Fakedisplay;
@@ -27,8 +28,12 @@ my %default = (
platform => q{},
);
+my @efa_services
+ = map { $_->{shortname} } Travel::Status::DE::EFA::get_efa_urls();
+
sub get_results {
my ( $backend, $city, $stop, $expiry ) = @_;
+ my $sub_backend;
$expiry ||= 150;
@@ -38,6 +43,16 @@ sub get_results {
lock_level => Cache::File::LOCK_LOCAL(),
);
+ if ( $backend =~ m{ [.] }x ) {
+ ($sub_backend) = ( $backend =~ m{ [.] (.+) $ }x );
+
+ if ( not $sub_backend ~~ \@efa_services ) {
+ $sub_backend = undef;
+ $backend =~ s{ [.] (.+) $ }{}x;
+ }
+ }
+ say "$backend : $sub_backend";
+
my $sstr = ("${backend} _ ${stop} _ ${city}");
$sstr =~ tr{a-zA-Z0-9}{_}c;
@@ -67,7 +82,17 @@ sub get_results {
);
}
else {
- $status = Travel::Status::DE::VRR->new(
+ my $efa_url = 'http://efa.vrr.de/vrr/XSLT_DM_REQUEST';
+ if ($sub_backend) {
+ my $service
+ = first { lc( $_->{shortname} ) eq lc($sub_backend) }
+ Travel::Status::DE::EFA::get_efa_urls();
+ if ($service) {
+ $efa_url = $service->{url};
+ }
+ }
+ $status = Travel::Status::DE::EFA->new(
+ efa_url => $efa_url,
place => $city,
name => $stop,
timeout => 3,
@@ -479,6 +504,12 @@ sub render_image {
return;
}
+helper 'efa_service_list' => sub {
+ my $self = shift;
+
+ return @efa_services;
+};
+
get '/_redirect' => sub {
my $self = shift;
my $city = $self->param('city') // q{};