diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-11-26 18:33:50 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-11-26 18:33:50 +0100 |
commit | 9e92134e0441444f46f11c244d80081809f41fcb (patch) | |
tree | cedb58a93f7825b355367c3c74fbfe28851e8302 | |
parent | b41f8a18ce3878e06345d0faf70b0e1e57407e8e (diff) |
add quick&dirty wagon order integration
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | index.pl | 21 | ||||
-rw-r--r-- | public/static/default.css | 4 | ||||
-rw-r--r-- | templates/app.html.ep | 6 | ||||
-rw-r--r-- | templates/layouts/default.html.ep | 2 | ||||
-rw-r--r-- | templates/wagenreihung.html.ep | 30 |
6 files changed, 64 insertions, 0 deletions
@@ -10,6 +10,7 @@ Dependencies * Cache::File (part of the Cache module) * Mojolicious * Mojolicious::Plugin::BrowserDetect + * Travel::Status::DE::DBWagenreihung >= 0.00 * Travel::Status::DE::DeutscheBahn >= 2.03 * Travel::Status::DE::IRIS >= 1.21 @@ -6,6 +6,7 @@ use Cache::File; use File::Slurp qw(read_file write_file); use List::Util qw(max); use List::MoreUtils qw(); +use Travel::Status::DE::DBWagenreihung; use Travel::Status::DE::HAFAS; use Travel::Status::DE::HAFAS::StopFinder; use Travel::Status::DE::IRIS; @@ -824,6 +825,9 @@ sub handle_request { map { $_->type . q{ } . $_->train_no } $result->replacement_for ], + wr_link => $result->sched_departure + ? $result->sched_departure->strftime('%Y%m%d%H%M') + : undef, } ); } @@ -1010,6 +1014,23 @@ get '/_impressum' => sub { $self->render( 'imprint', hide_opts => 1 ); }; +get '/_wr/:train/:departure' => sub { + my $self = shift; + my $train = $self->stash('train'); + my $departure = $self->stash('departure'); + + my $wr = Travel::Status::DE::DBWagenreihung->new( + departure => $departure, + train_number => $train, + ); + + $self->render( + 'wagenreihung', + wr => $wr, + hide_opts => 1, + ); +}; + app->defaults( layout => 'default' ); app->sessions->default_expiration( 3600 * 24 * 28 ); diff --git a/public/static/default.css b/public/static/default.css index 0038a60..0be22fa 100644 --- a/public/static/default.css +++ b/public/static/default.css @@ -204,6 +204,10 @@ div.app li .moreinfo .minfo { color: #ff0000; } +div.app li .moreinfo .verbose { + margin-bottom: 0.6em; +} + div.app li .moreinfo .timeinfo { margin-bottom: 0.6em; } diff --git a/templates/app.html.ep b/templates/app.html.ep index 88e6586..80e17d2 100644 --- a/templates/app.html.ep +++ b/templates/app.html.ep @@ -143,6 +143,12 @@ % } % } </div> <!-- timeinfo --> +% if ($linetype eq 'fern' and $departure->{wr_link}) { + <div class="verbose"> + <a href="/_wr/<%= $departure->{train_no} %>/<%= $departure->{wr_link} %>">Wagenreihung</a> + </div> +% } + % } % if ($departure->{route_post_diff} and @{$departure->{route_post_diff}}) { <div class="mroute"> diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index d7d6e70..163955b 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -232,6 +232,8 @@ nur Züge via Bochum oder Hamm)</li> <a href="https://finalrewind.org/projects/db-fakedisplay/">db-infoscreen</a> v<%= stash('version') // '???' %><br/> Backends:<br/> +<!--<a href="https://finalrewind.org/projects/Travel-Status-DE-DBWagenreihung/">-->Travel::Status::DE::DBWagenreihung<!--</a>--> +v<%= $Travel::Status::DE::DBWagenreihung::VERSION %><br/> <a href="https://finalrewind.org/projects/Travel-Status-DE-DeutscheBahn/">Travel::Status::DE::HAFAS</a> v<%= $Travel::Status::DE::HAFAS::VERSION %><br/> <a href="https://finalrewind.org/projects/Travel-Status-DE-IRIS/">Travel::Status::DE::IRIS</a> diff --git a/templates/wagenreihung.html.ep b/templates/wagenreihung.html.ep new file mode 100644 index 0000000..9055f00 --- /dev/null +++ b/templates/wagenreihung.html.ep @@ -0,0 +1,30 @@ +<div class="container"> +<div style="height: 2em;"> +(experimentell, die URL wird sich noch ändern und die Anzeige wird noch schöner) +</div> + +<div style="position: relative; width: 100%; height: 2em;"> +% for my $section ($wr->sections) { +<div style="position: absolute; left: <%= $section->{start_percent} %>%; right: <%= 100 - $section->{end_percent} %>%; top: 0em; bottom: 0em; text-align: center;"> +%= $section->{name} +</div> +% } +</div> +<div style="position: relative; width: 100%; height: 2em;"> +% for my $wagon ($wr->wagons) { +% my $bg = ''; +% if ($wagon->is_first_class) { +% $bg = 'background-color: #ffff99;'; +% } +<div style="position: absolute; left: <%= $wagon->{position}{start_percent} %>%; right: <%= 100 - $wagon->{position}{end_percent} %>%; top: 0em; bottom: 0em; border: 1px solid black; text-align: center; <%= $bg %>"> +% if ($wagon->is_locomotive or $wagon->is_powercar) { +LOK +% } +% else { +%= $wagon->{number} // '?' +% } +</div> +% } +</div> + +</div> |