Add initial geo plugin.
[blosxom-plugins.git] / gavinc / geo
blobf317a841189c3336bb1fedd7c1aeed9a9dc93293
1 # Blosxom Plugin: geo
2 # Author(s): Gavin Carr <gavin@openfusion.com.au>
3 # Version: 0.001000
4 # Documentation: 'perldoc geo'
6 package geo;
8 use strict;
9 use vars qw($latitude $longitude);
11 sub start { 1 }
13 # Return the first existing metadata item key and value given a list of keys
14 sub _get_meta {
15     for my $attr ( @_ ) {
16         my $meta_attr = $attr;
17         $meta_attr =~ s/-/_/g;
18         my $value = $blosxom::meta{$meta_attr};
19         $value = eval "\$meta::$attr" unless defined $value;
20         return wantarray ? ( $attr, $value ) : $value if defined $value;
21     }
22     return wantarray ? () : undef;
25 sub story {
26     $latitude = _get_meta('geolatitude', 'latitude');
27     $longitude = _get_meta('geolongitude', 'longitude');
29     return 1;
34 __END__
36 =head1 NAME
38 geo - blosxom plugin to set $geo::latitude and $geo::longitude 
39 story variables from metadata items
41 =head1 DESCRIPTION
43 geo - blosxom plugin to set story $geo::latitude and $geo::longitude 
44 story variables from metadata items. 
46 =head2 REQUIRED METADATA ITEMS
48 =over 4
50 =item Latitude (or GeoLatitude)
52 A decimal between -90.0 (South Pole) and +90.0 (North Pole), indicating 
53 degrees of latitude.
55 =item Longitude (or GeoLongitude)
57 A decimal between -180.0 (western hemisphere) and +180.0 (eastern hemisphere), 
58 indicating degrees of longitude.
60 =back
62 If any required metadata is missing the plugin just skips the story.
64 =back
66 =head1 EXAMPLE
68 If using the L<metamail> plugin:
70   Testing geo
71   Latitude: -33.717770
72   Longitude: 151.115886
74 If using the L<meta> plugin:
76   Random blog post
77   meta-latitude: -33.717770
78   meta-longitude: 151.115886
80 =head1 USAGE
82 geo should be loaded after your meta plugins (typically either 
83 L<metamail> or L<meta>).
85 =head1 SEE ALSO
87 Blosxom: http://blosxom.sourceforge.net/
89 =head1 AUTHOR
91 Gavin Carr <gavin@openfusion.com.au>, http://www.openfusion.net/
93 =head1 LICENSE
95 Copyright 2007, Gavin Carr.
97 This plugin is licensed under the same terms as blosxom itself i.e.
99 Permission is hereby granted, free of charge, to any person obtaining a
100 copy of this software and associated documentation files (the "Software"),
101 to deal in the Software without restriction, including without limitation
102 the rights to use, copy, modify, merge, publish, distribute, sublicense,
103 and/or sell copies of the Software, and to permit persons to whom the
104 Software is furnished to do so, subject to the following conditions:
106 The above copyright notice and this permission notice shall be included
107 in all copies or substantial portions of the Software.
109 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
110 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
111 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
112 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
113 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
114 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
115 OTHER DEALINGS IN THE SOFTWARE.
117 =cut
119 # vim:ft=perl