summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.pl21
-rw-r--r--templates/main.html.ep5
2 files changed, 24 insertions, 2 deletions
diff --git a/index.pl b/index.pl
index f1d9fad..5e792aa 100644
--- a/index.pl
+++ b/index.pl
@@ -32,6 +32,9 @@ my %default = (
my @efa_services
= map { $_->{shortname} } Travel::Status::DE::EFA::get_efa_urls();
+my @hafas_services
+ = map { $_->{shortname} } Travel::Status::DE::HAFAS::get_services();
+
sub log_api_access {
my $counter = 1;
if ( -r $ENV{VRRFAKEDISPLAY_STATS} ) {
@@ -56,6 +59,9 @@ sub get_results {
if ( not defined $backend or $backend eq 'vrr' ) {
$backend = 'efa.VRR';
}
+ if ( $backend and $backend eq 'db' ) {
+ $backend = 'hafas.DB';
+ }
if ( $backend =~ s{ [.] (.+) $ }{}x ) {
$sub_backend = $1;
@@ -66,6 +72,12 @@ sub get_results {
errstr => "efa sub-backend '$sub_backend' not supported"
};
}
+ if ( $backend eq 'hafas' and not $sub_backend ~~ \@hafas_services ) {
+ return {
+ results => [],
+ errstr => "hafas sub-backend '$sub_backend' not supported"
+ };
+ }
}
my $sstr = ("${backend} _ ${stop} _ ${city}");
@@ -78,10 +90,11 @@ sub get_results {
log_api_access();
}
my $status;
- if ( $backend eq 'db' ) {
+ if ( $backend eq 'hafas' ) {
$status = Travel::Status::DE::HAFAS->new(
station => "${stop}, ${city}",
excluded_mots => [qw[ice ic_ec d regio]],
+ service => $sub_backend,
);
}
elsif ( $backend eq 'aseag' ) {
@@ -519,6 +532,12 @@ helper 'efa_service_list' => sub {
return @efa_services;
};
+helper 'hafas_service_list' => sub {
+ my $self = shift;
+
+ return @hafas_services;
+};
+
get '/_redirect' => sub {
my $self = shift;
my $city = $self->param('city') // q{};
diff --git a/templates/main.html.ep b/templates/main.html.ep
index 13dda0e..589f690 100644
--- a/templates/main.html.ep
+++ b/templates/main.html.ep
@@ -155,7 +155,10 @@ other German transit networks.
% my @efa_backends = map { ["$_ (EFA)" => "efa.$_"] } efa_service_list();
% @efa_backends = map { $_->[1] } sort { $a->[0] cmp $b->[0] }
% map { [$_->[0], $_] } @efa_backends;
- %= select_field backend => [['EFA / VRR' => 'vrr'], ['DB (HAFAS)' => 'db'], ['ASEAG (URA)' => 'aseag'], @efa_backends]
+ % my @hafas_backends = map { ["$_ (HAFAS)" => "hafas.$_"] } hafas_service_list();
+ % @hafas_backends = map { $_->[1] } sort { $a->[0] cmp $b->[0] }
+ % map { [$_->[0], $_] } @hafas_backends;
+ %= select_field backend => [['EFA / VRR' => 'vrr'], ['DB (HAFAS)' => 'db'], ['ASEAG (URA)' => 'aseag'], @efa_backends, @hafas_backends]
</div>
</div>
</div>