diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-08-19 03:26:23 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-08-19 03:26:23 +0200 |
commit | 969590d6d4f98dfb4c5cb435205e6d5791497ec1 (patch) | |
tree | 2ce6c53208f958c644693b3f3556bbd027a4d975 | |
parent | 8996df6ac354bfcc20eeb286139b899f04aef556 (diff) |
Add via support
-rw-r--r-- | cgi/index.pl | 17 |
1 files changed, 16 insertions, 1 deletions
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(); |