Loading index.pl +39 −10 Original line number Diff line number Diff line Loading @@ -1070,14 +1070,37 @@ get '/api/v0/:action/:token' => sub { } if ( $api_action eq 'status' ) { my $status = $self->get_user_status($uid); my @station_descriptions; my $station_eva = undef; my $station_lon = undef; my $station_lat = undef; if ( $status->{station_ds100} ) { @station_descriptions = Travel::Status::DE::IRIS::Stations::get_station( $status->{station_ds100} ); } if ( @station_descriptions == 1 ) { ( undef, undef, $station_eva, $station_lon, $station_lat ) = @{ $station_descriptions[0] }; } $self->render( json => { deprecated => \0, checked_in => $status->{checked_in} ? \1 : \0, station_ds100 => $status->{station_ds100}, station_name => $status->{station_name}, train_type => $status->{train_type}, train_line => $status->{train_line}, train_no => $status->{train_no}, station => { ds100 => $status->{station_ds100}, name => $status->{station_name}, uic => $station_eva, longitude => $station_lon, latitude => $station_lat, }, train => { type => $status->{train_type}, line => $status->{train_line}, no => $status->{train_no}, }, action_ts => $status->{timestamp}->epoch, sched_ts => $status->{sched_ts}->epoch, real_ts => $status->{real_ts}->epoch, Loading Loading @@ -1483,7 +1506,13 @@ post '/delete' => sub { my $now = DateTime->now( time_zone => 'Europe/Berlin' )->epoch; if ( $self->param('action') eq 'delete' ) { if (not $self->authenticate($self->current_user->{name}, $self->param('password'))) { if ( not $self->authenticate( $self->current_user->{name}, $self->param('password') ) ) { $self->render( 'account', invalid => 'password' ); return; } Loading templates/account.html.ep +16 −8 Original line number Diff line number Diff line Loading @@ -148,9 +148,6 @@ <h3>Status</h3> <div class="row"> <div class="col s12"> <p> Das Format der API v0 kann sich noch ändern, ab v1 ist es stabil. </p> <p style="font-family: Monospace;"> % if ($token->{status}) { curl <%= $api_root %>/status/<%= $acc->{id} %>-<%= $token->{status} // 'TOKEN' %> Loading @@ -159,14 +156,25 @@ curl <%= $api_root %>/status/TOKEN % } </p> <p> Beispiel / Layout: </p> <p style="font-family: Monospace;"> {<br/> "deprecated" : true / false, (falls true: Diese API-Version wird irgendwann abgeschaltet, bitte auf eine neue umsteigen)<br/> "checked_in" : true / false,<br/> "station_ds100" : "EE", (DS100-Kürzel der letzten Station)<br/> "station_name" : "Essen Hbf", (Name der letzten Station)<br/> "train_type" : "ICE", (aktueller / letzter Zugtyp)<br/> "train_line" : "", (Linie, ggf. null)<br/> "train_no" : "1234", (Zugnummer)<br/> "station" : {<br/> "name" : "Essen Hbf", (Name der letzten Station)<br/> "ds100" : "EE", (DS100-Kürzel)<br/> "uic" : 8000098, (Internationale Bahnhofsnummer)<br/> "longitude" : 7.014793,<br/> "latitude" : 51.451355,<br/> },<br/> "train" : {<br/> "type" : "ICE", (aktueller / letzter Zugtyp)<br/> "line" : null, (Linie als String, nicht immer numerisch, ggf. null)<br/> "no" : "1234", (Zugnummer als String)<br/> },<br/> "action_ts" : 1234567, (UNIX-Timestamp des letzten Checkin/Checkout)<br/> "sched_ts" : 1234567, (UNIX-Timestamp der zugehörigen Ankunft/Abfahrt gemäß Fahrplan. Ggf. 0)<br/> "real_ts" : 1234567, (UNIX-Timestamp der zugehörigen Ankunft/Abfahrt laut Echtzeitdaten. Ggf. 0)<br/> Loading Loading
index.pl +39 −10 Original line number Diff line number Diff line Loading @@ -1070,14 +1070,37 @@ get '/api/v0/:action/:token' => sub { } if ( $api_action eq 'status' ) { my $status = $self->get_user_status($uid); my @station_descriptions; my $station_eva = undef; my $station_lon = undef; my $station_lat = undef; if ( $status->{station_ds100} ) { @station_descriptions = Travel::Status::DE::IRIS::Stations::get_station( $status->{station_ds100} ); } if ( @station_descriptions == 1 ) { ( undef, undef, $station_eva, $station_lon, $station_lat ) = @{ $station_descriptions[0] }; } $self->render( json => { deprecated => \0, checked_in => $status->{checked_in} ? \1 : \0, station_ds100 => $status->{station_ds100}, station_name => $status->{station_name}, train_type => $status->{train_type}, train_line => $status->{train_line}, train_no => $status->{train_no}, station => { ds100 => $status->{station_ds100}, name => $status->{station_name}, uic => $station_eva, longitude => $station_lon, latitude => $station_lat, }, train => { type => $status->{train_type}, line => $status->{train_line}, no => $status->{train_no}, }, action_ts => $status->{timestamp}->epoch, sched_ts => $status->{sched_ts}->epoch, real_ts => $status->{real_ts}->epoch, Loading Loading @@ -1483,7 +1506,13 @@ post '/delete' => sub { my $now = DateTime->now( time_zone => 'Europe/Berlin' )->epoch; if ( $self->param('action') eq 'delete' ) { if (not $self->authenticate($self->current_user->{name}, $self->param('password'))) { if ( not $self->authenticate( $self->current_user->{name}, $self->param('password') ) ) { $self->render( 'account', invalid => 'password' ); return; } Loading
templates/account.html.ep +16 −8 Original line number Diff line number Diff line Loading @@ -148,9 +148,6 @@ <h3>Status</h3> <div class="row"> <div class="col s12"> <p> Das Format der API v0 kann sich noch ändern, ab v1 ist es stabil. </p> <p style="font-family: Monospace;"> % if ($token->{status}) { curl <%= $api_root %>/status/<%= $acc->{id} %>-<%= $token->{status} // 'TOKEN' %> Loading @@ -159,14 +156,25 @@ curl <%= $api_root %>/status/TOKEN % } </p> <p> Beispiel / Layout: </p> <p style="font-family: Monospace;"> {<br/> "deprecated" : true / false, (falls true: Diese API-Version wird irgendwann abgeschaltet, bitte auf eine neue umsteigen)<br/> "checked_in" : true / false,<br/> "station_ds100" : "EE", (DS100-Kürzel der letzten Station)<br/> "station_name" : "Essen Hbf", (Name der letzten Station)<br/> "train_type" : "ICE", (aktueller / letzter Zugtyp)<br/> "train_line" : "", (Linie, ggf. null)<br/> "train_no" : "1234", (Zugnummer)<br/> "station" : {<br/> "name" : "Essen Hbf", (Name der letzten Station)<br/> "ds100" : "EE", (DS100-Kürzel)<br/> "uic" : 8000098, (Internationale Bahnhofsnummer)<br/> "longitude" : 7.014793,<br/> "latitude" : 51.451355,<br/> },<br/> "train" : {<br/> "type" : "ICE", (aktueller / letzter Zugtyp)<br/> "line" : null, (Linie als String, nicht immer numerisch, ggf. null)<br/> "no" : "1234", (Zugnummer als String)<br/> },<br/> "action_ts" : 1234567, (UNIX-Timestamp des letzten Checkin/Checkout)<br/> "sched_ts" : 1234567, (UNIX-Timestamp der zugehörigen Ankunft/Abfahrt gemäß Fahrplan. Ggf. 0)<br/> "real_ts" : 1234567, (UNIX-Timestamp der zugehörigen Ankunft/Abfahrt laut Echtzeitdaten. Ggf. 0)<br/> Loading