diff options
-rw-r--r-- | cgi/index.pl | 14 | ||||
-rw-r--r-- | cgi/templates/layouts/default.html.ep | 3 |
2 files changed, 12 insertions, 5 deletions
diff --git a/cgi/index.pl b/cgi/index.pl index 6abb47a..06eb677 100644 --- a/cgi/index.pl +++ b/cgi/index.pl @@ -7,12 +7,14 @@ use utf8; our $VERSION = '0.03'; +my $refresh_interval = 900; + sub get_results_for { my ($station) = @_; my $cache = Cache::File->new( cache_root => '/tmp/db-fake', - default_expires => '900 sec' + default_expires => $refresh_interval . ' sec', ); my $results = $cache->thaw($station); @@ -87,7 +89,8 @@ sub handle_request { $info = undef; } if ($info) { - $info =~ s{ ^ (?: ca\. \s* )? \+ (\d+) }{Verspätung ca. $1 Minuten}x; + $info + =~ s{ ^ (?: ca\. \s* )? \+ (\d+) }{Verspätung ca. $1 Minuten}x; $info =~ s{ 1 \s Minute\Kn }{}x; } push( @@ -105,9 +108,10 @@ sub handle_request { $self->render( $template, - departures => \@departures, - version => $VERSION, - title => "departures for ${station}" + departures => \@departures, + version => $VERSION, + title => "departures for ${station}", + refresh_interval => $refresh_interval + 3, ); } diff --git a/cgi/templates/layouts/default.html.ep b/cgi/templates/layouts/default.html.ep index 09a17c0..6e46cdc 100644 --- a/cgi/templates/layouts/default.html.ep +++ b/cgi/templates/layouts/default.html.ep @@ -4,6 +4,9 @@ <head> <title><%= $title %></title> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> +% if ($self->stash('refresh_interval')) { + <meta http-equiv="refresh" content="<%= $self->stash('refresh_interval') %>"/> +% } <style type="text/css"> html { |