From 969590d6d4f98dfb4c5cb435205e6d5791497ec1 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 19 Aug 2011 03:26:23 +0200 Subject: Add via support --- cgi/index.pl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cgi/index.pl b/cgi/index.pl index baddd38..90452aa 100644 --- a/cgi/index.pl +++ b/cgi/index.pl @@ -28,6 +28,7 @@ sub get_results_for { sub handle_request { my $self = shift; my $station = $self->stash('station'); + my $via = $self->stash('via'); $self->stash( departures => [] ); $self->stash( title => 'db-fakedisplay' ); @@ -47,6 +48,12 @@ sub handle_request { } for my $result (@results) { + if ($via) { + my @route = $result->route; + if (not( grep { $_ =~ m{$via}io } @route )) { + next; + } + } push( @departures, { @@ -71,11 +78,19 @@ sub handle_request { get '/_redirect' => sub { my $self = shift; my $station = $self->param('station'); - $self->redirect_to("/${station}"); + my $via = $self->param('via'); + + if ($via) { + $self->redirect_to("/${station}/${via}"); + } + else { + $self->redirect_to("/${station}"); + } }; get '/' => \&handle_request; get '/:station' => \&handle_request; +get '/:station/:via' => \&handle_request; get '/multi/:station' => \&handle_request; app->start(); -- cgit v1.2.3