From 9c7d87e0a67dadec3c13435c743b4498a5be1b91 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 6 Jan 2020 20:58:20 +0100 Subject: show planned IC/ICE subtype if available (experimental!) --- lib/DBInfoscreen.pm | 16 ++++++++++++++++ lib/DBInfoscreen/Controller/Stationboard.pm | 1 + 2 files changed, 17 insertions(+) (limited to 'lib') diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm index c1455ff..d8f5b87 100644 --- a/lib/DBInfoscreen.pm +++ b/lib/DBInfoscreen.pm @@ -5,6 +5,8 @@ use Mojo::Base 'Mojolicious'; # License: 2-Clause BSD use Cache::File; +use File::Slurp qw(read_file); +use JSON; use Travel::Status::DE::HAFAS; use Travel::Status::DE::HAFAS::StopFinder; use Travel::Status::DE::IRIS::Stations; @@ -60,6 +62,20 @@ sub startup { } ); + $self->attr( + ice_type_map => sub { + my $ice_type_map = JSON->new->utf8->decode( + scalar read_file('share/ice_type.json') ); + my $ret; + while ( my ( $k, $v ) = each %{$ice_type_map} ) { + if ( $v->{short} ) { + $ret->{$k} = $v->{short}; + } + } + return $ret; + } + ); + $self->helper( 'handle_no_results' => sub { my ( $self, $backend, $station, $errstr ) = @_; diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 4af9ff4..60caf8d 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -1270,6 +1270,7 @@ sub handle_request { $self->render( $template, departures => \@departures, + ice_type => $self->app->ice_type_map, version => $dbf_version, title => $via ? "$station_name → $via" : $station_name, refresh_interval => $template eq 'app' ? 0 : 120, -- cgit v1.2.3