summaryrefslogtreecommitdiff
path: root/cgi
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-08-19 03:26:23 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-08-19 03:26:23 +0200
commit969590d6d4f98dfb4c5cb435205e6d5791497ec1 (patch)
tree2ce6c53208f958c644693b3f3556bbd027a4d975 /cgi
parent8996df6ac354bfcc20eeb286139b899f04aef556 (diff)
Add via support
Diffstat (limited to 'cgi')
-rw-r--r--cgi/index.pl17
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();