From c3c7a0c78b30cc7ef2b836cca4eb0a4e110955da Mon Sep 17 00:00:00 2001
From: Derf Null
Date: Mon, 27 Mar 2023 21:03:25 +0200
Subject: stationboard: add HAFAS support
---
templates/_departures_hafas.html.ep | 44 ++++++++++++++++++++++++++++
templates/_departures_iris.html.ep | 52 +++++++++++++++++++++++++++++++++
templates/departures.html.ep | 58 ++++---------------------------------
templates/exception.html.ep | 2 +-
4 files changed, 103 insertions(+), 53 deletions(-)
create mode 100644 templates/_departures_hafas.html.ep
create mode 100644 templates/_departures_iris.html.ep
(limited to 'templates')
diff --git a/templates/_departures_hafas.html.ep b/templates/_departures_hafas.html.ep
new file mode 100644
index 0000000..5b1a057
--- /dev/null
+++ b/templates/_departures_hafas.html.ep
@@ -0,0 +1,44 @@
+
+
+% my $orientation_bar_shown = param('train');
+% my $now_epoch = now()->epoch;
+% for my $result (@{$results}) {
+ % my $td_class = '';
+ % my $link_class = 'action-checkin';
+ % if ($result->is_cancelled) {
+ % $td_class = "cancelled";
+ % $link_class = 'action-cancelled-from';
+ % }
+ % if (not $orientation_bar_shown and $result->datetime->epoch < $now_epoch) {
+ % $orientation_bar_shown = 1;
+
+
+ |
+
+ — Anfragezeitpunkt —
+ |
+
+ |
+
+ % }
+
+
+
+ <%= $result->line %>
+
+ |
+
+
+ <%= $result->destination %>
+
+ |
+
+ %= $result->datetime->strftime('%H:%M')
+ % if ($result->delay) {
+ (<%= sprintf('%+d', $result->delay) %>)
+ % }
+ |
+
+% }
+
+
diff --git a/templates/_departures_iris.html.ep b/templates/_departures_iris.html.ep
new file mode 100644
index 0000000..b24c3f1
--- /dev/null
+++ b/templates/_departures_iris.html.ep
@@ -0,0 +1,52 @@
+
+
+% my $orientation_bar_shown = param('train');
+% my $now_epoch = now()->epoch;
+% for my $result (@{$results}) {
+ % my $td_class = '';
+ % my $link_class = 'action-checkin';
+ % if ($result->departure_is_cancelled) {
+ % $td_class = "cancelled";
+ % $link_class = 'action-cancelled-from';
+ % }
+ % if (not $orientation_bar_shown and $result->departure->epoch < $now_epoch) {
+ % $orientation_bar_shown = 1;
+
+
+ |
+
+ — Anfragezeitpunkt —
+ |
+
+ |
+
+ % }
+
+
+
+ <%= $result->line %>
+
+ |
+
+
+ <%= $result->destination %>
+
+ |
+
+ % if ($result->departure_hidden) {
+ (<%= $result->departure->strftime('%H:%M') %>)
+ % }
+ % else {
+ %= $result->departure->strftime('%H:%M')
+ % }
+ % if ($result->departure_delay) {
+ (<%= sprintf('%+d', $result->departure_delay) %>)
+ % }
+ % elsif (not $result->has_realtime and $result->start->epoch < $now_epoch) {
+ gps_off
+ % }
+ |
+
+% }
+
+
diff --git a/templates/departures.html.ep b/templates/departures.html.ep
index 25e752a..857be74 100644
--- a/templates/departures.html.ep
+++ b/templates/departures.html.ep
@@ -63,58 +63,12 @@
und maximal 120 Minuten nach Abfahrt möglich.
% }
-
-
- % my $orientation_bar_shown = param('train');
- % my $now_epoch = now()->epoch;
- % for my $result (@{$results}) {
- % my $td_class = '';
- % my $link_class = 'action-checkin';
- % if ($result->departure_is_cancelled) {
- % $td_class = "cancelled";
- % $link_class = 'action-cancelled-from';
- % }
- % if (not $orientation_bar_shown and $result->departure->epoch < $now_epoch) {
- % $orientation_bar_shown = 1;
-
-
- |
-
- — Anfragezeitpunkt —
- |
-
- |
-
- % }
-
-
-
- <%= $result->line %>
-
- |
-
-
- <%= $result->destination %>
-
- |
-
- % if ($result->departure_hidden) {
- (<%= $result->departure->strftime('%H:%M') %>)
- % }
- % else {
- %= $result->departure->strftime('%H:%M')
- % }
- % if ($result->departure_delay) {
- (<%= sprintf('%+d', $result->departure_delay) %>)
- % }
- % elsif (not $result->has_realtime and $result->start->epoch < $now_epoch) {
- gps_off
- % }
- |
-
- % }
-
-
+ % if ($hafas) {
+ %= include '_departures_hafas', results => $results;
+ % }
+ % else {
+ %= include '_departures_iris', results => $results;
+ % }
diff --git a/templates/exception.html.ep b/templates/exception.html.ep
index 290efc5..ec01ad2 100644
--- a/templates/exception.html.ep
+++ b/templates/exception.html.ep
@@ -21,7 +21,7 @@
%= DateTime->now(time_zone => 'Europe/Berlin')->strftime("%d/%b/%Y:%H:%M:%S %z")
Message:
- %= (split(qr{\n}, $exception->message))[0]
+ %= ref($exception) ? (split(qr{\n}, $exception->message))[0] : $exception
--
cgit v1.2.3