From db11f698064160c366ef5165b723f297f75cba16 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 19 Oct 2015 20:07:42 +0200 Subject: form: redirect to .html when infoscreen frontend is selected --- index.pl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'index.pl') 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; -- cgit v1.2.3