From c74b91b09f8888b5d4a35b7b2cb49d313db342d9 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Tue, 30 Jul 2024 15:14:24 +0200 Subject: Switch to new bahn.de carriage formation API (WiP) --- templates/_train_details.html.ep | 4 ++-- templates/_wagon.html.ep | 44 +++++++++++++++++----------------------- templates/wagenreihung.html.ep | 31 +++++++++++++--------------- 3 files changed, 35 insertions(+), 44 deletions(-) (limited to 'templates') diff --git a/templates/_train_details.html.ep b/templates/_train_details.html.ep index c0248d9..49edc3e 100644 --- a/templates/_train_details.html.ep +++ b/templates/_train_details.html.ep @@ -128,7 +128,7 @@ % $left = q{}; % $right = '▶'; % } - + %= $left % for my $entry ((defined $departure->{wr_direction_num} and $departure->{wr_direction_num} != $wr->direction) ? reverse @{$departure->{wr_preview} // []} : @{$departure->{wr_preview} // []}) { % if ($entry->[1]) { @@ -152,7 +152,7 @@ % } % } % if ($departure->{wr_link}) { - <%= $departure->{wr_text} || 'Wagen' %> + <%= $departure->{wr_text} || 'Wagen' %> % } % if ($departure->{train_type} and $departure->{train_no} and (not param('hafas') or param('hafas') eq 'DB')) { diff --git a/templates/_wagon.html.ep b/templates/_wagon.html.ep index 59a2ca1..46d07b7 100644 --- a/templates/_wagon.html.ep +++ b/templates/_wagon.html.ep @@ -1,19 +1,19 @@ % my $bg = ''; % my $extra_class = ''; -% if ($wagon->is_first_class) { -% $extra_class .= ' firstclass'; -% } +% #if ($wagon->has_first_class) { +% # $extra_class .= ' firstclass'; +% #} % if ($wagon->is_locomotive or $wagon->is_powercar) { % $extra_class .= ' powercar'; % } % if ($wagon->is_closed) { % $extra_class .= ' closed'; % } -% if ($wagon->train_no ne $train_no) { +% if ($group->train_no ne $train_no) { % $extra_class .= ' nondestwagon'; % }
+ top: <%= $wagon->start_percent %>%; bottom: <%= 100 - $wagon->end_percent %>%; <%= $bg %>"> % if ($wagon->is_locomotive or $wagon->is_powercar) { % } % elsif ($wagon->is_closed) { @@ -21,25 +21,19 @@ % } % else { %= $wagon->number // '?' -% if ($wagon->has_accessibility) { +% if(0){ #if ($wagon->has_wheelchair_space) { accessible % } -% if ($wagon->has_bistro) { +% if(0){ #if ($wagon->has_bistro) { restaurant % } -% if ($wagon->has_compartments) { - -% } -% if ($wagon->has_quiet_area) { +% if(0){ #if ($wagon->has_quiet_zone) { volume_off % } -% if ($wagon->has_phone_area) { - smartphone -% } -% if ($wagon->has_family_area) { +% if(0){ #if ($wagon->has_family_zone) { people % } -% if ($wagon->has_bahn_comfort) { +% if(0){ #if ($wagon->has_bahn_comfort) { star % } % } @@ -55,9 +49,9 @@
+ top: <%= $wagon->start_percent %>%; bottom: <%= 100 - $wagon->end_percent %>%;"> % if ($exit_dir ne 'right') { -% if (my $img = wagon_image($wagon->train_subtype // $wr->train_type // '?', $wagon->type, $wagon->uic_id)) { +% if (my $img = wagon_image($wr->train_type // '?', $wagon->type, $wagon->uic_id)) { <%= $wagon->type %> % } % else { @@ -67,7 +61,7 @@ % } % } % my $uic_id = $wagon->uic_id; -% if (length($uic_id) != 12) { +% if (length($uic_id) != 12 and length($uic_id) != 14) { <%= $uic_id %> % } % elsif (substr($uic_id, 0, 2) >= 90) { @@ -77,7 +71,7 @@ <%= substr($uic_id, 0, 2) %><%= substr($uic_id, 2, 2) %><%= substr($uic_id, 4, 2) %><%= substr($uic_id, 6, 2) %><%= substr($uic_id, 8, 3) %><%= substr($uic_id, 11) %> % } % if ($exit_dir eq 'right') { -% if (my $img = wagon_image($wagon->train_subtype // $wr->train_type // '?', $wagon->type, $wagon->uic_id)) { +% if (my $img = wagon_image($wr->train_type // '?', $wagon->type, $wagon->uic_id)) { <%= $wagon->type %> % } % else { @@ -89,15 +83,15 @@ % if ($multi and $first) {
-% if (scalar $wr->train_nos > 1) { - <%= $wr->train_type %> <%= ($wr->groups)[$wagon->group_index]->train_no %> +% if (scalar $wr->train_numbers > 1) { + <%= $group->train_type %> <%= $group->train_no %> % } % if (scalar $wr->destinations > 1) { - → <%= $wr->{data}{istformation}{allFahrzeuggruppe}[$wagon->group_index]{zielbetriebsstellename} %> + → <%= $group->destination %> % } - % if ($multi and ($wr->groups)[$wagon->group_index]->desc_short) { - <%= ($wr->groups)[$wagon->group_index]->desc_short %> + % if ($multi and $group->desc_short) { + <%= $group->desc_short %> % } % }
diff --git a/templates/wagenreihung.html.ep b/templates/wagenreihung.html.ep index 6781dca..0af66bd 100644 --- a/templates/wagenreihung.html.ep +++ b/templates/wagenreihung.html.ep @@ -9,42 +9,39 @@ % else {
- <%= $wr->station->{name} %> Gleis <%= $wr->platform %>
+ Gleis <%= $wr->platform %>
-% if (not $wr->has_bad_wagons) { -% for my $section ($wr->sections) { -
-%= $section->{name} -
-% } +% for my $sector ($wr->sectors) { +
+%= $sector->name +
% } % for my $group ($wr->groups) { % my $first = 1; -% for my $wagon ($group->wagons) { -%= include '_wagon', wr => $wr, wagon => $wagon, first => $first, multi => (scalar $wr->destinations) - 1 + (scalar $wr->train_nos) - 1, wref => $wref, exit_dir => stash('exit_dir'); +% for my $wagon ($group->carriages) { +%= include '_wagon', wr => $wr, group => $group, wagon => $wagon, first => $first, multi => (scalar $wr->destinations) - 1 + (scalar $wr->train_numbers) - 1, wref => $wref, exit_dir => stash('exit_dir'), train_no => param('number'); % $first = 0; % } % }
-
-%= join( ' / ', map { $_->{name} } $wr->origins ) - → -%= join( ' / ', map { $_->{name} } $wr->destinations ) -
% for my $group ($wr->groups) { % if ($group->description) {
%= $group->description - % if (scalar $wr->groups > 1 and $group->has_sections) { - in Abschnitt <%= join(q{}, sort $group->sections) %> + % if (scalar $wr->groups > 1 and $group->has_sectors) { + in Abschnitt <%= join(q{}, sort $group->sectors) %> % }
% } % } +
+ nach +%= join( ' / ', map { $_->{name} } $wr->destinations ) +