diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-05-25 12:01:16 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-05-25 12:01:16 +0200 |
commit | 7844270322c4062817b0398ad2eb07a586fd5232 (patch) | |
tree | bb312d87eaf85f8cf2bf3e5708234ec245f7abda | |
parent | 3ebd7d5179136ed7ca652742d489fd9be2fd228f (diff) |
Get wagonorder description and designation from DBRIS::Formation2.11.34
-rwxr-xr-x | lib/Travelynx.pm | 38 | ||||
-rw-r--r-- | templates/_public_status_card.html.ep | 10 | ||||
-rw-r--r-- | templates/_wagons.html.ep | 7 |
3 files changed, 32 insertions, 23 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 6ae646d..aa48128 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -1100,7 +1100,7 @@ sub startup { if (@unknown_stations) { $self->app->log->warn( sprintf( -'Route of %s %s (%s -> %s) contains unknown stations: %s', +'IRIS: Route of %s %s (%s -> %s) contains unknown stations: %s', $train->type, $train->train_no, $train->origin, @@ -1467,35 +1467,41 @@ sub startup { my $data = {}; my $user_data = {}; - if ( $opt{is_departure} + my $wr; + eval { + $wr + = Travel::Status::DE::DBRIS::Formation->new( + json => $wagonorder ); + }; + + if ( $opt{is_departure} + and $wr and not exists $wagonorder->{error} ) { $data->{wagonorder_dep} = $wagonorder; $user_data->{wagongroups} = []; - for my $group ( @{ $wagonorder->{groups} // [] } ) { + for my $group ( $wr->groups ) { my @wagons; - for my $wagon ( @{ $group->{vehicles} // [] } ) - { + for my $wagon ( $group->carriages ) { push( @wagons, { - id => $wagon->{vehicleID}, - number => $wagon - ->{wagonIdentificationNumber}, - type => - $wagon->{type}{constructionType}, + id => $wagon->uic_id, + number => $wagon->number, + type => $wagon->type, } ); } push( @{ $user_data->{wagongroups} }, { - name => $group->{name}, - to => $group->{transport}{destination} - {name}, - type => $group->{transport}{category}, - no => $group->{transport}{number}, - wagons => [@wagons], + name => $group->name, + description => $group->description, + designation => $group->designation, + to => $group->destination, + type => $group->train_type, + no => $group->train_no, + wagons => [@wagons], } ); if ( $group->{name} diff --git a/templates/_public_status_card.html.ep b/templates/_public_status_card.html.ep index 5cda2f0..70b9ee7 100644 --- a/templates/_public_status_card.html.ep +++ b/templates/_public_status_card.html.ep @@ -173,7 +173,7 @@ </div> % } % if (@{$journey->{messages} // []} > 0 and $journey->{messages}[0]) { - <div style="margin-bottom: 2ex;"> + <div style="margin-top: 2ex;"> <ul> % for my $message (reverse @{$journey->{messages} // []}) { % if ($journey->{sched_departure}->epoch - $message->[0]->epoch < 1800) { @@ -187,7 +187,7 @@ </div> % } % if (@{$journey->{extra_data}{him_msg} // []}) { - <div style="margin-bottom: 2ex;"> + <div style="margin-top: 2ex;"> <ul> % for my $message (@{$journey->{extra_data}{him_msg} // []}) { % if (not stash('from_timeline') or $message->{prio} and $message->{prio} eq 'HOCH') { @@ -198,13 +198,13 @@ </div> % } % if ( @{$journey->{wagongroups} // []} and not stash('from_timeline')) { - <div class="wagons" style="margin-bottom: 2ex;"> + <div class="wagons" style="margin-top: 2ex;"> Wagen:<br/> %= include '_wagons', wagongroups => $journey->{wagongroups}; </div> % } % if (not stash('from_timeline')) { - <div> + <div style="margin-top: 2ex;"> Zuglauf:<br/> % my $before = 1; % my $within = 0; @@ -213,7 +213,7 @@ % if (($station->[1] and $station->[1] == $journey->{dep_eva}) or $station->[0] eq $journey->{dep_name}) { % $within = 1; $at_startstop = 1; % } - % elsif (($station->[1] and $station->[1] == $journey->{arr_eva}) or $station->[0] eq $journey->{arr_name}) { + % elsif ($journey->{arr_eva} and ($station->[1] and $station->[1] == $journey->{arr_eva}) or $station->[0] eq $journey->{arr_name}) { % $within = 0; $at_startstop = 1; % } % else { diff --git a/templates/_wagons.html.ep b/templates/_wagons.html.ep index b4af3bc..d0d9682 100644 --- a/templates/_wagons.html.ep +++ b/templates/_wagons.html.ep @@ -1,7 +1,10 @@ % for my $wagongroup (@{$wagongroups // []}) { - <%= $wagongroup->{name} %> + %= $wagongroup->{description} // $wagongroup->{name} % my ($wagon_number) = ($wagongroup->{name} =~ m{ ^ ICE 0* (\d+) $ }x); - % if ($wagon_number and my $group_name = app->ice_name->{$wagon_number}) { + % if ($wagongroup->{designation}) { + „<%= $wagongroup->{designation} %>“ + % } + % elsif ($wagon_number and my $group_name = app->ice_name->{$wagon_number}) { „<%= $group_name %>“ % } als <b><%= $wagongroup->{type} // $journey->{type} %> <%= $wagongroup->{no} %></b> |