summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2013-09-03 18:51:01 +0200
committerDaniel Friesel <derf@finalrewind.org>2013-09-03 18:51:01 +0200
commitceef0eda607c16844043be2477bf0da5abf9aec4 (patch)
tree0e730a8747d7c86dabbee23cb96dffffdfd44a6b
parent84bd3ab9a8d7a5ff188227737f77bc1b1a02037a (diff)
add experimental HTML frontend
-rw-r--r--cgi/index.pl30
-rw-r--r--cgi/templates/display.html.ep74
-rw-r--r--cgi/templates/main.html.ep14
3 files changed, 118 insertions, 0 deletions
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 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title><%= $title %></title>
+ <meta charset="utf-8">
+ <style type="text/css">
+
+ @font-face {
+ font-family: VRRR;
+ src: url('/VRRR.ttf');
+ }
+
+ body {
+ font-family: VRRR;
+ background-color: #000000;
+ color: #ffd000;
+ font-size: 430%;
+ }
+
+ div.outer {
+ width: 12em;
+ margin-left: auto;
+ margin-right: auto;
+ }
+
+ div.row {
+ position: relative;
+ margin-bottom: 0;
+ margin-top: 0;
+ padding-bottom: 0;
+ padding-top: 0;
+ width: 12em;
+ height: 0.68em;
+ }
+
+ div.row div {
+ overflow: hidden;
+ position: absolute;
+ height: 100%;
+ }
+
+ div.line {
+ left: 0;
+ width: 13%;
+ }
+
+ div.dest {
+ left: 14%;
+ width: 67%;
+ }
+
+ div.time {
+ right: 0;
+ width: 19%;
+ text-align: right;
+ }
+
+ </style>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
+</head>
+<body>
+
+<div class="outer">
+% for my $d (@{$departures}) {
+<div class="row">
+<div class="line"> <%= $d->[0] %> </div>
+<div class="dest"> <%= $d->[1] %> </div>
+<div class="time"> <%= $d->[2] %> </div>
+</div> <!-- row -->
+% }
+</div> <!-- outer -->
+
+</body>
+</html>
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 @@
<body>
% if ($city and $stop) {
+% if ($frontend eq 'png') {
<img src="../<%= $city %>/<%= $stop %>.png?<%= $params %>" alt=""
id="display" height="<%= $height * 4 %>" width="<%= $width * 4 %>"/>
% }
+% elsif ($frontend eq 'html') {
+<iframe src="/<%= $city %>/<%= $stop %>.html?<%= $params %>"
+height="<%= $height * 5 %>" width="<%= $width * 5 %>"></iframe>
+% }
+% }
% else {
<p>
@@ -116,6 +126,10 @@ other German transit networks.
<div class="desc">backend</div>
<div><%= select_field backend => [['EFA (VRR)' => 'vrr'], ['HAFAS (DB)' => 'db']] %></div>
</div>
+ <div class="field">
+ <div class="desc">frontend</div>
+ <div><%= select_field frontend => [['Image (PNG)' => 'png'], ['HTML' => 'html']] %></div>
+ </div>
</div>
<% end %>