Loading lib/DBInfoscreen.pm +0 −31 Original line number Diff line number Diff line Loading @@ -102,36 +102,6 @@ sub startup { } ); $self->attr( ice_type_map => sub { if ( -r 'share/zugbildungsplan.json' ) { my $ice_type_map = JSON->new->utf8->decode( scalar read_file('share/zugbildungsplan.json') ); my $ret = {}; while ( my ( $k, $v ) = each %{ $ice_type_map->{train} } ) { if ( $v->{type} ) { $ret->{$k} = [ $v->{type}, $v->{shortType}, exists $v->{wagons} ? 1 : 0 ]; } } return $ret; } return {}; } ); $self->attr( train_details_db => sub { if ( -r 'share/zugbildungsplan.json' ) { return JSON->new->utf8->decode( scalar read_file('share/zugbildungsplan.json') )->{train}; } return {}; } ); $self->attr( dbdb_wagon => sub { return JSON->new->utf8->decode( Loading Loading @@ -323,7 +293,6 @@ sub startup { $r->get('/dyn/:av/autocomplete.js')->to('stationboard#autocomplete'); $r->get('/_wr/:train/:departure')->to('wagenreihung#wagenreihung'); $r->get('/wr/:train')->to('wagenreihung#zugbildung_db'); $r->get('/w/*wagon')->to('wagenreihung#wagen'); $r->get('/_ajax_mapinfo/:tripid/:lineno')->to('map#ajax_route'); Loading lib/DBInfoscreen/Controller/Stationboard.pm +2 −52 Original line number Diff line number Diff line Loading @@ -915,30 +915,6 @@ sub render_train { } )->wait; $departure->{composition} = $self->app->train_details_db->{ $departure->{train_no} }; if ( not $departure->{arrival} and $departure->{composition}{prepTime} and $departure->{composition}{prepAt} eq $station_name ) { $departure->{prep_time} = $departure->{composition}{prepTime}; $departure->{arrival_hidden} = 1; } if ( $self->param('detailed') ) { my @cycle_from; my @cycle_to; for my $pred ( @{ $departure->{composition}{predecessors} // [] } ) { push( @cycle_from, $pred->[1] ); } for my $succ ( @{ $departure->{composition}{successors} // [] } ) { push( @cycle_to, $succ->[1] ); } $departure->{cycle_from} = [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_from ]; $departure->{cycle_to} = [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_to ]; } # Defer rendering until all requests have completed Mojo::Promise->all(@requests)->then( sub { Loading @@ -954,10 +930,6 @@ sub render_train { ), departure => $departure, linetype => $linetype, icetype => $self->app->ice_type_map->{ $departure->{train_no} }, details => $self->param('detailed') ? $departure->{composition} // {} : {}, dt_now => DateTime->now( time_zone => 'Europe/Berlin' ), station_name => $station_name, nav_link => Loading Loading @@ -1290,25 +1262,6 @@ sub train_details { $res->{details} = [@him_details]; } if ( $self->param('detailed') ) { $res->{composition} = $self->app->train_details_db->{ $res->{train_no} }; my @cycle_from; my @cycle_to; for my $pred ( @{ $res->{composition}{predecessors} // [] } ) { push( @cycle_from, $pred->[1] ); } for my $succ ( @{ $res->{composition}{successors} // [] } ) { push( @cycle_to, $succ->[1] ); } $res->{cycle_from} = [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_from ]; $res->{cycle_to} = [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_to ]; } $self->render( $self->param('ajax') ? '_train_details' : 'train_details', description => sprintf( Loading @@ -1321,8 +1274,6 @@ sub 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' ), ); } Loading Loading @@ -1809,7 +1760,6 @@ sub handle_result { api_text => $api_text, api_icon => $api_icon, departures => \@departures, ice_type => $self->app->ice_type_map, station => $station_name, version => $self->config->{version}, title => $via ? "$station_name → $via" : $station_name, Loading lib/DBInfoscreen/Controller/Wagenreihung.pm +7 −113 Original line number Diff line number Diff line Loading @@ -13,114 +13,9 @@ use utf8; use Travel::Status::DE::DBWagenreihung; use Travel::Status::DE::DBWagenreihung::Wagon; sub get_zugbildung_db { my ( $self, $train_no ) = @_; my $details = $self->app->train_details_db->{$train_no}; if ( not $details ) { return; } my @wagons; for my $wagon ( @{ $details->{wagons} } ) { my $wagon_type = $wagon->{type}; my $wagon_number = $wagon->{number}; my %wagon = ( fahrzeugnummer => "", fahrzeugtyp => $wagon_type, kategorie => $wagon_type =~ m{^[0-9.]+$} ? 'LOK' : '', train_no => $train_no, wagenordnungsnummer => $wagon_number, positionamhalt => { startprozent => 0, endeprozent => 0, startmeter => 0, endemeter => 0, } ); my $wagon = Travel::Status::DE::DBWagenreihung::Wagon->new(%wagon); if ( $details->{type} ) { $wagon->set_traintype( $details->{type} ); } push( @wagons, $wagon ); } my $pos = 0; for my $wagon (@wagons) { $wagon->{position}{start_percent} = $pos; $wagon->{position}{end_percent} = $pos + 5; $pos += 5; } my $train_type = $details->{rawType}; $train_type =~ s{ - .* }{}x; my $route_start = $details->{route}{start} // $details->{route}{preStart}; my $route_end = $details->{route}{end} // $details->{route}{postEnd}; my $route = "${route_start} → ${route_end}"; return { route => $route, train_type => $train_type, wagons => [@wagons] }; } sub zugbildung_db { my ($self) = @_; my $train_no = $self->param('train'); my $details = $self->get_zugbildung_db($train_no); if ( not $details ) { $self->render( 'not_found', message => "Keine Daten zu Zug ${train_no} bekannt" ); return; } $self->render( 'zugbildung_db', description => sprintf( 'Soll-Wagenreihung %s %s', $details->{train_type} // 'Zug', $train_no ), wr_error => undef, title => $details->{train_type} . ' ' . $train_no, route => $details->{route}, zb => $details, train_no => $train_no, wagons => $details->{wagons}, hide_opts => 1, ); } sub handle_wagenreihung_error { my ( $self, $train_no, $err ) = @_; my $details = $self->get_zugbildung_db($train_no); if ( $details and @{ $details->{wagons} } ) { my $wr_error = "${err}. Ersatzweise werden die Solldaten laut Fahrplan angezeigt."; $self->render( 'zugbildung_db', description => sprintf( 'Soll-Wagenreihung %s %s', $details->{train_type} // 'Zug', $train_no ), wr_error => $wr_error, title => $details->{train_type} . ' ' . $train_no, route => $details->{route}, zb => $details, train_no => $train_no, wagons => $details->{wagons}, hide_opts => 1, ); } else { $self->render( 'wagenreihung', title => "Zug $train_no", Loading @@ -131,7 +26,6 @@ sub handle_wagenreihung_error { hide_opts => 1, ); } } sub wagenreihung { my ($self) = @_; Loading templates/_train_details.html.ep +0 −76 Original line number Diff line number Diff line Loading @@ -2,9 +2,6 @@ <div> % if ($departure->{train_no} or $departure->{train_line}) { <span class="train-line <%= $linetype %>"><%= $departure->{train_type} %> % if ($linetype eq 'fern' and $icetype and $icetype->[1]) { <span class="trainsubtype" aria-hidden="true"><%= $icetype->[1] %></span> % } <%= $departure->{train_line} // $departure->{train_no} %></span> <span class="train-no"><%= $departure->{train_line} ? $departure->{train_no} : q{} %></span> Loading Loading @@ -152,12 +149,6 @@ <a class="smallbutton" href="/_wr/<%= $departure->{train_no} %>/<%= $departure->{wr_link} %>?e=<%= $departure->{direction} // '' %>"><i class="material-icons" aria-hidden="true">train</i> <%= $departure->{wr_text} || 'Wagen' %> </a> % } % elsif ($icetype and $icetype->[2] and ($linetype eq 'fern' or $departure->{train_type} =~ m{NJ})) { <a class="smallbutton" href="/wr/<%= $departure->{train_no} %>"><i class="material-icons" aria-hidden="true">train</i> Plan: <%= $icetype->[0] %></a> % } % elsif ($icetype and $icetype->[1] and $linetype eq 'fern') { <span class="disabledbutton"><i class="material-icons" aria-hidden="true">train</i> Plan: <%= $icetype->[0] %></span> % } % if ($departure->{train_type} and $departure->{train_no}) { <a class="smallbutton" href="https://bahn.expert/details/<%= $departure->{train_type} %>%20<%= $departure->{train_no} %>/<%= ($departure->{date} // DateTime->now(time_zone => 'Europe/Berlin'))->iso8601 %>?evaNumberAlongRoute=<%= $departure->{eva} %>"><img src="/static/icons/bahn-expert.svg">Details</a> % } Loading Loading @@ -350,72 +341,5 @@ % } </ul> </div> % } % if ($details->{attributes}) { % if (@{$details->{attributes}} > 1) { <div class="db-attr"> Attribute: <ul> % for my $attr (@{$details->{attributes}}) { <li><%= include '_train_attr', attr => $attr, with_station => 1 %></li> % } </ul> </div> % } % else { <div class="db-attr"> %= include '_train_attr', attr => $details->{attributes}[0], with_station => 0 </div> % } % } % if ($details and not $departure->{arrival}) { % if (my $s = $details->{route}{preStart}) { Zug wird voraussichtlich aus <%= $s %> eingesetzt.<br/><br/> % } % if (@{$departure->{cycle_from} // []}) { Bildung möglicherweise aus <ul> % for my $t (@{$departure->{cycle_from}}) { % my ($train_no, $train) = @{$t}; % my $tt = $train->{type} // $train->{rawType} // 'Zug'; % $tt =~ s{ .*|[0-9]}{}; % if ($tt ne 'Zug') { <li><a href="<%= url_for('train', train => "$tt $train_no")->query({detailed => param('detailed'), past => param('past'), rt => param('rt'), hafas => param('hafas')}) %>"><%= $tt %> <%= $train_no %></a> % } % else { <li><%= $tt %> <%= $train_no %> % } % if ($train->{route}{start} and $train->{route}{end}) { <%= $train->{route}{start} %> → <%= $train->{route}{end} %> % } </li> % } </ul> % } % } % if ($details and not $departure->{departure}) { % if (my $e = $details->{route}{postEnd}) { Zug wird voraussichtlich in <%= $e %> abgestellt.<br/><br/> % } % if (@{$departure->{cycle_to} // []}) { Weiterfahrt möglicherweise als <ul> % for my $t (@{$departure->{cycle_to}}) { % my ($train_no, $train) = @{$t}; % my $tt = $train->{type} // $train->{rawType} // 'Zug'; % $tt =~ s{ .*|[0-9]}{}; % if ($tt ne 'Zug') { <li><a href="<%= url_for('train', train => "$tt $train_no")->query({detailed => param('detailed'), past => param('past'), rt => param('rt'), hafas => param('hafas')}) %>"><%= $tt %> <%= $train_no %></a> % } % else { <li><%= $tt %> <%= $train_no %> % } % if ($train->{route}{start} and $train->{route}{end}) { <%= $train->{route}{start} %> → <%= $train->{route}{end} %> % } </li> % } </ul> % } % } </div> <!-- mfooter --> templates/app.html.ep +0 −3 Original line number Diff line number Diff line Loading @@ -67,9 +67,6 @@ %= $departure->{train_line} % } % elsif ($departure->{train_no}) { % if (param('detailed') and $departure->{linetype} eq 'fern' and exists $ice_type->{$departure->{train_no}} and $ice_type->{$departure->{train_no}}[1]) { <span class="trainsubtype" aria-hidden="true"><%= $ice_type->{$departure->{train_no}}[1] %></span> % } <span class="trainno"><%= $departure->{train_no} %></span> % } % else { Loading Loading
lib/DBInfoscreen.pm +0 −31 Original line number Diff line number Diff line Loading @@ -102,36 +102,6 @@ sub startup { } ); $self->attr( ice_type_map => sub { if ( -r 'share/zugbildungsplan.json' ) { my $ice_type_map = JSON->new->utf8->decode( scalar read_file('share/zugbildungsplan.json') ); my $ret = {}; while ( my ( $k, $v ) = each %{ $ice_type_map->{train} } ) { if ( $v->{type} ) { $ret->{$k} = [ $v->{type}, $v->{shortType}, exists $v->{wagons} ? 1 : 0 ]; } } return $ret; } return {}; } ); $self->attr( train_details_db => sub { if ( -r 'share/zugbildungsplan.json' ) { return JSON->new->utf8->decode( scalar read_file('share/zugbildungsplan.json') )->{train}; } return {}; } ); $self->attr( dbdb_wagon => sub { return JSON->new->utf8->decode( Loading Loading @@ -323,7 +293,6 @@ sub startup { $r->get('/dyn/:av/autocomplete.js')->to('stationboard#autocomplete'); $r->get('/_wr/:train/:departure')->to('wagenreihung#wagenreihung'); $r->get('/wr/:train')->to('wagenreihung#zugbildung_db'); $r->get('/w/*wagon')->to('wagenreihung#wagen'); $r->get('/_ajax_mapinfo/:tripid/:lineno')->to('map#ajax_route'); Loading
lib/DBInfoscreen/Controller/Stationboard.pm +2 −52 Original line number Diff line number Diff line Loading @@ -915,30 +915,6 @@ sub render_train { } )->wait; $departure->{composition} = $self->app->train_details_db->{ $departure->{train_no} }; if ( not $departure->{arrival} and $departure->{composition}{prepTime} and $departure->{composition}{prepAt} eq $station_name ) { $departure->{prep_time} = $departure->{composition}{prepTime}; $departure->{arrival_hidden} = 1; } if ( $self->param('detailed') ) { my @cycle_from; my @cycle_to; for my $pred ( @{ $departure->{composition}{predecessors} // [] } ) { push( @cycle_from, $pred->[1] ); } for my $succ ( @{ $departure->{composition}{successors} // [] } ) { push( @cycle_to, $succ->[1] ); } $departure->{cycle_from} = [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_from ]; $departure->{cycle_to} = [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_to ]; } # Defer rendering until all requests have completed Mojo::Promise->all(@requests)->then( sub { Loading @@ -954,10 +930,6 @@ sub render_train { ), departure => $departure, linetype => $linetype, icetype => $self->app->ice_type_map->{ $departure->{train_no} }, details => $self->param('detailed') ? $departure->{composition} // {} : {}, dt_now => DateTime->now( time_zone => 'Europe/Berlin' ), station_name => $station_name, nav_link => Loading Loading @@ -1290,25 +1262,6 @@ sub train_details { $res->{details} = [@him_details]; } if ( $self->param('detailed') ) { $res->{composition} = $self->app->train_details_db->{ $res->{train_no} }; my @cycle_from; my @cycle_to; for my $pred ( @{ $res->{composition}{predecessors} // [] } ) { push( @cycle_from, $pred->[1] ); } for my $succ ( @{ $res->{composition}{successors} // [] } ) { push( @cycle_to, $succ->[1] ); } $res->{cycle_from} = [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_from ]; $res->{cycle_to} = [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_to ]; } $self->render( $self->param('ajax') ? '_train_details' : 'train_details', description => sprintf( Loading @@ -1321,8 +1274,6 @@ sub 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' ), ); } Loading Loading @@ -1809,7 +1760,6 @@ sub handle_result { api_text => $api_text, api_icon => $api_icon, departures => \@departures, ice_type => $self->app->ice_type_map, station => $station_name, version => $self->config->{version}, title => $via ? "$station_name → $via" : $station_name, Loading
lib/DBInfoscreen/Controller/Wagenreihung.pm +7 −113 Original line number Diff line number Diff line Loading @@ -13,114 +13,9 @@ use utf8; use Travel::Status::DE::DBWagenreihung; use Travel::Status::DE::DBWagenreihung::Wagon; sub get_zugbildung_db { my ( $self, $train_no ) = @_; my $details = $self->app->train_details_db->{$train_no}; if ( not $details ) { return; } my @wagons; for my $wagon ( @{ $details->{wagons} } ) { my $wagon_type = $wagon->{type}; my $wagon_number = $wagon->{number}; my %wagon = ( fahrzeugnummer => "", fahrzeugtyp => $wagon_type, kategorie => $wagon_type =~ m{^[0-9.]+$} ? 'LOK' : '', train_no => $train_no, wagenordnungsnummer => $wagon_number, positionamhalt => { startprozent => 0, endeprozent => 0, startmeter => 0, endemeter => 0, } ); my $wagon = Travel::Status::DE::DBWagenreihung::Wagon->new(%wagon); if ( $details->{type} ) { $wagon->set_traintype( $details->{type} ); } push( @wagons, $wagon ); } my $pos = 0; for my $wagon (@wagons) { $wagon->{position}{start_percent} = $pos; $wagon->{position}{end_percent} = $pos + 5; $pos += 5; } my $train_type = $details->{rawType}; $train_type =~ s{ - .* }{}x; my $route_start = $details->{route}{start} // $details->{route}{preStart}; my $route_end = $details->{route}{end} // $details->{route}{postEnd}; my $route = "${route_start} → ${route_end}"; return { route => $route, train_type => $train_type, wagons => [@wagons] }; } sub zugbildung_db { my ($self) = @_; my $train_no = $self->param('train'); my $details = $self->get_zugbildung_db($train_no); if ( not $details ) { $self->render( 'not_found', message => "Keine Daten zu Zug ${train_no} bekannt" ); return; } $self->render( 'zugbildung_db', description => sprintf( 'Soll-Wagenreihung %s %s', $details->{train_type} // 'Zug', $train_no ), wr_error => undef, title => $details->{train_type} . ' ' . $train_no, route => $details->{route}, zb => $details, train_no => $train_no, wagons => $details->{wagons}, hide_opts => 1, ); } sub handle_wagenreihung_error { my ( $self, $train_no, $err ) = @_; my $details = $self->get_zugbildung_db($train_no); if ( $details and @{ $details->{wagons} } ) { my $wr_error = "${err}. Ersatzweise werden die Solldaten laut Fahrplan angezeigt."; $self->render( 'zugbildung_db', description => sprintf( 'Soll-Wagenreihung %s %s', $details->{train_type} // 'Zug', $train_no ), wr_error => $wr_error, title => $details->{train_type} . ' ' . $train_no, route => $details->{route}, zb => $details, train_no => $train_no, wagons => $details->{wagons}, hide_opts => 1, ); } else { $self->render( 'wagenreihung', title => "Zug $train_no", Loading @@ -131,7 +26,6 @@ sub handle_wagenreihung_error { hide_opts => 1, ); } } sub wagenreihung { my ($self) = @_; Loading
templates/_train_details.html.ep +0 −76 Original line number Diff line number Diff line Loading @@ -2,9 +2,6 @@ <div> % if ($departure->{train_no} or $departure->{train_line}) { <span class="train-line <%= $linetype %>"><%= $departure->{train_type} %> % if ($linetype eq 'fern' and $icetype and $icetype->[1]) { <span class="trainsubtype" aria-hidden="true"><%= $icetype->[1] %></span> % } <%= $departure->{train_line} // $departure->{train_no} %></span> <span class="train-no"><%= $departure->{train_line} ? $departure->{train_no} : q{} %></span> Loading Loading @@ -152,12 +149,6 @@ <a class="smallbutton" href="/_wr/<%= $departure->{train_no} %>/<%= $departure->{wr_link} %>?e=<%= $departure->{direction} // '' %>"><i class="material-icons" aria-hidden="true">train</i> <%= $departure->{wr_text} || 'Wagen' %> </a> % } % elsif ($icetype and $icetype->[2] and ($linetype eq 'fern' or $departure->{train_type} =~ m{NJ})) { <a class="smallbutton" href="/wr/<%= $departure->{train_no} %>"><i class="material-icons" aria-hidden="true">train</i> Plan: <%= $icetype->[0] %></a> % } % elsif ($icetype and $icetype->[1] and $linetype eq 'fern') { <span class="disabledbutton"><i class="material-icons" aria-hidden="true">train</i> Plan: <%= $icetype->[0] %></span> % } % if ($departure->{train_type} and $departure->{train_no}) { <a class="smallbutton" href="https://bahn.expert/details/<%= $departure->{train_type} %>%20<%= $departure->{train_no} %>/<%= ($departure->{date} // DateTime->now(time_zone => 'Europe/Berlin'))->iso8601 %>?evaNumberAlongRoute=<%= $departure->{eva} %>"><img src="/static/icons/bahn-expert.svg">Details</a> % } Loading Loading @@ -350,72 +341,5 @@ % } </ul> </div> % } % if ($details->{attributes}) { % if (@{$details->{attributes}} > 1) { <div class="db-attr"> Attribute: <ul> % for my $attr (@{$details->{attributes}}) { <li><%= include '_train_attr', attr => $attr, with_station => 1 %></li> % } </ul> </div> % } % else { <div class="db-attr"> %= include '_train_attr', attr => $details->{attributes}[0], with_station => 0 </div> % } % } % if ($details and not $departure->{arrival}) { % if (my $s = $details->{route}{preStart}) { Zug wird voraussichtlich aus <%= $s %> eingesetzt.<br/><br/> % } % if (@{$departure->{cycle_from} // []}) { Bildung möglicherweise aus <ul> % for my $t (@{$departure->{cycle_from}}) { % my ($train_no, $train) = @{$t}; % my $tt = $train->{type} // $train->{rawType} // 'Zug'; % $tt =~ s{ .*|[0-9]}{}; % if ($tt ne 'Zug') { <li><a href="<%= url_for('train', train => "$tt $train_no")->query({detailed => param('detailed'), past => param('past'), rt => param('rt'), hafas => param('hafas')}) %>"><%= $tt %> <%= $train_no %></a> % } % else { <li><%= $tt %> <%= $train_no %> % } % if ($train->{route}{start} and $train->{route}{end}) { <%= $train->{route}{start} %> → <%= $train->{route}{end} %> % } </li> % } </ul> % } % } % if ($details and not $departure->{departure}) { % if (my $e = $details->{route}{postEnd}) { Zug wird voraussichtlich in <%= $e %> abgestellt.<br/><br/> % } % if (@{$departure->{cycle_to} // []}) { Weiterfahrt möglicherweise als <ul> % for my $t (@{$departure->{cycle_to}}) { % my ($train_no, $train) = @{$t}; % my $tt = $train->{type} // $train->{rawType} // 'Zug'; % $tt =~ s{ .*|[0-9]}{}; % if ($tt ne 'Zug') { <li><a href="<%= url_for('train', train => "$tt $train_no")->query({detailed => param('detailed'), past => param('past'), rt => param('rt'), hafas => param('hafas')}) %>"><%= $tt %> <%= $train_no %></a> % } % else { <li><%= $tt %> <%= $train_no %> % } % if ($train->{route}{start} and $train->{route}{end}) { <%= $train->{route}{start} %> → <%= $train->{route}{end} %> % } </li> % } </ul> % } % } </div> <!-- mfooter -->
templates/app.html.ep +0 −3 Original line number Diff line number Diff line Loading @@ -67,9 +67,6 @@ %= $departure->{train_line} % } % elsif ($departure->{train_no}) { % if (param('detailed') and $departure->{linetype} eq 'fern' and exists $ice_type->{$departure->{train_no}} and $ice_type->{$departure->{train_no}}[1]) { <span class="trainsubtype" aria-hidden="true"><%= $ice_type->{$departure->{train_no}}[1] %></span> % } <span class="trainno"><%= $departure->{train_no} %></span> % } % else { Loading