diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-06-09 13:13:56 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-06-09 13:13:56 +0200 |
commit | ccdfc0206f849ccaeee8f5a5093c51d1274d2652 (patch) | |
tree | a30deb0179ef95a01360161020dd85dfe1d1823d /templates | |
parent | 3322ca23669871fff79a229b9167f2e3169c4352 (diff) |
Add (possibly still somewhat experimental) MOTIS support
Squashed commit of the following:
commit c7c8b2ec5d8254eefb548bfe7763a7d8c9558be4
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Mon Jun 9 13:08:57 2025 +0200
fix another merge issue
commit d2ae55c901ab59284263ad3070ba425e03cee833
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Mon Jun 9 13:08:39 2025 +0200
Stations: get_by_external_id is a slow function
commit 725174413300e71c350d2f1dcfbeacd751def977
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Mon Jun 9 13:05:48 2025 +0200
... I accidentally commited a merge conflict
commit c695494dbd6aaf252199da42ad763bdffa1d64b9
Merge: e5da62b 3322ca2
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Mon Jun 9 12:46:08 2025 +0200
Merge branch 'main' into motis
commit e5da62bcfc7953d5109ba53ae1fcc34f509f251b
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Wed Apr 30 18:15:39 2025 +0200
cpanfile: add Travel::Status::MOTIS dependency
commit 180723a9e0e2f0aede0bc6352d5eee601183ccef
Merge: 479373b c90ae4c
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Wed Apr 30 18:13:45 2025 +0200
Merge branch 'main' into motis
commit 479373b14eaadbc022199df246c9fb523a87188c
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Wed Apr 30 18:06:41 2025 +0200
database: remove duplicate users_with_backend migration
commit 94c8b5a7d1e2cb7f73b0eca7e33d916775504cd4
Author: Birte Kristina Friesel <derf@finalrewind.org>
Date: Wed Apr 30 18:06:04 2025 +0200
Do not store train colours in database. They're only supported by MOTIS.
commit d58f23c3c7b06cc0243c1945dacd8673d2d2e428
Author: networkException <git@nwex.de>
Date: Fri Apr 18 11:47:02 2025 +0200
Initial MOTIS backend support
This patch adds support for checkins using MOTIS backends
using the Travel::Status::MOTIS module.
With this travelynx supports the two services currently
exposed by the module, RNV for local transit in Mannheim,
Germany and surrounding cities and transitous for worldwide
crowdsourced tranit feeds.
This implementation supports realtime predictions,
cancellations and polylines as well as custom route colors
if available.
As MOTIS doesn't expose names of indivial trips currently,
displaying transports is mostly limited to route names.
MOTIS uses strings for stop ids, based on the used GTFS
source feeds. As travelynx's data model currently assumes
interger station ids, this patch adds a mapping table
to the database.
This patch assumes support for MOTIS in db-fakedisplay.
Note that while träwelling has migrated to tranitous fully
sync remains unsupported for now.
See https://github.com/Traewelling/traewelling/issues/3345
Diffstat (limited to 'templates')
-rw-r--r-- | templates/_backend_line.html.ep | 2 | ||||
-rw-r--r-- | templates/_departures_motis.html.ep | 54 | ||||
-rw-r--r-- | templates/_format_train.html.ep | 4 | ||||
-rw-r--r-- | templates/_history_trains.html.ep | 5 | ||||
-rw-r--r-- | templates/changelog.html.ep | 14 | ||||
-rw-r--r-- | templates/departures.html.ep | 18 | ||||
-rw-r--r-- | templates/landingpage.html.ep | 2 |
7 files changed, 92 insertions, 7 deletions
diff --git a/templates/_backend_line.html.ep b/templates/_backend_line.html.ep index 5f2bcf1..00496d3 100644 --- a/templates/_backend_line.html.ep +++ b/templates/_backend_line.html.ep @@ -6,7 +6,7 @@ % } % if ($backend->{has_area}) { <br/> - <a href="https://dbf.finalrewind.org/coverage/HAFAS/<%= $backend->{name} %>"><%= join(q{, }, @{$backend->{regions} // []}) || '[Karte]' %></a> + <a href="https://dbf.finalrewind.org/coverage/<%= $backend->{type} %>/<%= $backend->{name} %>"><%= join(q{, }, @{$backend->{regions} // []}) || '[Karte]' %></a> % } % elsif ($backend->{regions}) { <br/> diff --git a/templates/_departures_motis.html.ep b/templates/_departures_motis.html.ep new file mode 100644 index 0000000..2ebc5de --- /dev/null +++ b/templates/_departures_motis.html.ep @@ -0,0 +1,54 @@ +<ul class="collection departures"> +% my $orientation_bar_shown = param('train'); +% my $now_epoch = now->epoch; +% for my $result (@{$results}) { + % my $row_class = ''; + % my $link_class = 'action-checkin'; + % if ($result->is_cancelled) { + % $row_class = "cancelled"; + % $link_class = 'action-cancelled-from'; + % } + % if (not $orientation_bar_shown and $result->stopover->departure->epoch < $now_epoch) { + % $orientation_bar_shown = 1; + <li class="collection-item" id="now"> + <strong class="dep-time"> + %= now->strftime('%H:%M') + </strong> + <strong>— Anfragezeitpunkt —</strong> + </li> + % } + <li class="collection-item <%= $link_class %> <%= $row_class %>" + data-motis="<%= $motis %>" + data-station="<%= $result->stopover->stop->id %>" + data-train="<%= $result->id %>" + data-ts="<%= ($result->stopover->departure)->epoch %>" + > + <a class="dep-time" href="#"> + %= $result->stopover->departure->strftime('%H:%M') + % if ($result->stopover->delay) { + (<%= sprintf('%+d', $result->stopover->delay) %>) + % } + % elsif (not $result->stopover->is_realtime and not $result->stopover->is_cancelled) { + <i class="material-icons" aria-label="Keine Echtzeitdaten vorhanden" style="font-size: 16px;">gps_off</i> + % } + </a> + <span class="dep-line <%= $result->mode %>" style="background-color: #<%= $result->route_color // q{} %>;"> + %= $result->route_name + </span> + <span class="dep-dest"> + % if ($result->is_cancelled) { + Fahrt nach <%= $result->headsign %> entfällt + % } + % else { + %= $result->headsign + % for my $checkin (@{$checkin_by_train->{$result->id} // []}) { + <span class="followee-checkin"> + <i class="material-icons tiny" aria-label="Eine Person, der du folgst, ist hier eingecheckt">people</i> + <%= $checkin->{followee_name} %> → <%= $checkin->{arr_name} // '???' %> + </span> + % } + % } + </span> + </li> +% } +</ul> diff --git a/templates/_format_train.html.ep b/templates/_format_train.html.ep index 1d6acaa..e82f3f9 100644 --- a/templates/_format_train.html.ep +++ b/templates/_format_train.html.ep @@ -2,7 +2,9 @@ 🏳️🌈 % } <span class="dep-line <%= $journey->{train_type} // q{} %>"> - <%= $journey->{train_type} %> + % if (not $journey->{is_motis}) { + <%= $journey->{train_type} %> + % } <%= $journey->{train_line} // $journey->{train_no}%> </span> % if ($journey->{train_line}) { diff --git a/templates/_history_trains.html.ep b/templates/_history_trains.html.ep index cf998ab..7ae2a1d 100644 --- a/templates/_history_trains.html.ep +++ b/templates/_history_trains.html.ep @@ -17,7 +17,10 @@ <li class="collection-item"> <a href="<%= $detail_link %>"> <span class="dep-line <%= $travel->{type} // q{} %>"> - <%= $travel->{type} %> <%= $travel->{line} // $travel->{no}%> + % if (not $travel->{is_motis}) { + <%= $travel->{type} %> + % } + <%= $travel->{line} // $travel->{no}%> </span> </a> diff --git a/templates/changelog.html.ep b/templates/changelog.html.ep index 7a1417f..73eae7b 100644 --- a/templates/changelog.html.ep +++ b/templates/changelog.html.ep @@ -2,6 +2,20 @@ <div class="row"> <div class="col s12 m1 l1"> + 2.13 + </div> + <div class="col s12 m11 l11"> + <p> + <i class="material-icons left" aria-label="Neues Feature">add</i> + Experimentelle Unterstützung für Checkins via MOTIS-Backends + (derzeit transitous und RNV). Vielen Dank an <a href="https://github.com/networkException">networkException</a> + für die Implementierung der API und Einbindung in travelynx. + </p> + </div> +</div> + +<div class="row"> + <div class="col s12 m1 l1"> 2.12 </div> <div class="col s12 m11 l11"> diff --git a/templates/departures.html.ep b/templates/departures.html.ep index bbae40f..1745a47 100644 --- a/templates/departures.html.ep +++ b/templates/departures.html.ep @@ -15,6 +15,9 @@ % elsif (param('hafas')) { <a href="/account/select_backend?redirect_to=<%= $self_link %>" class="btn-small btn-flat"><i class="material-icons left" aria-hidden="true">directions</i><%= param('hafas') %></a> % } + % elsif (param('motis')) { + <a href="/account/select_backend?redirect_to=<%= $self_link %>" class="btn-small btn-flat"><i class="material-icons left" aria-hidden="true">directions</i><%= param('motis') %></a> + % } % else { % if ($user->{backend_id}) { <a href="/account/select_backend?redirect_to=<%= $self_link %>" class="btn-small btn-flat"><i class="material-icons left" aria-hidden="true">directions</i><%= $user->{backend_name} %></a> @@ -33,7 +36,13 @@ <div class="card"> <div class="card-content"> <span class="card-title">Aktuell eingecheckt</span> - <p>In <%= $user_status->{train_type} %> <%= $user_status->{train_no} %> + <p>In + % if ( not $user_status->{is_motis} ) { + <%= $user_status->{train_type} %> + % } + + <%= $user_status->{train_line} // $user_status->{train_no} %> + % if ( $user_status->{arr_name}) { von <%= $user_status->{dep_name} %> nach <%= $user_status->{arr_name} %> % } @@ -96,7 +105,7 @@ <div class="row"> <div class="col s4 center-align"> - % if ($dbris or $hafas) { + % if ($dbris or $hafas or $motis) { <a class="btn-small" href="<%= url_for('sstation', station => param('station'))->query({dbris => $dbris, hafas => $hafas, timestamp => $datetime->clone->subtract(hours => 1)->epoch}) %>"><i class="material-icons left" aria-hidden="true">chevron_left</i><span class="hide-on-small-only">früher</span></a> % } </div> @@ -106,7 +115,7 @@ % } </div> <div class="col s4 center-align"> - % if ($dbris or $hafas) { + % if ($dbris or $hafas or $motis) { <a class="btn-small" href="<%= url_for('sstation', station => param('station'))->query({dbris => $dbris, hafas => $hafas, timestamp => $datetime->clone->add(hours => 1)->epoch}) %>"><span class="hide-on-small-only">später</span><i class="material-icons right" aria-hidden="true">chevron_right</i></a> % } </div> @@ -154,6 +163,9 @@ % elsif ($hafas) { %= include '_departures_hafas', results => $results, hafas => $hafas; % } + % elsif ($motis) { + %= include '_departures_motis', results => $results, motis => $motis; + % } % else { %= include '_departures_iris', results => $results; % } diff --git a/templates/landingpage.html.ep b/templates/landingpage.html.ep index 67ba806..56aa8ff 100644 --- a/templates/landingpage.html.ep +++ b/templates/landingpage.html.ep @@ -57,7 +57,7 @@ <div class="card-content"> <span class="card-title">Hallo, <%= $user->{name} %>!</span> <p>Du bist gerade nicht eingecheckt.</p> - <div class="geolocation" data-recent="<%= join('|', map { $_->{eva} . ';' . $_->{name} . ';' . $_->{dbris} . ';' . $_->{hafas} } @{stash('recent_targets') // []} ) %>" data-backend="<%= $user->{backend_id} %>"> + <div class="geolocation" data-recent="<%= join('|', map { $_->{external_id_or_eva} . ';' . $_->{name} . ';' . $_->{dbris} . ';' . $_->{motis} . ';' . $_->{hafas} } @{stash('recent_targets') // []} ) %>" data-backend="<%= $user->{backend_id} %>"> <a class="btn waves-effect waves-light btn-flat request">Stationen in der Umgebung abfragen</a> </div> %= hidden_field backend_dbris => $user->{backend_dbris} |