package Kwiki::Weather; use strict; use warnings; use Kwiki::Plugin -Base; use mixin 'Kwiki::Installer'; our $VERSION = '0.05'; const class_title => 'Weather Report'; const class_id => 'weather'; const cgi_class => 'Kwiki::Weather::CGI'; field 'geo_weather'; sub register { my $registry = shift; $registry->add( action => 'weather' ); $registry->add( toolbar => 'weather', template => 'weather_button.html' ); $registry->add( wafl => weather => 'Kwiki::Weather::Wafl' ); $registry->add( prerequisite => 'zipcode' ); } sub weather { my $zipcode = $self->cgi->zipcode; return $self->render_screen( content_pane => 'weather_error.html' ) unless $zipcode =~ /^\d{5}$/; require Geo::Weather; my $weather = Geo::Weather->new; $weather->get_weather($zipcode); $self->geo_weather($weather); $self->render_screen; } package Kwiki::Weather::Wafl; use base 'Spoon::Formatter::WaflPhrase'; sub to_html { my $zipcode = $self->arguments; return $self->wafl_error unless $zipcode =~ /^\d{5}$/; require Geo::Weather; my $weather = Geo::Weather->new; $weather->get_weather($zipcode); $self->hub->template->process( 'weather_report.html', weather => $weather, ); } package Kwiki::Weather::CGI; use Kwiki::CGI -base; cgi 'zipcode'; package Kwiki::Weather; __DATA__ =head1 NAME Kwiki::Weather - Weather button and WAFL for your Kwiki =head1 SYNOPSIS $ cpan Kwiki::Weather $ cd /path/to/kwiki $ echo "Kwiki::Weather" >> plugins $ kwiki -update =head1 DESCRIPTION This adds as weather button in your Kwiki toolbar. Users must specify a zip code in their preferences first. Additionally, this plugin adds a WAFL phrase you can use to generate a weather report from KwikiText: === The Weather in Boston {weather: 02115} Reports are generated by L. =head1 AUTHORS Ian Langworth and Brian Ingerson =head1 SEE ALSO L, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2004 by Ian Langworth This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut __template/tt2/weather_content.html__ [% self.geo_weather.report %]
[% self.geo_weather.report_forecast %] __template/tt2/weather_error.html__ [% screen_title = 'Weather Report' %]

Please specify a zipcode in your Preferences.

__template/tt2/weather_report.html__ [% weather.report %]
[% weather.report_forecast %] __template/tt2/weather_button.html__ [% INCLUDE weather_button_icon.html %] __template/tt2/weather_button_icon.html__ Weather