diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2020-01-06 20:58:20 +0100 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2020-01-06 20:58:20 +0100 | 
| commit | 9c7d87e0a67dadec3c13435c743b4498a5be1b91 (patch) | |
| tree | 2bd81e117a2b8bc78a5564d1ba9d933cfc284d06 /lib | |
| parent | f5d1b92ac24883a72864ea65255a14c870f63794 (diff) | |
show planned IC/ICE subtype if available (experimental!)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/DBInfoscreen.pm | 16 | ||||
| -rw-r--r-- | lib/DBInfoscreen/Controller/Stationboard.pm | 1 | 
2 files changed, 17 insertions, 0 deletions
| 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, | 
