From dfe820952f13ccd792130758303c338dc94d3bc9 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Tue, 15 Aug 2023 08:37:14 +0200 Subject: station board: add iris / hafas links --- lib/Travelynx/Controller/Traveling.pm | 16 +++++++++++++++- templates/departures.html.ep | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index b64fcfa..4d2f22d 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -907,9 +907,17 @@ sub station { $promise->then( sub { my ($status) = @_; - + my $api_link; my @results; + if ($use_hafas) { + + my $iris_eva = List::Util::min grep { $_ >= 1000000 } + @{ $status->station->{evas} // [] }; + if ($iris_eva) { + $api_link = '/s/' . $iris_eva; + } + my $now = $self->now->epoch; @results = map { $_->[0] } sort { $b->[1] <=> $a->[1] } @@ -928,6 +936,9 @@ sub station { }; } else { + + $api_link = '/s/' . $status->{station_eva} . '?hafas=1'; + # You can't check into a train which terminates here @results = grep { $_->departure } @{ $status->{results} }; @@ -991,6 +1002,7 @@ sub station { user_status => $user_status, can_check_out => $can_check_out, connections => $connecting_trains, + api_link => $api_link, title => "travelynx: $status->{station_name}", ); } @@ -1005,6 +1017,7 @@ sub station { related_stations => $status->{related_stations}, user_status => $user_status, can_check_out => $can_check_out, + api_link => $api_link, title => "travelynx: $status->{station_name}", ); } @@ -1020,6 +1033,7 @@ sub station { related_stations => $status->{related_stations}, user_status => $user_status, can_check_out => $can_check_out, + api_link => $api_link, title => "travelynx: $status->{station_name}", ); } diff --git a/templates/departures.html.ep b/templates/departures.html.ep index c165d71..3b63016 100644 --- a/templates/departures.html.ep +++ b/templates/departures.html.ep @@ -6,6 +6,26 @@ % } +% if ($api_link) { +
+ % if (param('hafas')) { + +
+ → Nahverkehr ← +
+ % } + % else { +
+ → Schienenverkehr ← +
+ + % } +
+% } % my $have_connections = 0; % if ($user_status->{checked_in}) {
-- cgit v1.2.3