From 9e92134e0441444f46f11c244d80081809f41fcb Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 26 Nov 2018 18:33:50 +0100 Subject: add quick&dirty wagon order integration --- README.md | 1 + index.pl | 21 +++++++++++++++++++++ public/static/default.css | 4 ++++ templates/app.html.ep | 6 ++++++ templates/layouts/default.html.ep | 2 ++ templates/wagenreihung.html.ep | 30 ++++++++++++++++++++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 templates/wagenreihung.html.ep diff --git a/README.md b/README.md index e823d43..1e939dd 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/index.pl b/index.pl index d274caa..f270a23 100644 --- a/index.pl +++ b/index.pl @@ -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 @@ % } % } +% if ($linetype eq 'fern' and $departure->{wr_link}) { +
+ Wagenreihung +
+% } + % } % if ($departure->{route_post_diff} and @{$departure->{route_post_diff}}) {
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) db-infoscreen v<%= stash('version') // '???' %>
Backends:
+Travel::Status::DE::DBWagenreihung +v<%= $Travel::Status::DE::DBWagenreihung::VERSION %>
Travel::Status::DE::HAFAS v<%= $Travel::Status::DE::HAFAS::VERSION %>
Travel::Status::DE::IRIS 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 @@ +
+
+(experimentell, die URL wird sich noch ändern und die Anzeige wird noch schöner) +
+ +
+% for my $section ($wr->sections) { +
+%= $section->{name} +
+% } +
+
+% for my $wagon ($wr->wagons) { +% my $bg = ''; +% if ($wagon->is_first_class) { +% $bg = 'background-color: #ffff99;'; +% } +
+% if ($wagon->is_locomotive or $wagon->is_powercar) { +LOK +% } +% else { +%= $wagon->{number} // '?' +% } +
+% } +
+ +
-- cgit v1.2.3