# Blosxom Plugin: geotag # Author(s): Nils Ketelsen # Version: 0.1 #---------------------------------------------------------------------------- # "THE BEER-WARE LICENSE" (Revision 42): # wrote this file. As long as you retain this notice you # can do whatever you want with this stuff. If we meet some day, and you # think this stuff is worth it, you can buy me a beer in return # Nils Ketelsen # ---------------------------------------------------------------------------- package geotag; #--------------- Configuration section------------------- my $googlemapsprefix = "Google maps link: "; my $googlemapspostfix= "
\n"; my $geocacheprefix = "Geocache suche um: "; my $geocachepostfix = "
\n"; #---------------------End of config---------------------- # Exported Variables $googlemaps; $geocachesearch; $geofile; sub start { return 1; }; sub story{ my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; my $file = "${blosxom::datadir}/${path}/${filename}.geo"; my $lat, $long, $desc; $googlemaps = ''; $geocachesearch = ''; $geofile = $file; if (-f $file && -r _) { open GEOFILE,"<$file"; while (my $line = ) { ($lat,$long,$desc) = split /:/,$line,3; if ($lat =~ /\s/) {$lat = degmin2dec($lat)}; if ($long =~ /\s/) {$long = degmin2dec($long)}; $googlemaps = "$googlemaps $googlemapsprefix $desc$googlemapspostfix"; $geocachesearch = "$geocachesearch $geocacheprefix $desc$geocachepostfix"; }; close GEOFILE; }; return 1; }; sub degmin2dec { my $input = shift; my ($d, $m) = split /\s+/,$input,2; if ($d < 0) {$m *= -1}; return $d + $m/60; } 1;