Loading cpanfile +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ requires 'MIME::Entity'; requires 'Mojolicious'; requires 'Mojolicious::Plugin::Authentication'; requires 'Mojo::Pg'; requires 'Text::CSV'; requires 'Travel::Status::DE::DBWagenreihung'; requires 'Travel::Status::DE::IRIS'; requires 'UUID::Tiny'; Loading lib/Travelynx.pm +2 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ sub startup { $self->defaults( layout => 'default' ); $self->types->type( csv => 'text/csv; charset=utf-8' ); $self->types->type( json => 'application/json; charset=utf-8' ); $self->plugin('Config'); Loading Loading @@ -4043,6 +4044,7 @@ sub startup { $authed_r->get('/account/mail')->to('account#change_mail'); $authed_r->get('/export.json')->to('account#json_export'); $authed_r->get('/history.json')->to('traveling#json_history'); $authed_r->get('/history.csv')->to('traveling#csv_history'); $authed_r->get('/history')->to('traveling#history'); $authed_r->get('/history/commute')->to('traveling#commute'); $authed_r->get('/history/map')->to('traveling#map_history'); Loading lib/Travelynx/Controller/Traveling.pm +49 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use JSON; use List::Util qw(uniq min max); use List::UtilsBy qw(max_by uniq_by); use List::MoreUtils qw(first_index); use Text::CSV; use Travel::Status::DE::IRIS::Stations; sub homepage { Loading Loading @@ -644,6 +645,54 @@ sub json_history { $self->render( json => [ $self->get_user_travels ] ); } sub csv_history { my ($self) = @_; my $csv = Text::CSV->new( { eol => "\r\n" } ); my $buf = q{}; $csv->combine( qw(Zugtyp Linie Nummer Start Ziel), 'Start (DS100)', 'Ziel (DS100)', 'Abfahrt (soll)', 'Abfahrt (ist)', 'Ankunft (soll)', 'Ankunft (ist)', 'Kommentar', 'ID' ); $buf .= $csv->string; for my $journey ( $self->get_user_travels( with_datetime => 1 ) ) { if ( $csv->combine( $journey->{type}, $journey->{line}, $journey->{no}, $journey->{from_name}, $journey->{to_name}, $journey->{from_ds100}, $journey->{to_ds100}, $journey->{sched_departure}->strftime('%Y-%m-%d %H:%M'), $journey->{rt_departure}->strftime('%Y-%m-%d %H:%M'), $journey->{sched_arrival}->strftime('%Y-%m-%d %H:%M'), $journey->{rt_arrival}->strftime('%Y-%m-%d %H:%M'), $journey->{user_data}{comment} // q{}, $journey->{id} ) ) { $buf .= $csv->string; } } $self->render( text => $buf, format => 'csv' ); } sub yearly_history { my ($self) = @_; my $year = $self->stash('year'); Loading templates/history.html.ep +11 −4 Original line number Diff line number Diff line Loading @@ -41,22 +41,29 @@ <h2>Ausfälle und Verspätungen</h2> <div class="row"> <div class="col s12 m12 l5 center-align"> <a href="/cancelled" class="waves-effect waves-light btn"><i class="material-icons left">cancel</i> Zugausfälle</a> <a href="/cancelled" class="waves-effect waves-light btn"><i class="material-icons left" aria-hidden="true">cancel</i> Zugausfälle</a> </div> <div class="col s12 m12 l2"> </div> <div class="col s12 m12 l5 center-align"> <a href="/fgr" class="waves-effect waves-light btn"><i class="material-icons left">feedback</i> Fahrgastrechte</a> <a href="/fgr" class="waves-effect waves-light btn"><i class="material-icons left" aria-hidden="true">feedback</i> Fahrgastrechte</a> </div> </div> <h2>Rohdaten</h2> <div class="row"> <div class="col s12 m12 l5 center-align"> <a href="/history.json" class="waves-effect waves-light btn"><i class="material-icons left">cloud</i> JSON-Export</a> <a href="/history.json" class="waves-effect waves-light btn"><i class="material-icons left" aria-hidden="true">cloud</i> JSON-Export</a> </div> <div class="col s12 m12 l2"> </div> <div class="col s12 m12 l5 center-align"> <a href="/journey/add" class="waves-effect waves-light btn"><i class="material-icons left">add</i> Neue Fahrt</a> <a href="/history.csv" class="waves-effect waves-light btn"><i class="material-icons left" aria-hidden="true">list</i> CSV-Export</a> </div> </div> <div class="row"> <div class="col s12 m12 l5 center-align"> </div> <div class="col s12 m12 l2"> </div> <div class="col s12 m12 l5 center-align"> <a href="/journey/add" class="waves-effect waves-light btn"><i class="material-icons left" aria-hidden="true">add</i> Neue Fahrt</a> </div> </div> Loading Loading
cpanfile +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ requires 'MIME::Entity'; requires 'Mojolicious'; requires 'Mojolicious::Plugin::Authentication'; requires 'Mojo::Pg'; requires 'Text::CSV'; requires 'Travel::Status::DE::DBWagenreihung'; requires 'Travel::Status::DE::IRIS'; requires 'UUID::Tiny'; Loading
lib/Travelynx.pm +2 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ sub startup { $self->defaults( layout => 'default' ); $self->types->type( csv => 'text/csv; charset=utf-8' ); $self->types->type( json => 'application/json; charset=utf-8' ); $self->plugin('Config'); Loading Loading @@ -4043,6 +4044,7 @@ sub startup { $authed_r->get('/account/mail')->to('account#change_mail'); $authed_r->get('/export.json')->to('account#json_export'); $authed_r->get('/history.json')->to('traveling#json_history'); $authed_r->get('/history.csv')->to('traveling#csv_history'); $authed_r->get('/history')->to('traveling#history'); $authed_r->get('/history/commute')->to('traveling#commute'); $authed_r->get('/history/map')->to('traveling#map_history'); Loading
lib/Travelynx/Controller/Traveling.pm +49 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use JSON; use List::Util qw(uniq min max); use List::UtilsBy qw(max_by uniq_by); use List::MoreUtils qw(first_index); use Text::CSV; use Travel::Status::DE::IRIS::Stations; sub homepage { Loading Loading @@ -644,6 +645,54 @@ sub json_history { $self->render( json => [ $self->get_user_travels ] ); } sub csv_history { my ($self) = @_; my $csv = Text::CSV->new( { eol => "\r\n" } ); my $buf = q{}; $csv->combine( qw(Zugtyp Linie Nummer Start Ziel), 'Start (DS100)', 'Ziel (DS100)', 'Abfahrt (soll)', 'Abfahrt (ist)', 'Ankunft (soll)', 'Ankunft (ist)', 'Kommentar', 'ID' ); $buf .= $csv->string; for my $journey ( $self->get_user_travels( with_datetime => 1 ) ) { if ( $csv->combine( $journey->{type}, $journey->{line}, $journey->{no}, $journey->{from_name}, $journey->{to_name}, $journey->{from_ds100}, $journey->{to_ds100}, $journey->{sched_departure}->strftime('%Y-%m-%d %H:%M'), $journey->{rt_departure}->strftime('%Y-%m-%d %H:%M'), $journey->{sched_arrival}->strftime('%Y-%m-%d %H:%M'), $journey->{rt_arrival}->strftime('%Y-%m-%d %H:%M'), $journey->{user_data}{comment} // q{}, $journey->{id} ) ) { $buf .= $csv->string; } } $self->render( text => $buf, format => 'csv' ); } sub yearly_history { my ($self) = @_; my $year = $self->stash('year'); Loading
templates/history.html.ep +11 −4 Original line number Diff line number Diff line Loading @@ -41,22 +41,29 @@ <h2>Ausfälle und Verspätungen</h2> <div class="row"> <div class="col s12 m12 l5 center-align"> <a href="/cancelled" class="waves-effect waves-light btn"><i class="material-icons left">cancel</i> Zugausfälle</a> <a href="/cancelled" class="waves-effect waves-light btn"><i class="material-icons left" aria-hidden="true">cancel</i> Zugausfälle</a> </div> <div class="col s12 m12 l2"> </div> <div class="col s12 m12 l5 center-align"> <a href="/fgr" class="waves-effect waves-light btn"><i class="material-icons left">feedback</i> Fahrgastrechte</a> <a href="/fgr" class="waves-effect waves-light btn"><i class="material-icons left" aria-hidden="true">feedback</i> Fahrgastrechte</a> </div> </div> <h2>Rohdaten</h2> <div class="row"> <div class="col s12 m12 l5 center-align"> <a href="/history.json" class="waves-effect waves-light btn"><i class="material-icons left">cloud</i> JSON-Export</a> <a href="/history.json" class="waves-effect waves-light btn"><i class="material-icons left" aria-hidden="true">cloud</i> JSON-Export</a> </div> <div class="col s12 m12 l2"> </div> <div class="col s12 m12 l5 center-align"> <a href="/journey/add" class="waves-effect waves-light btn"><i class="material-icons left">add</i> Neue Fahrt</a> <a href="/history.csv" class="waves-effect waves-light btn"><i class="material-icons left" aria-hidden="true">list</i> CSV-Export</a> </div> </div> <div class="row"> <div class="col s12 m12 l5 center-align"> </div> <div class="col s12 m12 l2"> </div> <div class="col s12 m12 l5 center-align"> <a href="/journey/add" class="waves-effect waves-light btn"><i class="material-icons left" aria-hidden="true">add</i> Neue Fahrt</a> </div> </div> Loading