diff options
author | Daniel Friesel <derf@finalrewind.org> | 2015-09-18 22:31:56 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2015-09-18 22:31:56 +0200 |
commit | f12b977e9996439d8fc7d5987ca9581b07966a2d (patch) | |
tree | 7f3350270b5cd7ab96fdc3705355b2ade1b59489 | |
parent | 438505f1cb7c5542104f36626a14c6d59b7f475a (diff) |
switch to HAFAS backend, also improved legacy / sub-backend support
-rw-r--r-- | index.pl | 34 | ||||
-rw-r--r-- | templates/main.html.ep | 6 |
2 files changed, 19 insertions, 21 deletions
@@ -11,7 +11,7 @@ use List::Util qw(first); use List::MoreUtils qw(any); use App::VRR::Fakedisplay; -use Travel::Status::DE::DeutscheBahn; +use Travel::Status::DE::HAFAS; use Travel::Status::DE::ASEAG; use Travel::Status::DE::EFA; @@ -52,12 +52,19 @@ sub get_results { lock_level => Cache::File::LOCK_LOCAL(), ); - if ( $backend =~ m{ [.] }x ) { - ($sub_backend) = ( $backend =~ m{ [.] (.+) $ }x ); + # legacy values + if ( not defined $backend or $backend eq 'vrr' ) { + $backend = 'efa.VRR'; + } + + if ( $backend =~ s{ [.] (.+) $ }{}x ) { + $sub_backend = $1; - if ( not $sub_backend ~~ \@efa_services ) { - $sub_backend = undef; - $backend =~ s{ [.] (.+) $ }{}x; + if ( $backend eq 'efa' and not $sub_backend ~~ \@efa_services ) { + return { + results => [], + errstr => "efa sub-backend '$sub_backend' not supported" + }; } } @@ -72,18 +79,9 @@ sub get_results { } my $status; if ( $backend eq 'db' ) { - $status = Travel::Status::DE::DeutscheBahn->new( - station => "${stop}, ${city}", - mot => { - ice => 0, - ic_ec => 0, - d => 0, - nv => 0, - s => 1, - bus => 1, - u => 1, - tram => 1, - }, + $status = Travel::Status::DE::HAFAS->new( + station => "${stop}, ${city}", + excluded_mots => [qw[ice ic_ec d regio]], ); } elsif ( $backend eq 'aseag' ) { diff --git a/templates/main.html.ep b/templates/main.html.ep index 7dc9cb9..13dda0e 100644 --- a/templates/main.html.ep +++ b/templates/main.html.ep @@ -51,7 +51,7 @@ Data is cached for 1 minute. JSON format: % if (param('backend') and param('backend') eq 'db') { serialized <a href="http://finalrewind.org/projects/Travel-Status-DE-DeutscheBahn/"> -Travel::Status::DE::DeutscheBahn</a>-objects, see the +Travel::Status::DE::HAFAS</a>-objects, see the <a href="http://man.finalrewind.org/3/Travel-Status-DE-DeutscheBahn-Result/">::Result</a> documentation % } @@ -186,8 +186,8 @@ v<%= $version %><br/> Backends:<br/> <a href="http://finalrewind.org/projects/Travel-Status-DE-URA/">Travel::Status::DE::ASEAG</a> v<%= $Travel::Status::DE::ASEAG::VERSION %><br/> -<a href="http://finalrewind.org/projects/Travel-Status-DE-DeutscheBahn/">Travel::Status::DE::DeutscheBahn</a> -v<%= $Travel::Status::DE::DeutscheBahn::VERSION %><br/> +<a href="http://finalrewind.org/projects/Travel-Status-DE-DeutscheBahn/">Travel::Status::DE::HAFAS</a> +v<%= $Travel::Status::DE::HAFAS::VERSION %><br/> <a href="http://finalrewind.org/projects/Travel-Status-DE-VRR/">Travel::Status::DE::EFA</a> v<%= $Travel::Status::DE::EFA::VERSION %><br/> </div> |