diff options
Diffstat (limited to 'lib/DBInfoscreen.pm')
-rw-r--r-- | lib/DBInfoscreen.pm | 60 |
1 files changed, 7 insertions, 53 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm index 9dcc2d0..c784e96 100644 --- a/lib/DBInfoscreen.pm +++ b/lib/DBInfoscreen.pm @@ -38,12 +38,6 @@ sub startup { chomp $self->config->{version}; $self->defaults( version => $self->config->{version} // 'UNKNOWN' ); - $self->plugin( - I18N => { - default => 'de', - }, - ); - # Generally, the reverse proxy handles compression. # Also, Mojolicious compression breaks legacy callback-based JSON endpoints # for some clients. @@ -62,18 +56,6 @@ sub startup { if ( $cookie->name eq 'theme' ) { $self->session( theme => $cookie->value ); } - elsif ( $cookie->name eq 'lang' ) { - my $l = $cookie->value; - if ( $l eq 'de' or $l eq 'en' ) { - $self->languages($l); - } - } - } - - if ( my $l = $self->param('lang') ) { - if ( $l eq 'de' or $l eq 'en' ) { - $self->languages($l); - } } } ); @@ -103,36 +85,6 @@ sub startup { ); $self->attr( - ice_type_map => sub { - if ( -r 'share/zugbildungsplan.json' ) { - my $ice_type_map = JSON->new->utf8->decode( - scalar read_file('share/zugbildungsplan.json') ); - my $ret = {}; - while ( my ( $k, $v ) = each %{ $ice_type_map->{train} } ) { - if ( $v->{type} ) { - $ret->{$k} = [ - $v->{type}, $v->{shortType}, - exists $v->{wagons} ? 1 : 0 - ]; - } - } - return $ret; - } - return {}; - } - ); - - $self->attr( - train_details_db => sub { - if ( -r 'share/zugbildungsplan.json' ) { - return JSON->new->utf8->decode( - scalar read_file('share/zugbildungsplan.json') )->{train}; - } - return {}; - } - ); - - $self->attr( dbdb_wagon => sub { return JSON->new->utf8->decode( scalar read_file('share/dbdb_wagen.json') ); @@ -323,20 +275,22 @@ sub startup { $r->get('/dyn/:av/autocomplete.js')->to('stationboard#autocomplete'); $r->get('/_wr/:train/:departure')->to('wagenreihung#wagenreihung'); - $r->get('/wr/:train')->to('wagenreihung#zugbildung_db'); $r->get('/w/*wagon')->to('wagenreihung#wagen'); $r->get('/_ajax_mapinfo/:tripid/:lineno')->to('map#ajax_route'); $r->get('/map/:tripid/:lineno')->to('map#route'); - $r->get( '/z/:train/*station' => 'train_at_station' ) - ->to('stationboard#station_train_details'); - $r->get( '/z/:train' => 'train' )->to('stationboard#train_details'); + $r->get( '/z/:train/*station' => [ format => [ 'html', 'json' ] ] ) + ->to( 'stationboard#station_train_details', format => undef ) + ->name('train_at_station'); + $r->get( '/z/:train' => [ format => [ 'html', 'json' ] ] ) + ->to( 'stationboard#train_details', format => undef )->name('train'); $self->defaults( layout => 'app' ); $r->get('/')->to('stationboard#handle_request'); $r->get('/multi/*station')->to('stationboard#handle_request'); - $r->get('/*station')->to('stationboard#handle_request'); + $r->get( '/*station' => [ format => [ 'html', 'json' ] ] ) + ->to( 'stationboard#handle_request', format => undef ); $self->types->type( json => 'application/json; charset=utf-8' ); |