summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-10-19 20:07:42 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-10-19 20:07:42 +0200
commitdb11f698064160c366ef5165b723f297f75cba16 (patch)
tree3d99d8a6f1498ca8f5b2f1bc1c6b9fe9fea7ebf7
parent91a0e1fbe110cd7a5c69506e16888376e380b53a (diff)
form: redirect to .html when infoscreen frontend is selected
-rw-r--r--index.pl23
1 files changed, 16 insertions, 7 deletions
diff --git a/index.pl b/index.pl
index 4951878..1b4cd23 100644
--- a/index.pl
+++ b/index.pl
@@ -369,8 +369,10 @@ sub make_infoboard_lines {
sub render_html {
my $self = shift;
- my $color = $self->param('color') || '255,208,0';
- my $template = $self->param('template') || 'display';
+ my $color = $self->param('color') // '255,208,0';
+ my $frontend = $self->param('frontend') // 'infoscreen';
+
+ my $template = $frontend eq 'html' ? 'display' : 'infoscreen';
my $data = get_filtered_departures(
city => $self->stash('city') // q{},
@@ -554,9 +556,10 @@ helper 'handle_no_results' => sub {
};
get '/_redirect' => sub {
- my $self = shift;
- my $city = $self->param('city') // q{};
- my $stop = $self->param('stop');
+ my $self = shift;
+ my $city = $self->param('city') // q{};
+ my $stop = $self->param('stop');
+ my $suffix = q{};
my $params = $self->req->params;
@@ -571,13 +574,19 @@ get '/_redirect' => sub {
}
}
+ if ( $params->param('frontend')
+ and $params->param('frontend') eq 'infoscreen' )
+ {
+ $suffix = '.html';
+ }
+
my $params_s = $params->to_string;
if ($city) {
- $self->redirect_to("/${city}/${stop}?${params_s}");
+ $self->redirect_to("/${city}/${stop}${suffix}?${params_s}");
}
else {
- $self->redirect_to("/${stop}?${params_s}");
+ $self->redirect_to("/${stop}${suffix}?${params_s}");
}
return;