From 11d77d4bb95e0f79d2afbcf0ab9bb7b66cc12003 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 17 Mar 2019 18:34:33 +0100 Subject: add journey detail view --- templates/history.html.ep | 7 +-- templates/journey.html.ep | 101 ++++++++++++++++++++++++++++++++++++++++++ templates/landingpage.html.ep | 7 +-- 3 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 templates/journey.html.ep (limited to 'templates') diff --git a/templates/history.html.ep b/templates/history.html.ep index cf81765..d79b515 100644 --- a/templates/history.html.ep +++ b/templates/history.html.ep @@ -19,12 +19,13 @@ - % for my $travel (get_user_travels(0)) { + % for my $travel (get_user_travels()) { % if ($travel->{completed}) { + % my $detail_link = '/journey/' . current_user()->{id} . '-' . $travel->{checkin}->epoch . '-' . $travel->{checkout}->epoch; <%= $travel->{sched_departure}->strftime('%d.%m.%Y') %> - <%= $travel->{type} %> <%= $travel->{line} // '' %> <%= $travel->{no} %> - <%= $travel->{from_name} %> → <%= $travel->{to_name} %> + <%= $travel->{type} %> <%= $travel->{line} // '' %> <%= $travel->{no} %> + <%= $travel->{from_name} %> → <%= $travel->{to_name} %> <%= $travel->{rt_departure}->strftime('%H:%M') %> % if ($travel->{sched_departure} != $travel->{rt_departure}) { (+<%= ($travel->{rt_departure}->epoch - $travel->{sched_departure}->epoch) / 60 %>) diff --git a/templates/journey.html.ep b/templates/journey.html.ep new file mode 100644 index 0000000..520b2ef --- /dev/null +++ b/templates/journey.html.ep @@ -0,0 +1,101 @@ +% if ($error) { +
+
+
+
+ Fehler +

Zugfahrt nicht gefunden.

+

+
+
+
+% } +% else { +
+
+

+ Fahrt von + <%= $journey->{from_name} %> + nach + <%= $journey->{to_name} %> + am + <%= $journey->{sched_departure}->strftime('%d.%m.%Y') %> +

+ + + + + + + + + + + + + + + + + + + + + +
Zug + <%= $journey->{type} %> <%= $journey->{no} %> + % if ($journey->{line}) { + (Linie <%= $journey->{type} %> <%= $journey->{line} %>) + % } +
Abfahrt + % if ($journey->{rt_departure} != $journey->{sched_departure}) { + %= $journey->{rt_departure}->strftime('%H:%M'); + (+<%= ($journey->{rt_departure}->epoch - $journey->{sched_departure}->epoch) / 60 %>, + Plan: <%= $journey->{sched_departure}->strftime('%H:%M'); %>) + % } + % else { + %= $journey->{sched_departure}->strftime('%H:%M'); + % } +
Ankunft + % if ($journey->{rt_arrival}->epoch == 0 and $journey->{sched_arrival}->epoch == 0) { + timer_off + % } + % elsif ($journey->{rt_arrival} != $journey->{sched_arrival}) { + %= $journey->{rt_arrival}->strftime('%H:%M'); + (+<%= ($journey->{rt_arrival}->epoch - $journey->{sched_arrival}->epoch) / 60 %>, + Plan: <%= $journey->{sched_arrival}->strftime('%H:%M'); %>) + % } + % else { + %= $journey->{sched_arrival}->strftime('%H:%M'); + % } +
Meldungen + % for my $message (@{$journey->{messages} // []}) { + % my ($ts, $msg) = @{$message}; + <%= $ts->strftime('%d.%m.%Y %H:%M') %> : <%= $msg %> + % } +
+
Route + % my $within = 0; + % my $at_startstop = 0; + % for my $station (@{$journey->{route}}) { + % if ($station eq $journey->{from_name}) { + % $within = 1; $at_startstop = 1; + % } + % elsif ($station eq $journey->{to_name}) { + % $within = 0; $at_startstop = 1; + % } + % else { + % $at_startstop = 0; + % } + % if ($at_startstop or $within) { + <%= $station %> + % } + % else { + <%= $station %> + % } +
+ % } +
+
+
+% } diff --git a/templates/landingpage.html.ep b/templates/landingpage.html.ep index c672dd2..dcc0083 100644 --- a/templates/landingpage.html.ep +++ b/templates/landingpage.html.ep @@ -75,12 +75,13 @@ - % for my $travel (get_user_travels(1)) { + % for my $travel (get_user_travels(limit => 1)) { % if ($travel->{completed}) { + % my $detail_link = '/journey/' . current_user()->{id} . '-' . $travel->{checkin}->epoch . '-' . $travel->{checkout}->epoch; <%= $travel->{sched_departure}->strftime('%d.%m.%Y') %> - <%= $travel->{type} %> <%= $travel->{line} // $travel->{no} %> - <%= $travel->{from_name} %> → <%= $travel->{to_name} %> + <%= $travel->{type} %> <%= $travel->{line} // $travel->{no} %> + <%= $travel->{from_name} %> → <%= $travel->{to_name} %> % if ($travel->{rt_arrival}->epoch and $travel->{rt_departure}->epoch) { <%= ($travel->{rt_arrival}->epoch - $travel->{rt_departure}->epoch) / 60 %> min -- cgit v1.2.3