[%
cur = f.currently; today = f.daily.data.0;
today_start = f.hourly.data.0.time.clone
today_stop = f.hourly.data.0.time.clone.add('days'=>1);
hourly = f.hourly.slice('from', today_start, 'to', today_stop);
MACRO hours_length(span) BLOCK;
d=span.stop_time.subtract_datetime(span.start_time);
format_duration(
'pattern','%k',
'base',span.start_time,
'normalize',1).format_duration(d);
END;
MACRO time(d) BLOCK;
d.clone.set_time_zone('Europe/London').strftime('%H:%M');
END;
MACRO minsec_until(d) BLOCK;
dur=d.subtract_datetime(now);
format_duration(
'pattern','%M:%S',
'base',now,
'normalize',1).format_duration(dur);
END;
-%]
<html>
<head>
<title>Forecast</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<style type="text/css">
body, table {
font-size: 15px;
}
div.currently, div.next-hour, div.next-day, div.next-week {
float: left; clear: none;
width: 24%;
}
div.days { clear: both }
div.days dl { float: left; width: 30% }
div.bus, div.tube { float: left }
table { border-collapse: collapse; empty-cells: show }
table td { border: dotted thin black }
.icon img {
width: 2em; height: 2em;
float: left;
}
.stripes {
text-align: center;
border: solid thin black;
}
.stripes span {
font-size: 30%;
vertical-align: middle;
}
</style>
</head>
<body>
<div class="forecast">
<div class="currently">
<h2>Currently</h2>
<span class="icon"><img src="[% icon_for(cur.icon) %]" alt="[% cur.icon %]" /></span>
<dl class="currently">
<dt class="temperature">Temperature:</dt>
<dd class="temperature">[% cur.temperature %]°</dd>
<dt class="summary">Summary:</dt>
<dd class="summary">[% cur.summary %]</dd>
</dl>
</div>
<div class="next-hour">
<h2>Next hour</h2>
<span class="icon"><img src="[% icon_for(f.minutely.icon) %]" alt="[% f.minutely.icon %]" /></span>
<dl class="next-hour">
<dt class="summary">Summary:</dt>
<dd class="summary">[% f.minutely.summary %]</dd>
</dl>
</div>
<div class="next-day">
<h2>Next 24 hours</h2>
<span class="icon"><img src="[% icon_for(hourly.icon) %]" alt="[% hourly.icon %]" /></span>
<dl class="next-day">
<dt class="summary">Summary:</dt>
<dd class="summary">[% hourly.summary %]</dd>
</dl>
</div>
<div class="next-week">
<h2>Next 7 days</h2>
<span class="icon"><img src="[% icon_for(f.daily.icon) %]" alt="[% f.daily.icon %]" /></span>
<dl class="next-week">
<dt class="summary">Summary:</dt>
<dd class="summary">[% f.daily.summary %]</dd>
</dl>
</div>
<div class="days">
<div class="day today">
<h2>Today</h2>
<span class="icon"><img src="[% icon_for(today.icon) %]" alt="[% today.icon %]" /></span>
<dl class="today">
<dt class="summary">Summary:</dt>
<dd class="summary">[% today.summary %]</dd>
<dt class="temperature min">Min temperature:</dt>
<dd class="temperature min">[% today.temperatureMin %]° <span class="time">[% time(today.temperatureMinTime) %]</span></dd>
<dt class="temperature max">Max temperature:</dt>
<dd class="temperature max">[% today.temperatureMax %]° <span class="time">[% time(today.temperatureMaxTime) %]</span></dd>
<dt class="sunrise">Sunrise:</dt>
<dd class="sunrise"><span class="time">[% time(today.sunriseTime) %]</span></dd>
<dt class="sunset">Sunset:</dt>
<dd class="sunset"><span class="time">[% time(today.sunsetTime) %]</span></dd>
</dl>
<div class="timeline">
<table class="timeline">
<tr class="summary">
[% FOR span IN hourly.spans_by_string('summary');
width=hours_length(span) %]
<td class="stripes" colspan="[% width %]"><span>[% span.value %]</span></td>
[% END %]
</tr>
<tr class="hours">
[% FOR h IN hourly.data; BREAK IF loop.last %]
<td class="stripes"><span>[% time(h.time) %]</span></td>
[% END %]
</tr>
<tr class="temperature">
[% FOR h IN hourly.data; BREAK IF loop.last %]
<td class="stripes"><span>[% h.temperature %]°</span></td>
[% END %]
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="bus">
<table class="prediction">
<thead>
<tr><th>Line</th><th>Destination</th><th>When</th></tr>
</thead>
<tbody>
[% FOREACH p IN b.Prediction %]
<tr>
<td>[% p.LineName %]</td>
<td>[% p.DestinationText %]</td>
<td>[% minsec_until(p.EstimatedTime) %]</td>
</tr>
[% END %]
</tbody>
</table>
</div>
<div class="tube">
<table class="status">
<thead>
<tr><th>Line</th><th>Status</th><th>Details</th></tr>
</thead>
<tbody>
[% FOREACH line IN t.lines %]
<tr>
<td>[% line.name %]</td>
<td>[% line.status.description %]</td>
<td>[% line.status.details %]</td>
</tr>
[% END %]
</tbody>
</table>
</div>
</body>
</html>