diff options
author | Daniel Friesel <derf@finalrewind.org> | 2015-10-19 20:07:42 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2015-10-19 20:07:42 +0200 |
commit | db11f698064160c366ef5165b723f297f75cba16 (patch) | |
tree | 3d99d8a6f1498ca8f5b2f1bc1c6b9fe9fea7ebf7 | |
parent | 91a0e1fbe110cd7a5c69506e16888376e380b53a (diff) |
form: redirect to .html when infoscreen frontend is selected
-rw-r--r-- | index.pl | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -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; |