From ceef0eda607c16844043be2477bf0da5abf9aec4 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 3 Sep 2013 18:51:01 +0200 Subject: add experimental HTML frontend --- cgi/index.pl | 30 ++++++++++++++++++ cgi/templates/display.html.ep | 74 +++++++++++++++++++++++++++++++++++++++++++ cgi/templates/main.html.ep | 14 ++++++++ 3 files changed, 118 insertions(+) create mode 100644 cgi/templates/display.html.ep diff --git a/cgi/index.pl b/cgi/index.pl index 5c464d9..7c8db0b 100644 --- a/cgi/index.pl +++ b/cgi/index.pl @@ -77,6 +77,7 @@ sub handle_request { my $stop = $self->stash('stop'); my $no_lines = $self->param('no_lines'); + my $frontend = $self->param('frontend') // 'png'; if ( not $no_lines or $no_lines < 1 or $no_lines > 10 ) { $no_lines = $default{no_lines}; @@ -94,6 +95,7 @@ sub handle_request { city => $city, stop => $stop, version => $VERSION, + frontend => $frontend, title => $city ? "departures for ${city} ${stop}" : "vrr-fakedisplay ${VERSION}", @@ -259,6 +261,34 @@ sub get_departures { return ( \@fmt_departures, $errstr ); } +sub render_html { + my $self = shift; + + my ( $departures, $errstr ) = get_departures( + city => $self->stash('city'), + stop => $self->stash('stop'), + no_lines => scalar $self->param('no_lines'), + backend => scalar $self->param('backend'), + filter_line => scalar $self->param('line'), + filter_platform => scalar $self->param('platform'), + offset => scalar $self->param('offset'), + ); + + for my $d ( @{$departures} ) { + if ( $d->[2] and $d->[2] ne 'sofort' ) { + $d->[2] .= ' min'; + } + } + + $self->render( + 'display', + title => "vrr-fakedisplay v${VERSION}", + departures => $departures, + ); + + return; +} + sub render_image { my $self = shift; diff --git a/cgi/templates/display.html.ep b/cgi/templates/display.html.ep new file mode 100644 index 0000000..b61dabf --- /dev/null +++ b/cgi/templates/display.html.ep @@ -0,0 +1,74 @@ + + + + <%= $title %> + + + + + + +
+% for my $d (@{$departures}) { +
+
<%= $d->[0] %>
+
<%= $d->[1] %>
+
<%= $d->[2] %>
+
+% } +
+ + + diff --git a/cgi/templates/main.html.ep b/cgi/templates/main.html.ep index 6686ff6..821824a 100644 --- a/cgi/templates/main.html.ep +++ b/cgi/templates/main.html.ep @@ -9,6 +9,10 @@ font-family: Sans-Serif; } + iframe { + border: none; + } + div.about { margin-top: 2em; color: #666666; @@ -57,9 +61,15 @@ % if ($city and $stop) { +% if ($frontend eq 'png') { % } +% elsif ($frontend eq 'html') { + +% } +% } % else {

@@ -116,6 +126,10 @@ other German transit networks.

backend
<%= select_field backend => [['EFA (VRR)' => 'vrr'], ['HAFAS (DB)' => 'db']] %>
+
+
frontend
+
<%= select_field frontend => [['Image (PNG)' => 'png'], ['HTML' => 'html']] %>
+
<% end %> -- cgit v1.2.3