line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::Weather; |
2
|
1
|
|
|
1
|
|
42634
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
42
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
120
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
563
|
use Kwiki::Plugin -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
const class_title => 'Weather Report'; |
11
|
|
|
|
|
|
|
const class_id => 'weather'; |
12
|
|
|
|
|
|
|
const cgi_class => 'Kwiki::Weather::CGI'; |
13
|
|
|
|
|
|
|
field 'geo_weather'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub register { |
16
|
|
|
|
|
|
|
my $registry = shift; |
17
|
|
|
|
|
|
|
$registry->add( action => 'weather' ); |
18
|
|
|
|
|
|
|
$registry->add( |
19
|
|
|
|
|
|
|
toolbar => 'weather', |
20
|
|
|
|
|
|
|
template => 'weather_button.html' |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
$registry->add( wafl => weather => 'Kwiki::Weather::Wafl' ); |
23
|
|
|
|
|
|
|
$registry->add( prerequisite => 'zipcode' ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub weather { |
27
|
|
|
|
|
|
|
my $zipcode = $self->cgi->zipcode; |
28
|
|
|
|
|
|
|
return $self->render_screen( content_pane => 'weather_error.html' ) |
29
|
|
|
|
|
|
|
unless $zipcode =~ /^\d{5}$/; |
30
|
|
|
|
|
|
|
require Geo::Weather; |
31
|
|
|
|
|
|
|
my $weather = Geo::Weather->new; |
32
|
|
|
|
|
|
|
$weather->get_weather($zipcode); |
33
|
|
|
|
|
|
|
$self->geo_weather($weather); |
34
|
|
|
|
|
|
|
$self->render_screen; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
package Kwiki::Weather::Wafl; |
38
|
|
|
|
|
|
|
use base 'Spoon::Formatter::WaflPhrase'; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub to_html { |
41
|
|
|
|
|
|
|
my $zipcode = $self->arguments; |
42
|
|
|
|
|
|
|
return $self->wafl_error |
43
|
|
|
|
|
|
|
unless $zipcode =~ /^\d{5}$/; |
44
|
|
|
|
|
|
|
require Geo::Weather; |
45
|
|
|
|
|
|
|
my $weather = Geo::Weather->new; |
46
|
|
|
|
|
|
|
$weather->get_weather($zipcode); |
47
|
|
|
|
|
|
|
$self->hub->template->process( 'weather_report.html', weather => $weather, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
package Kwiki::Weather::CGI; |
52
|
|
|
|
|
|
|
use Kwiki::CGI -base; |
53
|
|
|
|
|
|
|
cgi 'zipcode'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
package Kwiki::Weather; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__DATA__ |