summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-07-02 21:05:33 +0200
committerDaniel Friesel <derf@finalrewind.org>2021-07-02 21:05:33 +0200
commit257a4ec39bbf6c9fadce097b854c16969c953a35 (patch)
treeb03aedbc39fd6f2c77578fc55d5090977d4b9dcd
parent254013b651cbb183452107d1d9eb7636d2157808 (diff)
Note that dbf is limited to DB lines when encountering no results
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm32
-rw-r--r--templates/_error.html.ep4
-rw-r--r--templates/layouts/app.html.ep4
3 files changed, 28 insertions, 12 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index f7c469a..55dcd0b 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -28,7 +28,9 @@ my %default = (
);
sub handle_no_results {
- my ( $self, $station, $errstr ) = @_;
+ my ( $self, $station, $data ) = @_;
+
+ my $errstr = $data->{errstr};
my @candidates = map { [ $_->[1], $_->[0] ] }
Travel::Status::DE::IRIS::Stations::get_station($station);
@@ -43,17 +45,27 @@ sub handle_no_results {
);
return;
}
+ if ( $data->{station_ds100} and $data->{station_ds100} =~ m{ ^ [XYZ] }x ) {
+ $self->render(
+ 'landingpage',
+ error => ( $errstr // "Keine Abfahrten an '$station'" )
+ . '. Das von DBF genutzte IRIS-Backend unterstützt im Regelfall nur innerdeutsche Zugfahrten.',
+ hide_opts => 0
+ );
+ return;
+ }
$self->render(
'landingpage',
- error => ( $errstr // "Got no results for '$station'" ),
+ error => ( $errstr // "Keine Abfahrten an '$station'" ),
hide_opts => 0
);
return;
}
sub handle_no_results_json {
- my ( $self, $station, $errstr, $api_version ) = @_;
+ my ( $self, $station, $data, $api_version ) = @_;
+ my $errstr = $data->{errstr};
my $callback = $self->param('callback');
$self->res->headers->access_control_allow_origin(q{*});
@@ -221,6 +233,8 @@ sub get_results_for {
$data = {
results => [ $status->results ],
errstr => $status->errstr,
+ station_ds100 =>
+ ( $status->station ? $status->station->{ds100} : undef ),
station_name =>
( $status->station ? $status->station->{name} : $station ),
};
@@ -317,16 +331,15 @@ sub handle_request {
$opt{lookahead} = 200;
}
- my $data = get_results_for( $station, %opt );
- my $errstr = $data->{errstr};
+ my $data = get_results_for( $station, %opt );
if ( not @{ $data->{results} } and $template eq 'json' ) {
- $self->handle_no_results_json( $station, $errstr, $api_version );
+ $self->handle_no_results_json( $station, $data, $api_version );
return;
}
if ( not @{ $data->{results} } ) {
- $self->handle_no_results( $station, $errstr );
+ $self->handle_no_results( $station, $data );
return;
}
@@ -1104,7 +1117,10 @@ sub handle_result {
# no longer supported
$self->handle_no_results_json(
undef,
- "JSON API version=${apiver} is no longer supported",
+ {
+ errstr =>
+ "JSON API version=${apiver} is no longer supported"
+ },
$Travel::Status::DE::IRIS::VERSION
);
return;
diff --git a/templates/_error.html.ep b/templates/_error.html.ep
index 4abfb4e..8585f90 100644
--- a/templates/_error.html.ep
+++ b/templates/_error.html.ep
@@ -1,5 +1,5 @@
<div class="error"><strong>Fehler:</strong>
-<pre>
+<p style="font-family: Monospace;">
%= $error
-</pre>
+</p>
</div>
diff --git a/templates/layouts/app.html.ep b/templates/layouts/app.html.ep
index 83c83fa..a897747 100644
--- a/templates/layouts/app.html.ep
+++ b/templates/layouts/app.html.ep
@@ -101,9 +101,9 @@
<div class="container">
% if (my $error = stash 'error') {
<div class="error"><strong>Fehler:</strong>
-<pre>
+<p>
%= $error
-</pre>
+</p>
</div>
% }
% elsif (stash('stationlist')) {