From 4e0d56220896ece6e59bf585b8344888e5cb4ec0 Mon Sep 17 00:00:00 2001 From: Serge Noiraud Date: Thu, 23 Nov 2017 09:40:52 +0100 Subject: [PATCH] Various Feature Requests in Narrative Web (#468) Issue #06772 --- gramps/plugins/webreport/basepage.py | 27 ++++++++++++++++++------ gramps/plugins/webreport/narrativeweb.py | 22 ++++++++++++++++++- gramps/plugins/webreport/person.py | 12 +++++------ 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/gramps/plugins/webreport/basepage.py b/gramps/plugins/webreport/basepage.py index 3bf9f2b04..21742df5b 100644 --- a/gramps/plugins/webreport/basepage.py +++ b/gramps/plugins/webreport/basepage.py @@ -57,8 +57,9 @@ import logging # Gramps module #------------------------------------------------ from gramps.gen.const import GRAMPS_LOCALE as glocale -from gramps.gen.lib import (FamilyRelType, NoteType, NameType, Person, UrlType, - Name, PlaceType, EventRoleType, Family, Citation) +from gramps.gen.lib import (FamilyRelType, NoteType, NameType, Person, + UrlType, Date, Name, PlaceType, EventRoleType, + Family, Citation) from gramps.gen.lib.date import Today from gramps.gen.const import PROGRAM_NAME, URL_HOMEPAGE from gramps.version import VERSION @@ -72,6 +73,7 @@ from gramps.gen.display.name import displayer as _nd from gramps.gen.display.place import displayer as _pd from gramps.plugins.lib.libhtmlconst import _CC from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback +from gramps.gen.datehandler import parser as _dp from gramps.plugins.lib.libhtml import Html, xml_lang from gramps.plugins.lib.libhtmlbackend import HtmlBackend, process_spaces from gramps.gen.utils.place import conv_lat_lon @@ -1491,8 +1493,8 @@ class BasePage: # pylint: disable=C1001 (self.report.surname_fname, self._("Surnames"), True), ('families', self._("Families"), self.report.inc_families), ('events', self._("Events"), self.report.inc_events), - ('places', self._("Places"), True), - ('sources', self._("Sources"), True), + ('places', self._("Places"), self.report.inc_places), + ('sources', self._("Sources"), self.report.inc_sources), ('repositories', self._("Repositories"), inc_repos), ('media', self._("Media"), _create_media_link), ('thumbnails', self._("Thumbnails"), self.create_media), @@ -2747,7 +2749,10 @@ class BasePage: # pylint: disable=C1001 elif obj[2] == "Family": role = "1" else: - role = "3" + if len(obj[2].split('-')) > 1: + role = obj[2] # date in ISO format + else: + role = "3" return role for (bkref_class, bkref_handle, role) in sorted( @@ -2758,7 +2763,17 @@ class BasePage: # pylint: disable=C1001 name = self.report.obj_dict[bkref_class][bkref_handle][1] gid = self.report.obj_dict[bkref_class][bkref_handle][2] if role != "": - role = self._(" (%s) " % self._(role)) + if len(role.split('-')) > 1: + # conver ISO date to Date for translation. + if len(role.split(' - ')) > 1: + (d1, d2) = role.split(' - ') + role = self._("between") + " " + d1 + " " + role += self._("and") + " " + d2 + date = _dp.parse(role) + date = self.rlocale.get_date(date) + role = " (%s) " % date + else: + role = " (%s) " % self._(role) ordered += list_html if path == "": list_html += name diff --git a/gramps/plugins/webreport/narrativeweb.py b/gramps/plugins/webreport/narrativeweb.py index 3e63d9d83..99804e2eb 100644 --- a/gramps/plugins/webreport/narrativeweb.py +++ b/gramps/plugins/webreport/narrativeweb.py @@ -175,6 +175,12 @@ class NavWebReport(Report): # create an event pages or not? self.inc_events = self.options['inc_events'] + # create places pages or not? + self.inc_places = self.options['inc_places'] + + # create sources pages or not? + self.inc_sources = self.options['inc_sources'] + # include repository page or not? self.inc_repository = self.options['inc_repository'] @@ -814,12 +820,16 @@ class NavWebReport(Report): place_name = _pd.display_event(self._db, event) else: place_name = place.get_title() + if event: + role_or_date = str(event.get_date_object()) + else: + role_or_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, event) self.bkref_dict[Place][place_handle].add((bkref_class, bkref_handle, - "" # no role for a place + role_or_date )) ############### Media section ############## @@ -1931,6 +1941,16 @@ class NavWebOptions(MenuReportOptions): _('Add a complete events list and relevant pages or not')) addopt("inc_events", inc_events) + inc_places = BooleanOption(_('Include places pages'), False) + inc_places.set_help( + _('Whether or not to include the places Pages.')) + addopt("inc_places", inc_places) + + inc_sources = BooleanOption(_('Include sources pages'), False) + inc_sources.set_help( + _('Whether or not to include the sources Pages.')) + addopt("inc_sources", inc_sources) + inc_repository = BooleanOption(_('Include repository pages'), False) inc_repository.set_help( _('Whether or not to include the Repository Pages.')) diff --git a/gramps/plugins/webreport/person.py b/gramps/plugins/webreport/person.py index f506c4be5..4cd0041fb 100644 --- a/gramps/plugins/webreport/person.py +++ b/gramps/plugins/webreport/person.py @@ -478,6 +478,12 @@ class PersonPages(BasePage): individualdetail += thumbnail individualdetail += (name, summary) + # display Narrative Notes + notelist = person.get_note_list() + sect8 = self.display_note_list(notelist) + if sect8 is not None: + individualdetail += sect8 + # display a person's events sect2 = self.display_ind_events(place_lat_long) if sect2 is not None: @@ -538,12 +544,6 @@ class PersonPages(BasePage): if sect7 is not None: individualdetail += sect7 - # display Narrative Notes - notelist = person.get_note_list() - sect8 = self.display_note_list(notelist) - if sect8 is not None: - individualdetail += sect8 - # display attributes attrlist = person.get_attribute_list() if attrlist: