From edafc6a7c1fa66ab7b3805850b8c29e92ad1d732 Mon Sep 17 00:00:00 2001 From: Tim G L Lyons Date: Tue, 24 Sep 2013 11:30:33 +0000 Subject: [PATCH] 0006802: In Narrative Web report most Family Maps are missing. Problem due to single apostrophe (closing single quotation mark) which needs to be escaped. svn: r23189 --- gramps/plugins/webreport/narrativeweb.py | 31 +++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/gramps/plugins/webreport/narrativeweb.py b/gramps/plugins/webreport/narrativeweb.py index 32fa6b17b..e1aedee54 100644 --- a/gramps/plugins/webreport/narrativeweb.py +++ b/gramps/plugins/webreport/narrativeweb.py @@ -3527,7 +3527,8 @@ class PlacePages(BasePage): head += jsc # Google adds Latitude/ Longitude to its maps... - jsc += google_jsc % (latitude, longitude, placetitle) + jsc += google_jsc % (latitude, longitude, + placetitle.replace("'", "\\'")) else: # OpenStreetMap (OSM) adds Longitude/ Latitude to its maps, @@ -5495,7 +5496,7 @@ class PersonPages(BasePage): individualdetail += self.display_ind_associations(assocs) # for use in family map pages... - if len(place_lat_long): + if len(place_lat_long) > 0: if self.report.options["familymappages"]: # save of, string_io and cur_fname before creating a new page sof = of @@ -5630,13 +5631,17 @@ class PersonPages(BasePage): # are we creating Drop Markers or Markers? elif self.googleopts in ["Drop", "Markers"]: tracelife += """ - ['%s', %s, %s, %d],""" % (placetitle, latitude, longitude, seq_) + ['%s', %s, %s, %d],""" % (placetitle.replace("'", "\\'"), latitude, longitude, seq_) # are we using OpenStreetMap? else: tracelife += """ [%s, %s],""" % (longitude, latitude) seq_ += 1 + # FIXME: The last element in the place_lat_long list is treated + # specially, and the code above is apparently repeated so as to + # avoid a comma at the end, and get the right closing. This is very + # ugly. latitude, longitude, placetitle, handle ,date, etype = place_lat_long[-1] # are we using Google? @@ -5652,7 +5657,7 @@ class PersonPages(BasePage): elif self.googleopts in ["Drop", "Markers"]: tracelife += """ ['%s', %s, %s, %d] - ];""" % (placetitle, latitude, longitude, seq_) + ];""" % (placetitle.replace("'", "\\'"), latitude, longitude, seq_) # are we using OpenStreetMap? elif self.mapservice == "OpenStreetMap": @@ -5691,11 +5696,25 @@ class PersonPages(BasePage): # are we using Google? if self.mapservice == "Google": - jsc += google_jsc % (latitude, longitude, placetitle) + # FIXME: Horrible hack, because when there is only a + # single marker, the javascript for place is used, + # which has a 'place_canvas' division, instead of a + # 'map_canvas' division. + jsc += google_jsc.replace("place_canvas", + "map_canvas") % \ + (latitude, longitude, + placetitle.replace("'", "\\'")) # we are using OpenStreetMap? else: - jsc += openstreetmap_jsc % (xml_lang()[3:5].lower(), longitude, latitude) + # FIXME: Horrible hack, because when there is only a + # single marker, the javascript for place is used, + # which has a 'place_canvas' division, instead of a + # 'map_canvas' division. + jsc += openstreetmap_jsc.replace("place_canvas", + "map_canvas") % \ + (xml_lang()[3:5].lower(), + longitude, latitude) # there is more than one marker... else: