diff --git a/index.pl b/index.pl index fc629ee..7881253 100755 --- a/index.pl +++ b/index.pl @@ -1184,7 +1184,16 @@ get '/account' => sub { get '/history' => sub { my ($self) = @_; - $self->render('history'); + $self->respond_to( + json => { json => [ $self->get_user_travels(0) ] }, + any => { template => 'history' } + ); +}; + +get '/history.json' => sub { + my ($self) = @_; + + $self->render( json => [ $self->get_user_travels(0) ] ); }; get '/export.json' => sub { diff --git a/templates/history.html.ep b/templates/history.html.ep index 25e826f..cf81765 100644 --- a/templates/history.html.ep +++ b/templates/history.html.ep @@ -1,40 +1,49 @@
Datum | -Zug | -Strecke | -Abfahrt | -Ankunft | -
---|---|---|---|---|
<%= $travel->{sched_departure}->strftime('%d.%m.%Y') %> | -<%= $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 %>) - % } - | -- % if ($travel->{rt_arrival}->epoch == 0 and $travel->{sched_arrival}->epoch == 0) { - timer_off - % } else { - %= $travel->{rt_arrival}->strftime('%H:%M'); - % if ($travel->{sched_arrival} != $travel->{rt_arrival}) { - (+<%= ($travel->{rt_arrival}->epoch - $travel->{sched_arrival}->epoch) / 60 %>) - % } - % } - | -
Datum | +Zug | +Strecke | +Abfahrt | +Ankunft | +
---|---|---|---|---|
<%= $travel->{sched_departure}->strftime('%d.%m.%Y') %> | +<%= $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 %>) + % } + | ++ % if ($travel->{rt_arrival}->epoch == 0 and $travel->{sched_arrival}->epoch == 0) { + timer_off + % } else { + %= $travel->{rt_arrival}->strftime('%H:%M'); + % if ($travel->{sched_arrival} != $travel->{rt_arrival}) { + (+<%= ($travel->{rt_arrival}->epoch - $travel->{sched_arrival}->epoch) / 60 %>) + % } + % } + | +