summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-03-21 10:53:04 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-03-21 10:53:04 +0100
commitbb32333ee20326e9125ff2de0c9c7bbd22ee8bb4 (patch)
treedde01801be8fd9a3f2a72d8ba88916a686b903e9
parent7f180555b22d2162ba26d62c93491f496211e537 (diff)
landing page: accept both train numbers and station names
-rw-r--r--lib/DBInfoscreen/Controller/Static.pm16
-rw-r--r--templates/layouts/app.html.ep8
-rw-r--r--templates/layouts/legacy.html.ep8
3 files changed, 19 insertions, 13 deletions
diff --git a/lib/DBInfoscreen/Controller/Static.pm b/lib/DBInfoscreen/Controller/Static.pm
index 4a645ed..c25c6c5 100644
--- a/lib/DBInfoscreen/Controller/Static.pm
+++ b/lib/DBInfoscreen/Controller/Static.pm
@@ -1,4 +1,5 @@
package DBInfoscreen::Controller::Static;
+
# Copyright (C) 2011-2020 Daniel Friesel
#
# SPDX-License-Identifier: AGPL-3.0-or-later
@@ -11,11 +12,11 @@ my %default = (
);
sub redirect {
- my ($self) = @_;
- my $station = $self->param('station');
- my $params = $self->req->params;
+ my ($self) = @_;
+ my $input = $self->param('input');
+ my $params = $self->req->params;
- $params->remove('station');
+ $params->remove('input');
for my $param (qw(platforms mode admode via)) {
if (
@@ -30,7 +31,12 @@ sub redirect {
$params = $params->to_string;
- $self->redirect_to("/${station}?${params}");
+ if ( $input =~ m{ ^ [a-zA-Z]{1,5} \s+ \d+ $ }x ) {
+ $self->redirect_to("/z/${input}?${params}");
+ }
+ else {
+ $self->redirect_to("/${input}?${params}");
+ }
}
sub geolocation {
diff --git a/templates/layouts/app.html.ep b/templates/layouts/app.html.ep
index 78f8ebf..cf552e3 100644
--- a/templates/layouts/app.html.ep
+++ b/templates/layouts/app.html.ep
@@ -124,13 +124,13 @@ Bitte eine Station aus der Liste auswählen</div>
<div class="desc">Bahnhof / Haltestelle</div>
<div>
% if (stash('stationlist')) {
- %= select_field station => stash('stationlist')
+ %= select_field input => stash('stationlist')
% }
-% elsif (stash('station')) {
- %= text_field 'station', class => 'station', placeholder => 'Name oder DS100-Kürzel', id => 'stationinput'
+% elsif (stash('input')) {
+ %= text_field 'input', class => 'station', placeholder => 'Name oder DS100-Kürzel', id => 'stationinput'
% }
% else {
- %= text_field 'station', class => 'station', placeholder => 'Name oder DS100-Kürzel', id => 'stationinput', autofocus => 'autofocus'
+ %= text_field 'input', class => 'station', placeholder => 'Name oder DS100-Kürzel', id => 'stationinput', autofocus => 'autofocus'
% }
</div>
</div>
diff --git a/templates/layouts/legacy.html.ep b/templates/layouts/legacy.html.ep
index d587cc6..c706a2d 100644
--- a/templates/layouts/legacy.html.ep
+++ b/templates/layouts/legacy.html.ep
@@ -83,13 +83,13 @@ Bitte eine Station aus der Liste auswählen</div>
<div class="desc">Bahnhof / Haltestelle</div>
<div>
% if (stash('stationlist')) {
- %= select_field station => stash('stationlist')
+ %= select_field input => stash('stationlist')
% }
-% elsif (stash('station')) {
- %= text_field 'station', class => 'station', placeholder => 'Name oder DS100-Kürzel'
+% elsif (stash('input')) {
+ %= text_field 'input', class => 'station', placeholder => 'Name oder DS100-Kürzel'
% }
% else {
- %= text_field 'station', class => 'station', placeholder => 'Name oder DS100-Kürzel', autofocus => 'autofocus'
+ %= text_field 'input', class => 'station', placeholder => 'Name oder DS100-Kürzel', autofocus => 'autofocus'
% }
</div>
</div>