diff --git a/gramps/plugins/webreport/narrativeweb.py b/gramps/plugins/webreport/narrativeweb.py index 31762b08c..bfabf748a 100644 --- a/gramps/plugins/webreport/narrativeweb.py +++ b/gramps/plugins/webreport/narrativeweb.py @@ -129,6 +129,7 @@ from gramps.gen.display.place import displayer as _pd from gramps.gen.datehandler import displayer as _dd from gramps.gen.proxy import LivingProxyDb from gramps.plugins.lib.libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS +from gramps.gen.datehandler import get_date # import HTML Class from src/plugins/lib/libhtml.py from gramps.plugins.lib.libhtml import Html, xml_lang @@ -141,7 +142,7 @@ from gramps.gen.utils.place import conv_lat_lon from gramps.gen.plug import BasePluginManager from gramps.gen.relationship import get_relationship_calculator -from gramps.gen.utils.location import get_main_location +from gramps.gen.utils.location import get_main_location, get_location_list COLLATE_LANG = glocale.collation SORT_KEY = glocale.sort_key @@ -391,6 +392,7 @@ THEAD = _("Type") TEMPLE = _("Temple") VHEAD = _("Value") ALT_LOCATIONS = _("Alternate Locations") +LOCATIONS = _("Locations") _UNKNOWN = _("Unknown") _ABSENT = _("") @@ -502,7 +504,7 @@ def get_gendex_data(database, event_ref): if place_handle: place = database.get_place_from_handle(place_handle) if place: - poe = _pd.display(database, place) + poe = _pd.display(database, place, date) return doe, poe def format_date(date): @@ -1210,7 +1212,7 @@ class BasePage(object): place_hyper = None if place: - place_name = ReportUtils.place_name(self.dbase_, place_handle) + place_name = _pd.display(self.dbase_, place, evt.get_date_object()) place_hyper = self.place_link(place_handle, place_name, uplink = up) evt_desc = evt.get_description() @@ -2035,7 +2037,7 @@ class BasePage(object): _linkurl = self.report.build_url_fname_html(_obj.handle, "evt", True) elif classname == "Place": _obj = self.dbase_.get_place_from_handle(newhandle) - _name = ReportUtils.place_name(self.dbase_, newhandle) + _name = _pd.display(self.dbase_, _obj) if not _name: _name = _UNKNOWN _linkurl = self.report.build_url_fname_html(newhandle, "plc", True) @@ -2627,6 +2629,9 @@ class BasePage(object): @param: place -- place object from the database @param: table -- table from Placedetail """ + if place in self.visited: + return + self.visited.append(place) # add table body tbody = Html("tbody") table += tbody @@ -2696,6 +2701,19 @@ class BasePage(object): tbody += trow tbody += Html("tr") + Html("td", " ", colspan = 2) + # display all related locations + for placeref in place.get_placeref_list(): + place_date = get_date(placeref) + if place_date != "": + parent_place = self.db.get_place_from_handle(placeref.ref) + parent_name = parent_place.get_name().get_value() + trow = Html('tr') + ( + Html("td", LOCATIONS, class_ = "ColumnAttribute", inline =True), + Html("td", parent_name, class_ = "ColumnValue", inline = True), + Html("td", place_date, class_ = "ColumnValue", inline = True) + ) + tbody += trow + # return place table to its callers return table @@ -3323,6 +3341,7 @@ class PlacePages(BasePage): self.report = report self.db = report.database self.place_dict = defaultdict(set) + self.visited = [] def display_pages(self, title): """ @@ -3394,18 +3413,22 @@ class PlacePages(BasePage): ) handle_list = sorted(place_handles, - key=lambda x: SORT_KEY(ReportUtils.place_name(self.dbase_, x))) + key=lambda x: SORT_KEY(ReportUtils.place_name(self.dbase_, + x[:x.index(':')]))) first = True # begin table body tbody = Html("tbody") table += tbody - for place_handle in handle_list: + for place_handle_key in handle_list: + event_date = self.report.obj_dict[Place][place_handle_key][4] + place_handle = self.report.obj_dict[Place][place_handle_key][0] + place_name = self.report.obj_dict[Place][place_handle_key][2] place = self.dbase_.get_place_from_handle(place_handle) if place: if place.get_change_time() > ldatec: ldatec = place.get_change_time() - place_title = _pd.display(self.dbase_, place) + place_title = _pd.display(self.dbase_, place, event_date) ml = get_main_location(self.dbase_, place) if place_title and not place_title.isspace(): @@ -3463,9 +3486,14 @@ class PlacePages(BasePage): # and close the file self.XHTMLWriter(placelistpage, of, sio, ldatec) - def PlacePage(self, report, title, place_handle): + def PlacePage(self, report, title, key): self.bibli = Bibliography() self.dbase_ = report.database + place_handle = self.report.obj_dict[Place][key][0] + place_fname = self.report.obj_dict[Place][key][1] + place_name = self.report.obj_dict[Place][key][2] + place_id = self.report.obj_dict[Place][key][3] + event_date = self.report.obj_dict[Place][key][4] place = self.dbase_.get_place_from_handle(place_handle) if not place: return None @@ -3474,7 +3502,7 @@ class PlacePages(BasePage): of, sio = self.report.create_file(place_handle, "plc") self.up = True - self.page_title = _pd.display(self.dbase_, place) + self.page_title = _pd.display(self.dbase_, place, event_date) placepage, head, body = self.write_header(_("Places")) self.placemappages = self.report.options['placemappages'] @@ -3491,7 +3519,7 @@ class PlacePages(BasePage): placedetail += thumbnail # add section title - placedetail += Html("h3", html_escape(self.page_title), inline =True) + placedetail += Html("h3", html_escape(place.get_name().get_value()), inline =True) # begin summaryarea division and places table with Html("div", id ='summaryarea') as summaryarea: @@ -3523,7 +3551,7 @@ class PlacePages(BasePage): if self.placemappages: if (place and (place.lat and place.long)): latitude, longitude = conv_lat_lon(place.get_latitude(), place.get_longitude(), "D.D8") - placetitle = _pd.display(self.dbase_, place) + placetitle = place_name # add narrative-maps CSS... fname = "/".join(["css", "narrative-maps.css"]) @@ -7274,7 +7302,7 @@ class NavWebReport(Report): self._add_event(evt_ref.ref, Person, person_handle) place_handle = event.get_place_handle() if place_handle: - self._add_place(place_handle, Person, person_handle) + self._add_place(place_handle, Person, person_handle, event.get_date_object()) # If event pages are not being output, then tell the # media tab to display the perosn's event media. If # events are being displayed, then the media are linked @@ -7306,7 +7334,7 @@ class NavWebReport(Report): self._add_event(evt_ref.ref, Person, person_handle) place_handle = event.get_place_handle() if place_handle: - self._add_place(place_handle, Person, person_handle) + self._add_place(place_handle, Person, person_handle, event.get_date_object()) for citation_handle in event.get_citation_list(): self._add_citation( citation_handle, Person, person_handle) @@ -7354,7 +7382,6 @@ class NavWebReport(Report): media_handle = media_ref.get_reference_handle() self._add_media(media_handle, Person, person_handle) - def get_person_name(self, person): """ Return a string containing the person's primary name in the name @@ -7391,7 +7418,7 @@ class NavWebReport(Report): event = self.database.get_event_from_handle(evt_ref.ref) place_handle = event.get_place_handle() if place_handle: - self._add_place(place_handle, Family, family_handle) + self._add_place(place_handle, Family, family_handle, event.get_date_object()) if self.inc_events: # detail for family events are displayed on the events pages as @@ -7486,15 +7513,15 @@ class NavWebReport(Report): media_handle = media_ref.get_reference_handle() self._add_media(media_handle, Event, event_handle) - def _add_place(self, place_handle, bkref_class, bkref_handle): + def _add_place(self, place_handle, bkref_class, bkref_handle, date): place = self.database.get_place_from_handle(place_handle) if place is None: return - place_name = _pd.display(self.database, place) + place_name = _pd.display(self.database, place, date) place_fname = self.build_url_fname(place_handle, "plc", False) + self.ext - self.obj_dict[Place][place_handle] = (place_fname, place_name, - place.gramps_id) + self.obj_dict[Place][place_handle+":"+place_name] = (place_handle, place_fname, place_name, + place.gramps_id, date) self.bkref_dict[Place][place_handle].add((bkref_class, bkref_handle)) ############### Media section ############## @@ -8843,7 +8870,8 @@ def get_first_letters(dbase, handle_list, key): keyname = __get_person_keyname(dbase, handle) elif key == _KEYPLACE: - keyname = __get_place_keyname(dbase, handle) + real_handle = handle[:handle.index(':')] + keyname = __get_place_keyname(dbase, real_handle) else: keyname = handle