From 7bb417f22888bbac2bcb96b75a13cfe64381929a Mon Sep 17 00:00:00 2001 From: dakkar Date: Mon, 20 May 2013 22:17:42 +0100 Subject: HTML output or forecast stripes/spans are wrong --- forecast-file.pl | 40 ++++++++++++++++++-- forecast.html.tt | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ icons/1.svg | 59 +++++++++++++++++++++++++++++ icons/10.svg | 60 ++++++++++++++++++++++++++++++ icons/11.svg | 58 +++++++++++++++++++++++++++++ icons/12.svg | 57 ++++++++++++++++++++++++++++ icons/13.svg | 53 ++++++++++++++++++++++++++ icons/14.svg | 53 ++++++++++++++++++++++++++ icons/15.svg | 53 ++++++++++++++++++++++++++ icons/16.svg | 58 +++++++++++++++++++++++++++++ icons/17.svg | 58 +++++++++++++++++++++++++++++ icons/18.svg | 58 +++++++++++++++++++++++++++++ icons/19.svg | 60 ++++++++++++++++++++++++++++++ icons/2.svg | 62 +++++++++++++++++++++++++++++++ icons/20.svg | 62 +++++++++++++++++++++++++++++++ icons/21.svg | 65 ++++++++++++++++++++++++++++++++ icons/22.svg | 65 ++++++++++++++++++++++++++++++++ icons/23.svg | 85 ++++++++++++++++++++++++++++++++++++++++++ icons/24.svg | 61 ++++++++++++++++++++++++++++++ icons/25.svg | 60 ++++++++++++++++++++++++++++++ icons/26.svg | 61 ++++++++++++++++++++++++++++++ icons/27.svg | 65 ++++++++++++++++++++++++++++++++ icons/28.svg | 62 +++++++++++++++++++++++++++++++ icons/29.svg | 48 ++++++++++++++++++++++++ icons/3.svg | 51 +++++++++++++++++++++++++ icons/30.svg | 62 +++++++++++++++++++++++++++++++ icons/31.svg | 54 +++++++++++++++++++++++++++ icons/32.svg | 50 +++++++++++++++++++++++++ icons/33.svg | 49 ++++++++++++++++++++++++ icons/34.svg | 54 +++++++++++++++++++++++++++ icons/35.svg | 55 +++++++++++++++++++++++++++ icons/36.svg | 56 ++++++++++++++++++++++++++++ icons/37.svg | 58 +++++++++++++++++++++++++++++ icons/38.svg | 62 +++++++++++++++++++++++++++++++ icons/39.svg | 82 ++++++++++++++++++++++++++++++++++++++++ icons/4.svg | 60 ++++++++++++++++++++++++++++++ icons/40.svg | 57 ++++++++++++++++++++++++++++ icons/41.svg | 52 ++++++++++++++++++++++++++ icons/42.svg | 52 ++++++++++++++++++++++++++ icons/43.svg | 48 ++++++++++++++++++++++++ icons/44.svg | 52 ++++++++++++++++++++++++++ icons/45.svg | 53 ++++++++++++++++++++++++++ icons/46.svg | 67 +++++++++++++++++++++++++++++++++ icons/47.svg | 59 +++++++++++++++++++++++++++++ icons/5.svg | 54 +++++++++++++++++++++++++++ icons/6.svg | 54 +++++++++++++++++++++++++++ icons/7.svg | 55 +++++++++++++++++++++++++++ icons/8.svg | 67 +++++++++++++++++++++++++++++++++ icons/9.svg | 60 ++++++++++++++++++++++++++++++ 49 files changed, 2894 insertions(+), 3 deletions(-) create mode 100644 forecast.html.tt create mode 100644 icons/1.svg create mode 100644 icons/10.svg create mode 100644 icons/11.svg create mode 100644 icons/12.svg create mode 100644 icons/13.svg create mode 100644 icons/14.svg create mode 100644 icons/15.svg create mode 100644 icons/16.svg create mode 100644 icons/17.svg create mode 100644 icons/18.svg create mode 100644 icons/19.svg create mode 100644 icons/2.svg create mode 100644 icons/20.svg create mode 100644 icons/21.svg create mode 100644 icons/22.svg create mode 100644 icons/23.svg create mode 100644 icons/24.svg create mode 100644 icons/25.svg create mode 100644 icons/26.svg create mode 100644 icons/27.svg create mode 100644 icons/28.svg create mode 100644 icons/29.svg create mode 100644 icons/3.svg create mode 100644 icons/30.svg create mode 100644 icons/31.svg create mode 100644 icons/32.svg create mode 100644 icons/33.svg create mode 100644 icons/34.svg create mode 100644 icons/35.svg create mode 100644 icons/36.svg create mode 100644 icons/37.svg create mode 100644 icons/38.svg create mode 100644 icons/39.svg create mode 100644 icons/4.svg create mode 100644 icons/40.svg create mode 100644 icons/41.svg create mode 100644 icons/42.svg create mode 100644 icons/43.svg create mode 100644 icons/44.svg create mode 100644 icons/45.svg create mode 100644 icons/46.svg create mode 100644 icons/47.svg create mode 100644 icons/5.svg create mode 100644 icons/6.svg create mode 100644 icons/7.svg create mode 100644 icons/8.svg create mode 100644 icons/9.svg diff --git a/forecast-file.pl b/forecast-file.pl index 990dfa9..02dba1c 100644 --- a/forecast-file.pl +++ b/forecast-file.pl @@ -4,11 +4,45 @@ use warnings; use 5.014; use WebService::ForecastIo::Response; use Path::Class; +use Template::Provider::Encoding; +use Template::Stash::ForceUTF8; use Template; -my $res = WebService::ForecastIo::Response->new(file($ARGV[0])->slurp); -my $t = Template->new; -$t->process(\*DATA,{f=>$res}) +my %icon_for=( + 'clear-day' => '2', + 'clear-night' => '3', + rain => '18', + snow => '23', + sleet => '24', + wind => '6', + fog => '13', + cloudy => '14', + 'partly-cloudy-day' => '8', + 'partly-cloudy-night' => '9', +); + +sub icon_for { + my ($status) = @_; + + return "icons/".($icon_for{$status}//'45').".svg"; +} + +my $res = WebService::ForecastIo::Response->new( + file($ARGV[0])->slurp(iomode=>'<:raw') +); +my $tf = file(__FILE__)->parent->file('forecast.html.tt'); +my $t = Template->new( + LOAD_TEMPLATES => [ Template::Provider::Encoding->new( + ABSOLUTE => 1, + RELATIVE => 1, + ) ], + STASH => Template::Stash::ForceUTF8->new, +); +binmode STDOUT,':utf8'; +$t->process($tf->stringify,{ + f => $res, + icon_for => \&icon_for, +}) or die $t->error; __DATA__ diff --git a/forecast.html.tt b/forecast.html.tt new file mode 100644 index 0000000..57edfb7 --- /dev/null +++ b/forecast.html.tt @@ -0,0 +1,111 @@ +[% + cur = f.currently; today = f.daily.data.0; + MACRO hours_length BLOCK; + span.stop_time.subtract_datetime(span.start_time).in_units('hours'); + END; +-%] + + + Forecast + + + + +
+

Currently

+ [% cur.icon %] +
+
Temperature:
+
[% cur.temperature %]°
+
Summary:
+
[% cur.summary %]
+
+
+
+

Next hour

+ [% f.minutely.icon %] +
+
Summary:
+
[% f.minutely.summary %]
+
+
+
+

Next 24 hours

+ [% f.hourly.icon %] +
+
Summary:
+
[% f.hourly.summary %]
+
+
+
+

Next 7 days

+ [% f.daily.icon %] +
+
Summary:
+
[% f.daily.summary %]
+
+
+
+
+ [% today.icon %] +
+
Summary:
+
[% today.summary %]
+
Min temperature:
+
[% today.temperatureMin %]° [% today.temperatureMinTime.strftime('%H:%M') %]
+
Max temperature:
+
[% today.temperatureMax %]° [% today.temperatureMaxTime.strftime('%H:%M') %]
+
Sunrise:
+
[% today.sunriseTime.strftime('%H:%M') %]
+
Sunset:
+
[% today.sunsetTime.strftime('%H:%M') %]
+
+
+
+ [% left=0 ;FOR span IN f.hourly.spans_by_string('summary'); + width=3*hours_length(span=span) %] + [% span.value %] [% span.start_time %] [% span.stop_time %] + [% left=left+width; END %] +
+
+ [% left=0; FOR span IN [ 0 .. 23 ] %] + [% span %] + [% left=left+3; END %] +
+
+ [% left=0; FOR h IN f.hourly.data %] + [% h.temperature %]° + [% left=left+3; END %] +
+
+
+
+ + diff --git a/icons/1.svg b/icons/1.svg new file mode 100644 index 0000000..82ef012 --- /dev/null +++ b/icons/1.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/10.svg b/icons/10.svg new file mode 100644 index 0000000..5bd1551 --- /dev/null +++ b/icons/10.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/11.svg b/icons/11.svg new file mode 100644 index 0000000..4a260a3 --- /dev/null +++ b/icons/11.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/12.svg b/icons/12.svg new file mode 100644 index 0000000..a53981f --- /dev/null +++ b/icons/12.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/13.svg b/icons/13.svg new file mode 100644 index 0000000..105bb4e --- /dev/null +++ b/icons/13.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/14.svg b/icons/14.svg new file mode 100644 index 0000000..f104170 --- /dev/null +++ b/icons/14.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/15.svg b/icons/15.svg new file mode 100644 index 0000000..6d87bc8 --- /dev/null +++ b/icons/15.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/16.svg b/icons/16.svg new file mode 100644 index 0000000..9ebb31b --- /dev/null +++ b/icons/16.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/17.svg b/icons/17.svg new file mode 100644 index 0000000..d9ca7bf --- /dev/null +++ b/icons/17.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/18.svg b/icons/18.svg new file mode 100644 index 0000000..a7cba82 --- /dev/null +++ b/icons/18.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/19.svg b/icons/19.svg new file mode 100644 index 0000000..0fde01f --- /dev/null +++ b/icons/19.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/2.svg b/icons/2.svg new file mode 100644 index 0000000..8e4e5d4 --- /dev/null +++ b/icons/2.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/20.svg b/icons/20.svg new file mode 100644 index 0000000..3f63049 --- /dev/null +++ b/icons/20.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/21.svg b/icons/21.svg new file mode 100644 index 0000000..959e53d --- /dev/null +++ b/icons/21.svg @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/22.svg b/icons/22.svg new file mode 100644 index 0000000..5fc7e81 --- /dev/null +++ b/icons/22.svg @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/23.svg b/icons/23.svg new file mode 100644 index 0000000..b67227f --- /dev/null +++ b/icons/23.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/24.svg b/icons/24.svg new file mode 100644 index 0000000..a19e77f --- /dev/null +++ b/icons/24.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/25.svg b/icons/25.svg new file mode 100644 index 0000000..4ed88a3 --- /dev/null +++ b/icons/25.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/26.svg b/icons/26.svg new file mode 100644 index 0000000..243fc02 --- /dev/null +++ b/icons/26.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/27.svg b/icons/27.svg new file mode 100644 index 0000000..7050b80 --- /dev/null +++ b/icons/27.svg @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/28.svg b/icons/28.svg new file mode 100644 index 0000000..2886ace --- /dev/null +++ b/icons/28.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/29.svg b/icons/29.svg new file mode 100644 index 0000000..a53d754 --- /dev/null +++ b/icons/29.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/3.svg b/icons/3.svg new file mode 100644 index 0000000..c969499 --- /dev/null +++ b/icons/3.svg @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/30.svg b/icons/30.svg new file mode 100644 index 0000000..be657fc --- /dev/null +++ b/icons/30.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/31.svg b/icons/31.svg new file mode 100644 index 0000000..ac0e866 --- /dev/null +++ b/icons/31.svg @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/32.svg b/icons/32.svg new file mode 100644 index 0000000..6457c57 --- /dev/null +++ b/icons/32.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/33.svg b/icons/33.svg new file mode 100644 index 0000000..6e20fb0 --- /dev/null +++ b/icons/33.svg @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/34.svg b/icons/34.svg new file mode 100644 index 0000000..588eddc --- /dev/null +++ b/icons/34.svg @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/35.svg b/icons/35.svg new file mode 100644 index 0000000..2af60b4 --- /dev/null +++ b/icons/35.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/36.svg b/icons/36.svg new file mode 100644 index 0000000..6950b1a --- /dev/null +++ b/icons/36.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/37.svg b/icons/37.svg new file mode 100644 index 0000000..b47907a --- /dev/null +++ b/icons/37.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/38.svg b/icons/38.svg new file mode 100644 index 0000000..52e012c --- /dev/null +++ b/icons/38.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/39.svg b/icons/39.svg new file mode 100644 index 0000000..5e92ed2 --- /dev/null +++ b/icons/39.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/4.svg b/icons/4.svg new file mode 100644 index 0000000..8c15ee6 --- /dev/null +++ b/icons/4.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/40.svg b/icons/40.svg new file mode 100644 index 0000000..b65d9c4 --- /dev/null +++ b/icons/40.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/41.svg b/icons/41.svg new file mode 100644 index 0000000..308c3f8 --- /dev/null +++ b/icons/41.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/42.svg b/icons/42.svg new file mode 100644 index 0000000..f3b06bc --- /dev/null +++ b/icons/42.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/43.svg b/icons/43.svg new file mode 100644 index 0000000..ceb8dd3 --- /dev/null +++ b/icons/43.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/44.svg b/icons/44.svg new file mode 100644 index 0000000..d37e62d --- /dev/null +++ b/icons/44.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/45.svg b/icons/45.svg new file mode 100644 index 0000000..45bd521 --- /dev/null +++ b/icons/45.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/46.svg b/icons/46.svg new file mode 100644 index 0000000..0cea396 --- /dev/null +++ b/icons/46.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/47.svg b/icons/47.svg new file mode 100644 index 0000000..8aade7e --- /dev/null +++ b/icons/47.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/5.svg b/icons/5.svg new file mode 100644 index 0000000..18a5f37 --- /dev/null +++ b/icons/5.svg @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/6.svg b/icons/6.svg new file mode 100644 index 0000000..633016f --- /dev/null +++ b/icons/6.svg @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/7.svg b/icons/7.svg new file mode 100644 index 0000000..7bfa351 --- /dev/null +++ b/icons/7.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/8.svg b/icons/8.svg new file mode 100644 index 0000000..4c1cdc7 --- /dev/null +++ b/icons/8.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/9.svg b/icons/9.svg new file mode 100644 index 0000000..bdf09a3 --- /dev/null +++ b/icons/9.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3