Loading lib/DBInfoscreen.pm +4 −3 Original line number Diff line number Diff line Loading @@ -364,7 +364,8 @@ sub startup { $r->get('/_ajax_mapinfo/:tripid/:lineno')->to('map#ajax_route'); $r->get('/map/:tripid/:lineno')->to('map#route'); $r->get('/intersection/:trips')->to('map#intersection'); $r->get('/z/:train/:station')->to('stationboard#train_details'); $r->get('/z/:train/:station')->to('stationboard#station_train_details'); $r->get('/z/:train')->to('stationboard#train_details'); $r->get('/map')->to('map#search_form'); $r->get('/_trainsearch')->to('map#search'); Loading lib/DBInfoscreen/Controller/Stationboard.pm +120 −1 Original line number Diff line number Diff line Loading @@ -824,7 +824,7 @@ sub render_train { )->wait; } sub train_details { sub station_train_details { my ($self) = @_; my $train_no = $self->stash('train'); my $station = $self->stash('station'); Loading Loading @@ -919,6 +919,125 @@ sub train_details { ); } sub train_details { my ($self) = @_; my $train = $self->stash('train'); my ( $train_type, $train_no ) = ( $train =~ m{ ^ (\S+) \s+ (.*) $ }x ); # TODO error handling if ( $self->param('ajax') ) { delete $self->stash->{layout}; } my $api_version = $Travel::Status::DE::IRIS::VERSION; $self->stash( departures => [] ); $self->stash( title => 'DBF' ); $self->stash( version => $self->config->{version} ); my $res = { train_type => $train_type, train_line => undef, train_no => $train_no, route_pre_diff => [], route_post_diff => [], moreinfo => [], replaced_by => [], replacement_for => [], }; $self->stash( title => "${train_type} ${train_no}" ); $self->stash( hide_opts => 1 ); $self->render_later; my $linetype = 'bahn'; $self->hafas->get_route_timestamps_p( train_no => $train_no )->then( sub { my ( $route_ts, $route_info, $trainsearch ) = @_; $res->{trip_id} = $trainsearch->{trip_id}; if ( not defined $trainsearch->{trainClass} ) { $linetype = 'ext'; } elsif ( $trainsearch->{trainClass} <= 2 ) { $linetype = 'fern'; } elsif ( $trainsearch->{trainClass} <= 8 ) { $linetype = 'bahn'; } elsif ( $trainsearch->{trainClass} <= 16 ) { $linetype = 'sbahn'; } $res->{origin} = $route_info->{stations}[0]; $res->{destination} = $route_info->{stations}[-1]; $res->{route_post_diff} = [ map { { name => $_ } } @{ $route_info->{stations} } ]; if ($route_ts) { for my $elem ( @{ $res->{route_post_diff} } ) { for my $key ( keys %{ $route_ts->{ $elem->{name} } // {} } ) { $elem->{$key} = $route_ts->{ $elem->{name} }{$key}; } } } if ( $route_info and @{ $route_info->{messages} // [] } ) { my $him = $route_info->{messages}; my @him_messages; for my $message ( @{$him} ) { if ( $message->{display} ) { push( @him_messages, [ $message->{header}, $message->{lead} ] ); if ( $message->{lead} =~ m{zuginfo.nrw/?\?msg=(\d+)} ) { push( @{ $res->{links} }, [ "Großstörung", "https://zuginfo.nrw/?msg=$1" ] ); } } } $res->{moreinfo} = [@him_messages]; } $self->render( $self->param('ajax') ? '_train_details' : 'train_details', departure => $res, linetype => $linetype, icetype => $self->app->ice_type_map->{ $res->{train_no} }, details => {}, #$departure->{composition} // {}, dt_now => DateTime->now( time_zone => 'Europe/Berlin' ), #station_name => "FIXME",#$station_name, ); } )->catch( sub { my ($e) = @_; if ($e) { $self->render( 'exception', exception => $e, snapshot => {} ); } else { $self->render('not_found'); } } )->wait; } sub handle_result { my ( $self, $data ) = @_; Loading lib/DBInfoscreen/Helper/HAFAS.pm +2 −0 Original line number Diff line number Diff line Loading @@ -321,6 +321,8 @@ sub get_route_timestamps_p { $promise->reject; return; } $trainsearch_result->{trainClass} = $traininfo->{suggestions}[0]{trainClass}; my $ret = {}; my $strp = DateTime::Format::Strptime->new( Loading templates/_train_details.html.ep +19 −12 Original line number Diff line number Diff line Loading @@ -112,7 +112,12 @@ </div> <!-- dataline --> <div class="verbose"> % if ($departure->{trip_id}) { <a class="smallbutton" href="/map/<%= $departure->{trip_id} %>/<%= $departure->{train_line} // 0 %>?from=<%= $station_name %>"><i class="material-icons" aria-hidden="true">map</i> Karte</a> % if (stash('station_name')) { <a class="smallbutton" href="/map/<%= $departure->{trip_id} %>/<%= $departure->{train_line} // 0 %>?from=<%= stash('station_name') %>"><i class="material-icons" aria-hidden="true">map</i> Karte</a> % } % else { <a class="smallbutton" href="/map/<%= $departure->{trip_id} %>/<%= $departure->{train_line} // 0 %>"><i class="material-icons" aria-hidden="true">map</i> Karte</a> % } % } % if ($departure->{wr_link}) { <a class="smallbutton" href="/_wr/<%= $departure->{train_no} %>/<%= $departure->{wr_link} %>?e=<%= $departure->{direction} // '' %>"><i class="material-icons" aria-hidden="true">train</i> Wagenreihung Loading Loading @@ -192,6 +197,7 @@ % } </li> % } % if (stash('station_name')) { <li class="<%= $departure->{is_cancelled} ? 'cancelled-stop' : q{} %>"><%= $departure->{sched_departure} // $departure->{sched_arrival} // q{} %> % if ($departure->{sched_departure}) { % if ($departure->{departure} ne $departure->{sched_departure}) { Loading @@ -203,8 +209,9 @@ (heute <%= $departure->{arrival} %>) % } % } <strong><%= $station_name %></strong> <strong><%= stash('station_name') %></strong> </li> % } % for my $stop (@{$departure->{route_post_diff}}) { <li> <a href="<%= url_for('station', station => $stop->{name})->query({detailed => param('detailed')}) %>" class=" Loading templates/train_details.html.ep +1 −1 Original line number Diff line number Diff line <div class="app" data-station="<%= $station_name %>"> <div class="app" data-station="<%= stash('station_name') // q{} %>"> <div class="moreinfo" data-static="1"> %= include '_train_details' </div> Loading Loading
lib/DBInfoscreen.pm +4 −3 Original line number Diff line number Diff line Loading @@ -364,7 +364,8 @@ sub startup { $r->get('/_ajax_mapinfo/:tripid/:lineno')->to('map#ajax_route'); $r->get('/map/:tripid/:lineno')->to('map#route'); $r->get('/intersection/:trips')->to('map#intersection'); $r->get('/z/:train/:station')->to('stationboard#train_details'); $r->get('/z/:train/:station')->to('stationboard#station_train_details'); $r->get('/z/:train')->to('stationboard#train_details'); $r->get('/map')->to('map#search_form'); $r->get('/_trainsearch')->to('map#search'); Loading
lib/DBInfoscreen/Controller/Stationboard.pm +120 −1 Original line number Diff line number Diff line Loading @@ -824,7 +824,7 @@ sub render_train { )->wait; } sub train_details { sub station_train_details { my ($self) = @_; my $train_no = $self->stash('train'); my $station = $self->stash('station'); Loading Loading @@ -919,6 +919,125 @@ sub train_details { ); } sub train_details { my ($self) = @_; my $train = $self->stash('train'); my ( $train_type, $train_no ) = ( $train =~ m{ ^ (\S+) \s+ (.*) $ }x ); # TODO error handling if ( $self->param('ajax') ) { delete $self->stash->{layout}; } my $api_version = $Travel::Status::DE::IRIS::VERSION; $self->stash( departures => [] ); $self->stash( title => 'DBF' ); $self->stash( version => $self->config->{version} ); my $res = { train_type => $train_type, train_line => undef, train_no => $train_no, route_pre_diff => [], route_post_diff => [], moreinfo => [], replaced_by => [], replacement_for => [], }; $self->stash( title => "${train_type} ${train_no}" ); $self->stash( hide_opts => 1 ); $self->render_later; my $linetype = 'bahn'; $self->hafas->get_route_timestamps_p( train_no => $train_no )->then( sub { my ( $route_ts, $route_info, $trainsearch ) = @_; $res->{trip_id} = $trainsearch->{trip_id}; if ( not defined $trainsearch->{trainClass} ) { $linetype = 'ext'; } elsif ( $trainsearch->{trainClass} <= 2 ) { $linetype = 'fern'; } elsif ( $trainsearch->{trainClass} <= 8 ) { $linetype = 'bahn'; } elsif ( $trainsearch->{trainClass} <= 16 ) { $linetype = 'sbahn'; } $res->{origin} = $route_info->{stations}[0]; $res->{destination} = $route_info->{stations}[-1]; $res->{route_post_diff} = [ map { { name => $_ } } @{ $route_info->{stations} } ]; if ($route_ts) { for my $elem ( @{ $res->{route_post_diff} } ) { for my $key ( keys %{ $route_ts->{ $elem->{name} } // {} } ) { $elem->{$key} = $route_ts->{ $elem->{name} }{$key}; } } } if ( $route_info and @{ $route_info->{messages} // [] } ) { my $him = $route_info->{messages}; my @him_messages; for my $message ( @{$him} ) { if ( $message->{display} ) { push( @him_messages, [ $message->{header}, $message->{lead} ] ); if ( $message->{lead} =~ m{zuginfo.nrw/?\?msg=(\d+)} ) { push( @{ $res->{links} }, [ "Großstörung", "https://zuginfo.nrw/?msg=$1" ] ); } } } $res->{moreinfo} = [@him_messages]; } $self->render( $self->param('ajax') ? '_train_details' : 'train_details', departure => $res, linetype => $linetype, icetype => $self->app->ice_type_map->{ $res->{train_no} }, details => {}, #$departure->{composition} // {}, dt_now => DateTime->now( time_zone => 'Europe/Berlin' ), #station_name => "FIXME",#$station_name, ); } )->catch( sub { my ($e) = @_; if ($e) { $self->render( 'exception', exception => $e, snapshot => {} ); } else { $self->render('not_found'); } } )->wait; } sub handle_result { my ( $self, $data ) = @_; Loading
lib/DBInfoscreen/Helper/HAFAS.pm +2 −0 Original line number Diff line number Diff line Loading @@ -321,6 +321,8 @@ sub get_route_timestamps_p { $promise->reject; return; } $trainsearch_result->{trainClass} = $traininfo->{suggestions}[0]{trainClass}; my $ret = {}; my $strp = DateTime::Format::Strptime->new( Loading
templates/_train_details.html.ep +19 −12 Original line number Diff line number Diff line Loading @@ -112,7 +112,12 @@ </div> <!-- dataline --> <div class="verbose"> % if ($departure->{trip_id}) { <a class="smallbutton" href="/map/<%= $departure->{trip_id} %>/<%= $departure->{train_line} // 0 %>?from=<%= $station_name %>"><i class="material-icons" aria-hidden="true">map</i> Karte</a> % if (stash('station_name')) { <a class="smallbutton" href="/map/<%= $departure->{trip_id} %>/<%= $departure->{train_line} // 0 %>?from=<%= stash('station_name') %>"><i class="material-icons" aria-hidden="true">map</i> Karte</a> % } % else { <a class="smallbutton" href="/map/<%= $departure->{trip_id} %>/<%= $departure->{train_line} // 0 %>"><i class="material-icons" aria-hidden="true">map</i> Karte</a> % } % } % if ($departure->{wr_link}) { <a class="smallbutton" href="/_wr/<%= $departure->{train_no} %>/<%= $departure->{wr_link} %>?e=<%= $departure->{direction} // '' %>"><i class="material-icons" aria-hidden="true">train</i> Wagenreihung Loading Loading @@ -192,6 +197,7 @@ % } </li> % } % if (stash('station_name')) { <li class="<%= $departure->{is_cancelled} ? 'cancelled-stop' : q{} %>"><%= $departure->{sched_departure} // $departure->{sched_arrival} // q{} %> % if ($departure->{sched_departure}) { % if ($departure->{departure} ne $departure->{sched_departure}) { Loading @@ -203,8 +209,9 @@ (heute <%= $departure->{arrival} %>) % } % } <strong><%= $station_name %></strong> <strong><%= stash('station_name') %></strong> </li> % } % for my $stop (@{$departure->{route_post_diff}}) { <li> <a href="<%= url_for('station', station => $stop->{name})->query({detailed => param('detailed')}) %>" class=" Loading
templates/train_details.html.ep +1 −1 Original line number Diff line number Diff line <div class="app" data-station="<%= $station_name %>"> <div class="app" data-station="<%= stash('station_name') // q{} %>"> <div class="moreinfo" data-static="1"> %= include '_train_details' </div> Loading