summaryrefslogtreecommitdiff
path: root/forecast.html.tt
blob: ec38f433b14e8a16119961d78380ae97cd4a5849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
[%
 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>