NarrativeWeb: Bug fix for #4095. Thank you Peter for the heads up on this one.

svn: r15627
This commit is contained in:
Rob G. Healey 2010-07-08 22:36:46 +00:00
parent 2638f7641d
commit 3415a1918e

View File

@ -340,11 +340,6 @@ class BasePage(object):
self.create_media = report.options['gallery'] self.create_media = report.options['gallery']
self.inc_events = report.options['inc_events'] self.inc_events = report.options['inc_events']
# options for PlaceMaps for PlacePages
self.placemaps = report.options["placemaps"]
self.place_page = report.options["place_page"]
self.family_map = report.options["family_map"]
def complete_people(self, tcell, first_person, handle_list): def complete_people(self, tcell, first_person, handle_list):
""" """
completes the person column for classes EventListPage and EventPage completes the person column for classes EventListPage and EventPage
@ -2390,6 +2385,7 @@ class PlacePage(BasePage):
self.up = True self.up = True
self.page_title = ReportUtils.place_name(db, place_handle) self.page_title = ReportUtils.place_name(db, place_handle)
placepage, head, body = self.write_header(_("Places")) placepage, head, body = self.write_header(_("Places"))
self.placemappages = self.report.options['placemappages']
# begin PlaceDetail Division # begin PlaceDetail Division
with Html("div", class_ = "content", id = "PlaceDetail") as placedetail: with Html("div", class_ = "content", id = "PlaceDetail") as placedetail:
@ -2430,97 +2426,92 @@ class PlacePage(BasePage):
placedetail += urllinks placedetail += urllinks
# add place map here # add place map here
if self.placemaps: if self.placemappages:
if self.place_page: if (place and (place.lat and place.long)):
if (place and (place.lat and place.long)): # get reallatitude and reallongitude from place
latitude, longitude = conv_lat_lon( place.lat,
place.long,
"D.D8")
# get reallatitude and reallongitude from place # add Mapstraction CSS
latitude, longitude = conv_lat_lon( place.lat, fname = "/".join(["styles", "mapstraction.css"])
place.long, url = self.report.build_url_fname(fname, None, self.up)
"D.D8") head += Html("link", href = url, type = "text/css", media = "screen",
rel = "stylesheet", indent = False)
# add Mapstraction CSS # add googlev3 specific javascript code
fname = "/".join(["styles", "mapstraction.css"]) head += Html("script", type = "text/javascript",
url = self.report.build_url_fname(fname, None, self.up) src = "http://maps.google.com/maps/api/js?sensor=false", inline = True)
head += Html("link", href = url, type = "text/css", media = "screen",
rel = "stylesheet", indent = False)
# add googlev3 specific javascript code # add mapstraction javascript code
head += Html("script", type = "text/javascript", fname = "/".join(["mapstraction", "mxn.js?(googlev3)"])
src = "http://maps.google.com/maps/api/js?sensor=false", inline = True) url = self.report.build_url_fname(fname, None, self.up)
head += Html("script", type = "text/javascript", src = url, inline = True)
# add mapstraction javascript code # Place Map division
fname = "/".join(["mapstraction", "mxn.js?(googlev3)"]) with Html("div", id = "mapstraction") as mapstraction:
url = self.report.build_url_fname(fname, None, self.up) placedetail += mapstraction
head += Html("script", type = "text/javascript", src = url, inline = True)
# Place Map division # section title
with Html("div", id = "mapstraction") as mapstraction: mapstraction += Html("h4", _("Place Map"), inline = True)
placedetail += mapstraction
# section title # begin middle division
mapstraction += Html("h4", _("Place Map"), inline = True) with Html("div", id = "middle") as middle:
mapstraction += middle
# begin middle division # begin inline javascript code
with Html("div", id = "middle") as middle: # because jsc is a string, it does NOT have to properly indented
mapstraction += middle with Html("script", type = "text/javascript") as jsc:
middle += jsc
# begin inline javascript code jsc += """
# because jsc is a string, it does NOT have to properly indented var map;
with Html("script", type = "text/javascript") as jsc: var latlon;
middle += jsc
jsc += """ function initialize() {
//<![CDATA[
var map; // create mxn object
var latlon; map = new mxn.Mapstraction('googlev3','googlev3');
function initialize() { // add map controls to image
map.addControls({
pan: true,
zoom: 'large',
scale: true,
disableDoubleClickZoom: true,
keyboardShortcuts: true,
scrollwheel: false,
map_type: true
});
// create mxn object latlon = new mxn.LatLonPoint(%s, %s);""" % (latitude, longitude)
map = new mxn.Mapstraction('googlev3','googlev3');
// add map controls to image jsc += """
map.addControls({ // put map on page
pan: true, map.setCenterAndZoom(latlon, 10);
zoom: 'large',
scale: true,
disableDoubleClickZoom: true,
keyboardShortcuts: true,
scrollwheel: false,
map_type: true
});
latlon = new mxn.LatLonPoint(%s, %s);""" % (latitude, longitude) var marker;
jsc += """
// put map on page
map.setCenterAndZoom(latlon, 10);
var marker;
// set marker at latitude/ longitude // set marker at latitude/ longitude
marker = new mxn.Marker(latlon); marker = new mxn.Marker(latlon);
// add marker InfoBubble() using place name // add marker InfoBubble() using place name
marker.setInfoBubble('<div id = "geo-info" >%s</div>'); """ % self.page_title marker.setInfoBubble('<div id = "geo-info" >%s</div>'); """ % self.page_title
jsc += """ jsc += """
// add marker to map // add marker to map
map.addMarker(marker, true); map.addMarker(marker, true);
} }"""
//]]>""" # there is no need to add an ending "</script>",
# there is no need to add an ending "</script>", # as it will be added automatically!
# as it will be added automatically!
# googlev3 division # googlev3 division
middle += Html("div", id = "googlev3", inline = True) middle += Html("div", id = "googlev3", inline = True)
# add javascript function call to body element # add javascript function call to body element
body.attr = 'onload = "initialize();"' body.attr = 'onload = "initialize();"'
# source references # source references
srcrefs = self.display_ind_sources(place) srcrefs = self.display_ind_sources(place)
@ -3748,6 +3739,7 @@ class IndividualPage(BasePage):
of = self.report.create_file(person.handle, "ppl") of = self.report.create_file(person.handle, "ppl")
self.up = True self.up = True
indivdetpage, head, body = self.write_header(self.sort_name) indivdetpage, head, body = self.write_header(self.sort_name)
self.familymappages = self.report.options['familymappages']
# begin individualdetail division # begin individualdetail division
with Html("div", class_ = "content", id = 'IndividualDetail') as individualdetail: with Html("div", class_ = "content", id = 'IndividualDetail') as individualdetail:
@ -3831,7 +3823,7 @@ class IndividualPage(BasePage):
individualdetail += sect11 individualdetail += sect11
# create family map link # create family map link
if self.family_map: if self.familymappages:
if len(place_lat_long): if len(place_lat_long):
individualdetail += self.display_ind_family_map(person) individualdetail += self.display_ind_family_map(person)
@ -4567,6 +4559,7 @@ class IndividualPage(BasePage):
return None return None
db = self.report.database db = self.report.database
self.familymappages = self.report.options['familymappages']
# begin parents division # begin parents division
with Html("div", class_ = "subsection", id = "parents") as section: with Html("div", class_ = "subsection", id = "parents") as section:
@ -4606,8 +4599,8 @@ class IndividualPage(BasePage):
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if father_handle: if father_handle:
# get the father's event's places for family map # get the father's event's place for family map
if self.family_map: if self.familymappages:
father = db.get_person_from_handle(father_handle) father = db.get_person_from_handle(father_handle)
_get_event_place(db, father) _get_event_place(db, father)
@ -4622,7 +4615,7 @@ class IndividualPage(BasePage):
if mother_handle: if mother_handle:
# get the mother's event's places for family map # get the mother's event's places for family map
if self.family_map: if self.familymappages:
mother = db.get_person_from_handle(mother_handle) mother = db.get_person_from_handle(mother_handle)
_get_event_place(db, mother) _get_event_place(db, mother)
@ -4642,7 +4635,7 @@ class IndividualPage(BasePage):
if sibling: if sibling:
# add the sibling's event's place for family map # add the sibling's event's place for family map
if self.family_map: if self.familymappages:
for handle in sibling: for handle in sibling:
individual = db.get_person_from_handle(handle) individual = db.get_person_from_handle(handle)
_get_event_place(db, individual) _get_event_place(db, individual)
@ -4841,6 +4834,8 @@ class IndividualPage(BasePage):
return None return None
db = self.report.database db = self.report.database
birthorder = self.report.options['birthorder']
self.familymappages = self.report.options['familymappages']
# begin families division and section title # begin families division and section title
with Html("div", class_ = "subsection", id = "families") as section: with Html("div", class_ = "subsection", id = "families") as section:
@ -4871,13 +4866,13 @@ class IndividualPage(BasePage):
childlist = [child_ref.ref for child_ref in childlist] childlist = [child_ref.ref for child_ref in childlist]
# add individual's children events and places to family map # add individual's children event's place to family map
if self.family_map: if self.familymappages:
for handle in childlist: for handle in childlist:
individual = db.get_person_from_handle(handle) individual = db.get_person_from_handle(handle)
_get_event_place(db, individual) _get_event_place(db, individual)
if self.report.options["birthorder"]: if birthorder:
kids = sorted(add_birthdate(db, childlist)) kids = sorted(add_birthdate(db, childlist))
ordered.extend( ordered.extend(
@ -5435,7 +5430,8 @@ class NavWebReport(Report):
self.inc_addressbook = self.options["inc_addressbook"] self.inc_addressbook = self.options["inc_addressbook"]
# Place Map tab options # Place Map tab options
self.placemaps = self.options["placemaps"] self.placemappages = self.options['placemappages']
self.familymappages = self.options['familymappages']
if self.use_home: if self.use_home:
self.index_fname = "index" self.index_fname = "index"
@ -5616,7 +5612,7 @@ class NavWebReport(Report):
self.copy_file(fname, "Web_Navigation-Menus.css", "styles") self.copy_file(fname, "Web_Navigation-Menus.css", "styles")
# copy Mapstraction style sheet if using Place Maps # copy Mapstraction style sheet if using Place Maps
if self.placemaps or self.family_map: if self.placemappages or self.familymappages:
fname = os.path.join(const.DATA_DIR, "Mapstraction.css") fname = os.path.join(const.DATA_DIR, "Mapstraction.css")
self.copy_file(fname, "mapstraction.css", "styles") self.copy_file(fname, "mapstraction.css", "styles")
@ -5626,7 +5622,7 @@ class NavWebReport(Report):
# copy mapstraction files to mapstraction directory # copy mapstraction files to mapstraction directory
# if PlacePage or IndividualPage maps will be used # if PlacePage or IndividualPage maps will be used
if self.placemaps: if self.placemappages or self.familymappages:
js_files = [ "mxn.core.js", "mxn.geocommons.core.js", "mxn.google.core.js", js_files = [ "mxn.core.js", "mxn.geocommons.core.js", "mxn.google.core.js",
"mxn.google.geocoder.js", "mxn.googlev3.core.js", "mxn.google.geocoder.js", "mxn.googlev3.core.js",
"mxn.js", "mxn.openlayers.core.js" ] "mxn.js", "mxn.openlayers.core.js" ]
@ -6486,25 +6482,18 @@ class NavWebOptions(MenuReportOptions):
category_name = _("Place Map Options") category_name = _("Place Map Options")
self.__placemaps = BooleanOption(_("Add Place Maps to Report"), False) placemappages = BooleanOption(_("Include Place map on Place Pages"), False)
self.__placemaps.set_help(_("Whether to add place maps to this report")) placemappages.set_help(_("Whether to include a place map on the Place Pages, "
menu.add_option(category_name, "placemaps", self.__placemaps) "where Latitude/ Longitude are available."))
self.__placemaps.connect("value-changed", self._place_maps_changed) menu.add_option(category_name, "placemappages", placemappages)
self.__place_page = BooleanOption(_("Include Place map on Place Pages"), False) familymappages = BooleanOption(_("Include Individual Page Map with "
self.__place_page.set_help(_("Whether to include a place map on the Place Pages, " "all places shown on map"), False)
"where Latitude/ Longitude are available.")) familymappages.set_help(_("Whether to add an individual page map with "
menu.add_option(category_name, "place_page", self.__place_page)
self.__family_map = BooleanOption(_("Include Individual Page Map with "
"all places shown on map"), False)
self.__family_map.set_help(_("Whether to add an individual page map with "
"all the places on this page shown or not? " "all the places on this page shown or not? "
"This will allow you to see how your family " "This will allow you to see how your family "
"travelled around the country.")) "travelled around the country."))
menu.add_option(category_name, "family_map", self.__family_map) menu.add_option(category_name, "familymappages", familymappages)
self._place_maps_changed()
def __archive_changed(self): def __archive_changed(self):
""" """
@ -6594,16 +6583,6 @@ class NavWebOptions(MenuReportOptions):
self.__dl_descr2.set_available(False) self.__dl_descr2.set_available(False)
self.__dl_cright.set_available(False) self.__dl_cright.set_available(False)
def _place_maps_changed(self):
""" handles the changing nature of place maps """
if self.__placemaps.get_value():
self.__place_page.set_available(True)
self.__family_map.set_available(True)
else:
self.__place_page.set_available(False)
self.__family_map.set_available(False)
# FIXME. Why do we need our own sorting? Why not use Sort.Sort? # FIXME. Why do we need our own sorting? Why not use Sort.Sort?
def sort_people(db, handle_list): def sort_people(db, handle_list):
sname_sub = defaultdict(list) sname_sub = defaultdict(list)