From 25a7416f8a01c7d9809821756c8aa8e3d4f69d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Charette?= Date: Thu, 19 Jul 2007 06:45:25 +0000 Subject: [PATCH] several fixes and feature requests for NarrativeWeb, including optional columns, half-siblings, and event notes svn: r8745 --- ChangeLog | 6 + src/plugins/NarrativeWeb.py | 352 +++++++++++++++++++++++++++++++++--- 2 files changed, 329 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac599816d..d9a574a7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-07-18 Stephane Charette + * src/plugins/NarrativeWeb.py: added several new optional columns; + added optional link to home person; show half-siblings on individual + pages; display events notes just below the event; created a new + "Advanced Options" tab to toggle all of these optional items + 2007-07-18 Alex Roitman * TODO: Update. diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index 2a827eb66..6d51c88c9 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -147,6 +147,12 @@ class BasePage: self.encoding = options.handler.options_dict['NWEBencoding'] self.css = options.handler.options_dict['NWEBcss'] self.noid = options.handler.options_dict['NWEBnoid'] + self.linkhome = options.handler.options_dict['NWEBlinkhome'] + self.showbirth = options.handler.options_dict['NWEBshowbirth'] + self.showdeath = options.handler.options_dict['NWEBshowdeath'] + self.showspouse = options.handler.options_dict['NWEBshowspouse'] + self.showparents = options.handler.options_dict['NWEBshowparents'] + self.showhalfsiblings = options.handler.options_dict['NWEBshowhalfsiblings'] self.use_intro = options.handler.options_dict['NWEBintronote'] != u"" self.use_contact = options.handler.options_dict['NWEBcontact'] != u"" self.use_gallery = options.handler.options_dict['NWEBgallery'] @@ -322,6 +328,16 @@ class BasePage: msg = _('Generated by ' 'GRAMPS on %(date)s') % { 'date' : value } + if self.linkhome: + home_person_handle = db.get_default_handle() + if home_person_handle: + home_person = db.get_default_person() + home_person_url = self.build_name( + self.build_path(home_person_handle, "ppl", up), + home_person.handle) + home_person_name = home_person.get_primary_name().get_regular_name() + msg += _('
for %s') % (home_person_url, home_person_name) + of.write('\n' % msg) of.write('

%s

\n' % self.title_str) of.write('\n') except (IOError,OSError),msg: WarningDialog(_("Could not add photo to page"),str(msg)) - + notelist = obj.get_note_list() if notelist: note_obj = db.get_note_from_handle(notelist[0]) @@ -1109,7 +1289,7 @@ class IntroductionPage(BasePage): of.write('
\n%s\n
\n' % text) else: of.write('

') - of.write('

'.join(text.split('\n'))) + of.write('
'.join(text.split('\n'))) of.write('

') self.display_footer(of,db) @@ -1400,7 +1580,7 @@ class ContactPage(BasePage): if format: text = u"
%s
" % text else: - text = u"

".join(text.split("\n")) + text = u"
".join(text.split("\n")) of.write('

%s

\n' % text) of.write('\n') @@ -1849,6 +2029,7 @@ class IndividualPage(BasePage): # Get the mother and father relationships frel = "" mrel = "" + sibling = set() child_handle = self.person.get_handle() child_ref_list = ReportUtils.sanitize_list( family.get_child_ref_list(), self.exclude_private ) @@ -1872,6 +2053,7 @@ class IndividualPage(BasePage): of.write('\n') self.display_parent(of,mother_handle,_('Mother'),mrel) of.write('\n') + first = False if len(child_ref_list) > 1: of.write('\n') @@ -1879,9 +2061,53 @@ class IndividualPage(BasePage): of.write('\n') for child_ref in child_ref_list: child_handle = child_ref.ref + sibling.add(child_handle) # remember that we've already "seen" this child if child_handle != self.person.handle: self.display_child_link(of,child_handle) of.write('\n\n') + + # Also try to identify half-siblings + other_siblings = set() + + # if we have a known father... + if father_handle and self.showhalfsiblings: + # 1) get all of the families in which this father is involved + # 2) get all of the children from those families + # 3) if the children are not already listed as siblings... + # 4) then remember those children since we're going to list them + father = self.db.get_person_from_handle(father_handle) + for family_handle in father.get_family_handle_list(): + family = self.db.get_family_from_handle(family_handle) + step_child_ref_list = ReportUtils.sanitize_list(family.get_child_ref_list(), self.exclude_private) + for step_child_ref in step_child_ref_list: + step_child_handle = step_child_ref.ref + if step_child_handle not in sibling: + if step_child_handle != self.person.handle: + # we have a new step/half sibling + other_siblings.add(step_child_ref.ref) + + # do the same thing with the mother (see "father" just above): + if mother_handle and self.showhalfsiblings: + mother = self.db.get_person_from_handle(mother_handle) + for family_handle in mother.get_family_handle_list(): + family = self.db.get_family_from_handle(family_handle) + step_child_ref_list = ReportUtils.sanitize_list(family.get_child_ref_list(), self.exclude_private) + for step_child_ref in step_child_ref_list: + step_child_handle = step_child_ref.ref + if step_child_handle not in sibling: + if step_child_handle != self.person.handle: + # we have a new step/half sibling + other_siblings.add(step_child_ref.ref) + + # now that we have all of the step-siblings/half-siblings, print them out + if len(other_siblings) > 0: + of.write('\n') + of.write('%s\n' % _("Half Siblings")) + of.write('\n') + for child_handle in other_siblings: + self.display_child_link(of, child_handle) + of.write('\n\n') + of.write(' \n') of.write('\n') of.write('\n') @@ -1986,7 +2212,7 @@ class IndividualPage(BasePage): if format: of.write( u"
%s
" % text ) else: - of.write( u"

".join(text.split("\n"))) + of.write( u"
".join(text.split("\n"))) of.write('\n\n') def pedigree_person(self,of,person,is_spouse=False): @@ -2059,6 +2285,22 @@ class IndividualPage(BasePage): else: text = '\n' text += self.get_citation_links( event.get_source_references() ) + + # if the event has a note attached to it, get the text and format it correctly + notelist = event.get_note_list() + for notehandle in notelist: + nobj = self.db.get_note_from_handle(notehandle) + if nobj: + note_text = nobj.get(markup=True) + format = nobj.get_format() + if note_text: + if format: + text += u"

%s
" % note_text + else: + text += u"

" + text += u"
".join(note_text.split("\n")) + text += u"

" + return text def get_citation_links(self, source_ref_list): @@ -2123,6 +2365,12 @@ class WebReport(Report): NWEBintronote NWEBhomenote NWEBnoid + NWEBlinkhome + NWEBshowbirth + NWEBshowdeath + NWEBshowspouse + NWEBshowparents + NWEBshowhalfsiblings """ self.database = database @@ -2142,6 +2390,12 @@ class WebReport(Report): self.restrict_years = options.handler.options_dict['NWEBrestrictyears'] self.exclude_private = not options.handler.options_dict['NWEBincpriv'] self.noid = options.handler.options_dict['NWEBnoid'] + self.linkhome = options.handler.options_dict['NWEBlinkhome'] + self.showbirth = options.handler.options_dict['NWEBshowbirth'] + self.showdeath = options.handler.options_dict['NWEBshowdeath'] + self.showspouse = options.handler.options_dict['NWEBshowspouse'] + self.showparents = options.handler.options_dict['NWEBshowparents'] + self.showhalfsiblings = options.handler.options_dict['NWEBshowhalfsiblings'] self.title = options.handler.options_dict['NWEBtitle'] self.sort = Sort.Sort(self.database) self.inc_gallery = options.handler.options_dict['NWEBgallery'] @@ -2298,7 +2552,10 @@ class WebReport(Report): def person_pages(self, ind_list, restrict_list, place_list, source_list, archive): - self.progress.set_pass(_('Creating individual pages'),len(ind_list)) + self.progress.set_pass(_('Creating individual pages'),len(ind_list) + 1) + self.progress.step() # otherwise the progress indicator sits at 100% + # for a short while from the last step we did, + # which was to apply the privacy filter IndividualListPage( self.database, self.title, ind_list, restrict_list, @@ -2459,6 +2716,12 @@ class WebReportOptions(ReportOptions): 'NWEBincpriv' : 0, 'NWEBnonames' : 0, 'NWEBnoid' : 0, + 'NWEBlinkhome' : 0, + 'NWEBshowbirth' : 1, + 'NWEBshowdeath' : 0, + 'NWEBshowspouse' : 0, + 'NWEBshowparents' : 0, + 'NWEBshowhalfsiblings' : 0, 'NWEBcontact' : '', 'NWEBgallery' : 1, 'NWEBheader' : '', @@ -2537,6 +2800,24 @@ class WebReportOptions(ReportOptions): self.inc_download = gtk.CheckButton(download_msg) self.inc_download.set_active(self.options_dict['NWEBdownload']) + self.linkhome = gtk.CheckButton(_('Include link to home person on every page')) + self.linkhome.set_active(self.options_dict['NWEBlinkhome']) + + self.showbirth = gtk.CheckButton(_('Include a column for birth dates on the index pages')) + self.showbirth.set_active(self.options_dict['NWEBshowbirth']) + + self.showdeath = gtk.CheckButton(_('Include a column for death dates on the index pages')) + self.showdeath.set_active(self.options_dict['NWEBshowdeath']) + + self.showspouse = gtk.CheckButton(_('Include a column for partners on the index pages')) + self.showspouse.set_active(self.options_dict['NWEBshowspouse']) + + self.showparents = gtk.CheckButton(_('Include a column for parents on the index pages')) + self.showparents.set_active(self.options_dict['NWEBshowparents']) + + self.showhalfsiblings = gtk.CheckButton(_('Include half-brothers and half-sisters as siblings')) + self.showhalfsiblings.set_active(self.options_dict['NWEBshowhalfsiblings']) + # FIXME: document this: # 0 -- no images of any kind # 1 -- no living images, but some images @@ -2604,7 +2885,6 @@ class WebReportOptions(ReportOptions): title = _("Page Generation") - media_list = [['','']] html_list = [['','']] @@ -2644,6 +2924,14 @@ class WebReportOptions(ReportOptions): dialog.add_frame_option(title,None,self.restrict_living) dialog.add_frame_option(title,None,self.hbox) + title = _("Advanced Options") + dialog.add_frame_option(title,None,self.linkhome,) + dialog.add_frame_option(title,None,self.showbirth) + dialog.add_frame_option(title,None,self.showdeath) + dialog.add_frame_option(title,None,self.showspouse) + dialog.add_frame_option(title,None,self.showparents) + dialog.add_frame_option(title,None,self.showhalfsiblings) + def restrict_toggled(self,obj): self.restrict_years.set_sensitive(obj.get_active()) @@ -2657,6 +2945,12 @@ class WebReportOptions(ReportOptions): self.options_dict['NWEBincpriv'] = int(not self.no_private.get_active()) self.options_dict['NWEBnoid'] = int(self.noid.get_active()) self.options_dict['NWEBcontact'] = unicode(self.contact.get_handle()) + self.options_dict['NWEBlinkhome'] = int(self.linkhome.get_active()) + self.options_dict['NWEBshowbirth'] = int(self.showbirth.get_active()) + self.options_dict['NWEBshowdeath'] = int(self.showdeath.get_active()) + self.options_dict['NWEBshowspouse'] = int(self.showspouse.get_active()) + self.options_dict['NWEBshowparents'] = int(self.showparents.get_active()) + self.options_dict['NWEBshowhalfsiblings'] = int(self.showhalfsiblings.get_active()) self.options_dict['NWEBgallery'] = int(self.include_gallery.get_active()) self.options_dict['NWEBheader'] = unicode(self.header.get_handle()) self.options_dict['NWEBfooter'] = unicode(self.footer.get_handle())