Merge pull request #227 from phejl/master

0009626: Google map API now requires a key
This commit is contained in:
Sam Manzi 2016-09-13 09:06:58 +10:00 committed by GitHub
commit a0a3ea61e9

View File

@ -150,7 +150,7 @@ SORT_KEY = glocale.sort_key
#------------------------------------------------ #------------------------------------------------
# constants # constants
#------------------------------------------------ #------------------------------------------------
GOOGLE_MAPS = 'http://maps.googleapis.com/maps/' GOOGLE_MAPS = 'https://maps.googleapis.com/maps/'
# javascript code for marker path # javascript code for marker path
MARKER_PATH = """ MARKER_PATH = """
var marker_png = '%s' var marker_png = '%s'
@ -3941,6 +3941,7 @@ class PlacePages(BasePage):
self.placemappages = self.report.options['placemappages'] self.placemappages = self.report.options['placemappages']
self.mapservice = self.report.options['mapservice'] self.mapservice = self.report.options['mapservice']
self.googlemapkey = self.report.options['googlemapkey']
# begin PlaceDetail Division # begin PlaceDetail Division
with Html("div", class_="content", id="PlaceDetail") as placedetail: with Html("div", class_="content", id="PlaceDetail") as placedetail:
@ -4006,6 +4007,8 @@ class PlacePages(BasePage):
# add MapService specific javascript code # add MapService specific javascript code
src_js = GOOGLE_MAPS + "api/js?sensor=false" src_js = GOOGLE_MAPS + "api/js?sensor=false"
if self.mapservice == "Google": if self.mapservice == "Google":
if self.googlemapkey:
src_js += "&key=" + self.googlemapkey
head += Html("script", type="text/javascript", head += Html("script", type="text/javascript",
src=src_js, inline=True) src=src_js, inline=True)
else: else:
@ -6033,6 +6036,7 @@ class PersonPages(BasePage):
self.mapservice = None self.mapservice = None
self.sort_name = None self.sort_name = None
self.googleopts = None self.googleopts = None
self.googlemapkey = None
self.birthorder = None self.birthorder = None
self.person = None self.person = None
self.familymappages = None self.familymappages = None
@ -6350,6 +6354,7 @@ class PersonPages(BasePage):
self.placemappages = self.report.options['placemappages'] self.placemappages = self.report.options['placemappages']
self.mapservice = self.report.options['mapservice'] self.mapservice = self.report.options['mapservice']
self.googleopts = self.report.options['googleopts'] self.googleopts = self.report.options['googleopts']
self.googlemapkey = self.report.options['googlemapkey']
# decide if we will sort the birth order of siblings... # decide if we will sort the birth order of siblings...
self.birthorder = self.report.options['birthorder'] self.birthorder = self.report.options['birthorder']
@ -6589,7 +6594,9 @@ class PersonPages(BasePage):
# add MapService specific javascript code # add MapService specific javascript code
if self.mapservice == "Google": if self.mapservice == "Google":
src_js = "http://maps.googleapis.com/maps/api/js?sensor=false" src_js = GOOGLE_MAPS + "api/js?sensor=false"
if self.googlemapkey:
src_js += "&key=" + self.googlemapkey
head += Html("script", type="text/javascript", head += Html("script", type="text/javascript",
src=src_js, inline=True) src=src_js, inline=True)
else: else:
@ -8313,6 +8320,7 @@ class NavWebReport(Report):
self.familymappages = self.options['familymappages'] self.familymappages = self.options['familymappages']
self.mapservice = self.options['mapservice'] self.mapservice = self.options['mapservice']
self.googleopts = self.options['googleopts'] self.googleopts = self.options['googleopts']
self.googlemapkey = self.options['googlemapkey']
if self.use_home: if self.use_home:
self.index_fname = "index" self.index_fname = "index"
@ -9577,6 +9585,7 @@ class NavWebOptions(MenuReportOptions):
self.__placemappages = None self.__placemappages = None
self.__familymappages = None self.__familymappages = None
self.__googleopts = None self.__googleopts = None
self.__googlemapkey = None
self.__ancestortree = None self.__ancestortree = None
self.__css = None self.__css = None
self.__dl_descr1 = None self.__dl_descr1 = None
@ -9940,8 +9949,8 @@ class NavWebOptions(MenuReportOptions):
addopt = partial(menu.add_option, category_name) addopt = partial(menu.add_option, category_name)
mapopts = [ mapopts = [
[_("Google"), "Google"], [_("OpenStreetMap"), "OpenStreetMap"],
[_("OpenStreetMap"), "OpenStreetMap"]] [_("Google"), "Google"]]
self.__mapservice = EnumeratedListOption(_("Map Service"), self.__mapservice = EnumeratedListOption(_("Map Service"),
mapopts[0][1]) mapopts[0][1])
for trans, opt in mapopts: for trans, opt in mapopts:
@ -9983,6 +9992,10 @@ class NavWebOptions(MenuReportOptions):
"to have for the Google Maps Family Map pages...")) "to have for the Google Maps Family Map pages..."))
addopt("googleopts", self.__googleopts) addopt("googleopts", self.__googleopts)
self.__googlemapkey = StringOption(_("Google maps API key"),"")
self.__googlemapkey.set_help(_("The API key used for the Google maps"))
addopt("googlemapkey", self.__googlemapkey)
self.__placemap_options() self.__placemap_options()
def __add_others_options(self, menu): def __add_others_options(self, menu):
@ -10157,6 +10170,11 @@ class NavWebOptions(MenuReportOptions):
else: else:
self.__googleopts.set_available(False) self.__googleopts.set_available(False)
if (place_active or family_active) and mapservice_opts == "Google":
self.__googlemapkey.set_available(True)
else:
self.__googlemapkey.set_available(False)
# FIXME. Why do we need our own sorting? Why not use Sort? # FIXME. Why do we need our own sorting? Why not use Sort?
def sort_people(dbase, handle_list, rlocale=glocale): def sort_people(dbase, handle_list, rlocale=glocale):
""" """