]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/osm.pm
Added a comment
[git.ikiwiki.info.git] / IkiWiki / Plugin / osm.pm
index a7baa5f2b968ebb0464a787be7371a26a2f98423..27db31af583994fc8da9c1a062b8b6518daa5dba 100644 (file)
@@ -14,7 +14,7 @@ sub import {
        hook(type => "format", id => "osm", call => \&format);
        hook(type => "preprocess", id => "osm", call => \&preprocess);
        hook(type => "preprocess", id => "waypoint", call => \&process_waypoint);
        hook(type => "format", id => "osm", call => \&format);
        hook(type => "preprocess", id => "osm", call => \&preprocess);
        hook(type => "preprocess", id => "waypoint", call => \&process_waypoint);
-       hook(type => "savestate", id => "waypoint", call => \&savestate);
+       hook(type => "changes", id => "waypoint", call => \&changes);
        hook(type => "cgi", id => "osm", call => \&cgi);
 }
 
        hook(type => "cgi", id => "osm", call => \&cgi);
 }
 
@@ -192,6 +192,7 @@ sub process_waypoint {
                }
        }
        $icon = urlto($icon, $dest, 1);
                }
        }
        $icon = urlto($icon, $dest, 1);
+       $icon =~ s!/*$!!; # hack - urlto shouldn't be appending a slash in the first place
        $tag = '' unless $tag;
        register_rendered_files($map, $page, $dest);
        $pagestate{$page}{'osm'}{$map}{'waypoints'}{$name} = {
        $tag = '' unless $tag;
        register_rendered_files($map, $page, $dest);
        $pagestate{$page}{'osm'}{$map}{'waypoints'}{$name} = {
@@ -232,7 +233,7 @@ sub get_tag_icon($) {
        my $tag = shift;
        # look for an icon attached to the tag
        my $attached = $tag . '/' . $config{'osm_tag_default_icon'};
        my $tag = shift;
        # look for an icon attached to the tag
        my $attached = $tag . '/' . $config{'osm_tag_default_icon'};
-       if (srcfile($attached)) {
+       if (srcfile($attached, 1)) {
                return $attached;
        }
        else {
                return $attached;
        }
        else {
@@ -279,7 +280,7 @@ sub scrub_lonlat($$$) {
        return ($lon, $lat);
 }
 
        return ($lon, $lat);
 }
 
-sub savestate {
+sub changes {
        my %waypoints = ();
        my %linestrings = ();
 
        my %waypoints = ();
        my %linestrings = ();
 
@@ -506,7 +507,7 @@ sub include_javascript ($) {
                }
        }
        if ($loader) {
                }
        }
        if ($loader) {
-               return embed_map_code($page) . "<script type=\"text/javascript\" charset=\"utf-8\">$loader</script>";
+               return embed_map_code($page) . "<script type=\"text/javascript\">$loader</script>";
        }
        else {
                return '';
        }
        else {
                return '';
@@ -533,7 +534,7 @@ sub cgi($) {
        print "<html><body>";
        print "<div id=\"mapdiv-$map\"></div>";
        print embed_map_code();
        print "<html><body>";
        print "<div id=\"mapdiv-$map\"></div>";
        print embed_map_code();
-       print "<script type=\"text/javascript\" charset=\"utf-8\">";
+       print "<script type=\"text/javascript\">";
        print map_setup_code($map, $map,
                lat => "urlParams['lat']",
                lon => "urlParams['lon']",
        print map_setup_code($map, $map,
                lat => "urlParams['lat']",
                lon => "urlParams['lon']",
@@ -588,6 +589,7 @@ sub map_setup_code($;@) {
        }
         $options{'layers'} = $config{osm_layers};
 
        }
         $options{'layers'} = $config{osm_layers};
 
+       $name=~s/'//g; # $name comes from user input
        return "mapsetup('mapdiv-$name', " . to_json(\%options) . ");";
 }
 
        return "mapsetup('mapdiv-$name', " . to_json(\%options) . ");";
 }