Loading bin/db-fakedisplay +24 −14 Original line number Diff line number Diff line Loading @@ -14,16 +14,16 @@ our $VERSION = '0.00'; sub show_help { my ($exit_status) = @_; say 'Usage: db-fakedisplay <station> <platform>'; say 'Usage: db-fakedisplay <station> <platforms ...>'; exit $exit_status; } if (@ARGV != 2) { if (@ARGV < 2) { show_help(1); } my ($station, $platform) = @ARGV; my ($station, @platforms) = @ARGV; my $template_file = dist_file('db-fakedisplay', 'template.html'); my $template = HTML::Template->new( filename => $template_file); Loading @@ -31,20 +31,30 @@ my $status = Travel::Status::DE::DeutscheBahn->new( station => $station ); my @params; for my $platform (@platforms) { my $info = first { $_->platform eq $platform } $status->results; if (not defined $info) { say STDERR 'Got no departures for that platform'; exit 1; push(@params, { platform => $platform }); next; } $template->param( push(@params, { time => $info->time, train => $info->train, via => [ map { { stop => $_ } } $info->route_interesting(3) ], destination => $info->destination, platform => $info->platform, info => $info->info, }); } $template->param( platform => \@params, ); say $template->output; Loading share/template.html +31 −6 Original line number Diff line number Diff line Loading @@ -11,9 +11,10 @@ color: white; font-family: Sans-Serif; font-weight: bold; position: absolute; left: 1em; top: 1em; position: relative; margin-left: 1em; margin-top: 1em; float: left; width: 28em; height: 4.5em; border: 0.7em solid #000066; Loading @@ -24,6 +25,12 @@ position: absolute; } div.no-data { top: 0.5em; left: 1em; font-size: 2em; } div.time { top: 0em; left: 0em; Loading @@ -42,6 +49,10 @@ height: 1em; } div.via span { margin-right: 0.4em; } div.destination { top: 1.2em; left: 2.9em; Loading @@ -66,7 +77,15 @@ </style> </head> <body> <TMPL_LOOP platform> <div class="display"> <div class="platform"> <TMPL_VAR platform> </div> <TMPL_IF train> <div class="time"> <TMPL_VAR time> </div> Loading @@ -81,14 +100,20 @@ <div class="destination"> <TMPL_VAR destination> </div> <div class="platform"> <TMPL_VAR platform> </div> <TMPL_IF info> <div class="info"> <TMPL_VAR info> </div> </TMPL_IF> <TMPL_ELSE> <div class="no-data"> Bitte Ansage beachten </div> </TMPL_IF> </div> <!-- display --> </TMPL_LOOP> </body> </html> Loading
bin/db-fakedisplay +24 −14 Original line number Diff line number Diff line Loading @@ -14,16 +14,16 @@ our $VERSION = '0.00'; sub show_help { my ($exit_status) = @_; say 'Usage: db-fakedisplay <station> <platform>'; say 'Usage: db-fakedisplay <station> <platforms ...>'; exit $exit_status; } if (@ARGV != 2) { if (@ARGV < 2) { show_help(1); } my ($station, $platform) = @ARGV; my ($station, @platforms) = @ARGV; my $template_file = dist_file('db-fakedisplay', 'template.html'); my $template = HTML::Template->new( filename => $template_file); Loading @@ -31,20 +31,30 @@ my $status = Travel::Status::DE::DeutscheBahn->new( station => $station ); my @params; for my $platform (@platforms) { my $info = first { $_->platform eq $platform } $status->results; if (not defined $info) { say STDERR 'Got no departures for that platform'; exit 1; push(@params, { platform => $platform }); next; } $template->param( push(@params, { time => $info->time, train => $info->train, via => [ map { { stop => $_ } } $info->route_interesting(3) ], destination => $info->destination, platform => $info->platform, info => $info->info, }); } $template->param( platform => \@params, ); say $template->output; Loading
share/template.html +31 −6 Original line number Diff line number Diff line Loading @@ -11,9 +11,10 @@ color: white; font-family: Sans-Serif; font-weight: bold; position: absolute; left: 1em; top: 1em; position: relative; margin-left: 1em; margin-top: 1em; float: left; width: 28em; height: 4.5em; border: 0.7em solid #000066; Loading @@ -24,6 +25,12 @@ position: absolute; } div.no-data { top: 0.5em; left: 1em; font-size: 2em; } div.time { top: 0em; left: 0em; Loading @@ -42,6 +49,10 @@ height: 1em; } div.via span { margin-right: 0.4em; } div.destination { top: 1.2em; left: 2.9em; Loading @@ -66,7 +77,15 @@ </style> </head> <body> <TMPL_LOOP platform> <div class="display"> <div class="platform"> <TMPL_VAR platform> </div> <TMPL_IF train> <div class="time"> <TMPL_VAR time> </div> Loading @@ -81,14 +100,20 @@ <div class="destination"> <TMPL_VAR destination> </div> <div class="platform"> <TMPL_VAR platform> </div> <TMPL_IF info> <div class="info"> <TMPL_VAR info> </div> </TMPL_IF> <TMPL_ELSE> <div class="no-data"> Bitte Ansage beachten </div> </TMPL_IF> </div> <!-- display --> </TMPL_LOOP> </body> </html>