summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/DBInfoscreen.pm')
-rw-r--r--lib/DBInfoscreen.pm88
1 files changed, 82 insertions, 6 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm
index c784e96..18a2c87 100644
--- a/lib/DBInfoscreen.pm
+++ b/lib/DBInfoscreen.pm
@@ -7,8 +7,10 @@ package DBInfoscreen;
use Mojo::Base 'Mojolicious';
use Cache::File;
+use DBInfoscreen::Helper::DBRIS;
use DBInfoscreen::Helper::EFA;
use DBInfoscreen::Helper::HAFAS;
+use DBInfoscreen::Helper::MOTIS;
use DBInfoscreen::Helper::Wagonorder;
use File::Slurp qw(read_file);
use JSON;
@@ -92,6 +94,34 @@ sub startup {
);
$self->helper(
+ dbris => sub {
+ my ($self) = @_;
+ state $efa = DBInfoscreen::Helper::DBRIS->new(
+ log => $self->app->log,
+ main_cache => $self->app->cache_iris_main,
+ realtime_cache => $self->app->cache_iris_rt,
+ root_url => $self->url_for('/')->to_abs,
+ user_agent => $self->ua,
+ version => $self->config->{version},
+ );
+ }
+ );
+
+ $self->helper(
+ motis => sub {
+ my ($self) = @_;
+ state $motis = DBInfoscreen::Helper::MOTIS->new(
+ log => $self->app->log,
+ main_cache => $self->app->cache_iris_main,
+ realtime_cache => $self->app->cache_iris_rt,
+ root_url => $self->url_for('/')->to_abs,
+ user_agent => $self->ua,
+ version => $self->config->{version},
+ );
+ }
+ );
+
+ $self->helper(
efa => sub {
my ($self) = @_;
state $efa = DBInfoscreen::Helper::EFA->new(
@@ -178,6 +208,11 @@ sub startup {
{
return 1;
}
+ if ( ( $self->param('hafas') or $self->param('efa') )
+ and $stop =~ m{ [Bb]ahnhof | Bf }x )
+ {
+ return 1;
+ }
return;
}
);
@@ -187,9 +222,27 @@ sub startup {
my ( $self, $occupancy ) = @_;
my @symbols
- = (qw(help_outline person_outline people priority_high));
+ = (
+ qw(help_outline person_outline people priority_high not_interested)
+ );
my $text = 'Auslastung unbekannt';
+ if ( $occupancy eq 'MANY_SEATS' ) {
+ $occupancy = 1;
+ }
+ elsif ( $occupancy eq 'FEW_SEATS' ) {
+ $occupancy = 2;
+ }
+ elsif ( $occupancy eq 'STANDING_ONLY' ) {
+ $occupancy = 3;
+ }
+ elsif ( $occupancy eq 'FULL' ) {
+ $occupancy = 4;
+ }
+
+ if ( $occupancy > 3 ) {
+ $text = 'Voraussichtlich überfüllt';
+ }
if ( $occupancy > 2 ) {
$text = 'Sehr hohe Auslastung erwartet';
}
@@ -255,6 +308,25 @@ sub startup {
}
);
+ $self->helper(
+ 'get_rt_time_class' => sub {
+ my ( $self, $train ) = @_;
+ if ( $train->{has_realtime}
+ and not $train->{is_bit_delayed}
+ and not $train->{is_delayed} )
+ {
+ return 'on-time';
+ }
+ if ( $train->{is_bit_delayed} ) {
+ return 'a-bit-delayed';
+ }
+ if ( $train->{is_delayed} ) {
+ return 'delayed';
+ }
+ return q{};
+ }
+ );
+
my $r = $self->routes;
$r->get('/_redirect')->to('stationboard#redirect_to_station');
@@ -264,6 +336,8 @@ sub startup {
$r->get('/_autostop')->to('static#geostop');
+ $r->get('/_backend')->to('stationboard#backend_list');
+
$r->get('/_datenschutz')->to('static#privacy');
$r->post('/_geolocation')->to('stationboard#stations_by_coordinates');
@@ -274,23 +348,25 @@ sub startup {
$r->get('/dyn/:av/autocomplete.js')->to('stationboard#autocomplete');
- $r->get('/_wr/:train/:departure')->to('wagenreihung#wagenreihung');
+ $r->get('/carriage-formation')->to('wagenreihung#wagenreihung');
$r->get('/w/*wagon')->to('wagenreihung#wagen');
$r->get('/_ajax_mapinfo/:tripid/:lineno')->to('map#ajax_route');
$r->get('/map/:tripid/:lineno')->to('map#route');
+ $r->get('/coverage/:backend/:service')->to('map#coverage');
$r->get( '/z/:train/*station' => [ format => [ 'html', 'json' ] ] )
->to( 'stationboard#station_train_details', format => undef )
->name('train_at_station');
$r->get( '/z/:train' => [ format => [ 'html', 'json' ] ] )
- ->to( 'stationboard#train_details', format => undef )->name('train');
+ ->to( 'stationboard#train_details', format => undef )
+ ->name('train');
$self->defaults( layout => 'app' );
- $r->get('/')->to('stationboard#handle_request');
- $r->get('/multi/*station')->to('stationboard#handle_request');
+ $r->get('/')->to('stationboard#handle_board_request');
+ $r->get('/multi/*station')->to('stationboard#handle_board_request');
$r->get( '/*station' => [ format => [ 'html', 'json' ] ] )
- ->to( 'stationboard#handle_request', format => undef );
+ ->to( 'stationboard#handle_board_request', format => undef );
$self->types->type( json => 'application/json; charset=utf-8' );