Loading index.pl +54 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ my %action_type = ( undo => 3, ); my @action_types = (qw(checkin checkout undo)); app->plugin( authentication => { autoload_user => 1, Loading Loading @@ -754,6 +756,58 @@ post '/action' => sub { } }; get '/a/account' => sub { my ($self) = @_; $self->render('account'); }; get '/a/export.json' => sub { my ($self) = @_; my $uid = $self->get_user_id; my $query = $self->app->get_all_actions_query; $query->execute($uid); my @entries; while ( my @row = $query->fetchrow_array ) { my ( $action, $raw_ts, $ds100, $name, $train_type, $train_line, $train_no, $train_id, $raw_sched_ts, $raw_real_ts, $raw_route, $raw_messages ) = @row; $name = decode( 'UTF-8', $name ); $raw_route = decode( 'UTF-8', $raw_route ); $raw_messages = decode( 'UTF-8', $raw_messages ); push( @entries, { action => $action_types[ $action - 1 ], action_ts => $raw_ts, station_ds100 => $ds100, station_name => $name, train_type => $train_type, train_line => $train_line, train_no => $train_no, train_id => $train_id, scheduled_ts => $raw_sched_ts, realtime_ts => $raw_real_ts, messages => $raw_messages ? [ map { [ split(qr{:}) ] } split( qr{[|]}, $raw_messages ) ] : undef, route => $raw_route ? [ split( qr{[|]}, $raw_route ) ] : undef, } ); } $self->render( json => [@entries], ); }; get '/a/history' => sub { my ($self) = @_; Loading templates/account.html.ep 0 → 100644 +27 −0 Original line number Diff line number Diff line <h1>Account</h1> <div class="row"> <table class="striped"> <tr> <th scope="row">Name</th> <td><%= get_user_name() %></td> </tr> <tr> <th scope="row">Mail</th> <td>fnord@example.org</td> </tr> <tr> <th scope="row">Registriert am</th> <td>01.01.1970 00:00</td> </tr> </table> </div> <h1>Export</h1> <div class="row"> <div class="col s12"> <ul> <li><a href="/a/export.json">Rohdaten</a> (Kein API-Ersatz, das Format kann sich jederzeit ändern)</li> </ul> </div> </div> templates/layouts/default.html.ep +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ <a href="/" class="brand-logo left">travelynx</a> <ul id="nav-mobile" class="right"> <li class="<%= navbar_class('/a/history') %>"><a href='/a/history' title="History"><i class="material-icons">history</i></a></li> <li class="<%= navbar_class('/a/account') %>"><a href="/a/account" title="Account"><i class="material-icons left">account_circle</i><%= get_user_name() %></a></li> <li class="<%= navbar_class('/x/about') %>"><a href='/x/about' title="About"><i class="material-icons">info_outline</i></a></li> </ul> </div> Loading Loading
index.pl +54 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ my %action_type = ( undo => 3, ); my @action_types = (qw(checkin checkout undo)); app->plugin( authentication => { autoload_user => 1, Loading Loading @@ -754,6 +756,58 @@ post '/action' => sub { } }; get '/a/account' => sub { my ($self) = @_; $self->render('account'); }; get '/a/export.json' => sub { my ($self) = @_; my $uid = $self->get_user_id; my $query = $self->app->get_all_actions_query; $query->execute($uid); my @entries; while ( my @row = $query->fetchrow_array ) { my ( $action, $raw_ts, $ds100, $name, $train_type, $train_line, $train_no, $train_id, $raw_sched_ts, $raw_real_ts, $raw_route, $raw_messages ) = @row; $name = decode( 'UTF-8', $name ); $raw_route = decode( 'UTF-8', $raw_route ); $raw_messages = decode( 'UTF-8', $raw_messages ); push( @entries, { action => $action_types[ $action - 1 ], action_ts => $raw_ts, station_ds100 => $ds100, station_name => $name, train_type => $train_type, train_line => $train_line, train_no => $train_no, train_id => $train_id, scheduled_ts => $raw_sched_ts, realtime_ts => $raw_real_ts, messages => $raw_messages ? [ map { [ split(qr{:}) ] } split( qr{[|]}, $raw_messages ) ] : undef, route => $raw_route ? [ split( qr{[|]}, $raw_route ) ] : undef, } ); } $self->render( json => [@entries], ); }; get '/a/history' => sub { my ($self) = @_; Loading
templates/account.html.ep 0 → 100644 +27 −0 Original line number Diff line number Diff line <h1>Account</h1> <div class="row"> <table class="striped"> <tr> <th scope="row">Name</th> <td><%= get_user_name() %></td> </tr> <tr> <th scope="row">Mail</th> <td>fnord@example.org</td> </tr> <tr> <th scope="row">Registriert am</th> <td>01.01.1970 00:00</td> </tr> </table> </div> <h1>Export</h1> <div class="row"> <div class="col s12"> <ul> <li><a href="/a/export.json">Rohdaten</a> (Kein API-Ersatz, das Format kann sich jederzeit ändern)</li> </ul> </div> </div>
templates/layouts/default.html.ep +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ <a href="/" class="brand-logo left">travelynx</a> <ul id="nav-mobile" class="right"> <li class="<%= navbar_class('/a/history') %>"><a href='/a/history' title="History"><i class="material-icons">history</i></a></li> <li class="<%= navbar_class('/a/account') %>"><a href="/a/account" title="Account"><i class="material-icons left">account_circle</i><%= get_user_name() %></a></li> <li class="<%= navbar_class('/x/about') %>"><a href='/x/about' title="About"><i class="material-icons">info_outline</i></a></li> </ul> </div> Loading