diff --git a/ChangeLog b/ChangeLog index c5ffd5c06..f7392aab6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-10-26 Stéphane Charette + * src/plugins/NarrativeWeb.py: various: EOL should be
not

, + date is now displayed in the user's locale, source references no + longer skipped on media pages, allow half-sibling to be shown, allow + columns to be configurable, event notes are no longer skipped, progress + indicator no longer gets stuck at 100% for long periods of time with + large databases + 2007-10-26 Benny Malengier * src/plugins/rel_nl.py: various improvements diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index 06c6f5e45..1d698d609 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -74,6 +74,7 @@ import Errors import Utils import ImgManip import GrampsLocale +import DateHandler from QuestionDialog import ErrorDialog, WarningDialog from NameDisplay import displayer as _nd from DateHandler import displayer as _dd @@ -147,6 +148,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'] @@ -158,7 +165,7 @@ class BasePage: self.graphgens = options.handler.options_dict['NWEBgraphgens'] self.use_home = self.options.handler.options_dict['NWEBhomenote'] != "" self.page_title = "" - self.warn_dir = True + self.warn_dir = True def store_file(self,archive,html_dir,from_path,to_path): if archive: @@ -316,12 +323,22 @@ class BasePage: of.write(' \n') of.write('

\n') + def display_source_refs(self,of,db,sreflist): + if not sreflist: + return + of.write('
\n') + of.write('

%s

\n' % _('Source References')) + of.write('\n') + + index = 1 + for sref in sreflist: + lnk = (self.cur_name, self.page_title, self.gid) + shandle = sref.get_reference_handle() + if not shandle: + continue + if self.src_list.has_key(shandle): + if lnk not in self.src_list[shandle]: + self.src_list[shandle].append(lnk) + else: + self.src_list[shandle] = [lnk] + + source = self.db.get_source_from_handle(shandle) + title = source.get_title() + of.write('' % (index,index)) + of.write('\n') + index += 1 + of.write('
') + of.write('%d.') + self.source_link(of,source.handle,title,source.gramps_id,True) + tmp = [] + confidence = Utils.confidence.get(sref.confidence, _('Unknown')) + for (label,data) in [(_('Date'),_dd.display(sref.date)), + (_('Page'),sref.page), + (_('Confidence'),confidence), + (_('Text'),sref.text)]: + if data: + tmp.append("%s: %s" % (label,data)) + if len(tmp) > 0: + of.write('
' + '
'.join(tmp)) + of.write('
\n') + of.write('
\n') + def display_references(self,of,db,handlelist): if not handlelist: return @@ -602,37 +661,123 @@ class IndividualListPage(BasePage): of.write('\n\n') of.write('\n' % _('Surname')) of.write('\n' % _('Name')) - of.write('\n' % _('Birth date')) + column_count = 2 + if self.showbirth: + of.write('\n' % _('Birth')) + column_count += 1 + if self.showdeath: + of.write('\n' % _('Death')) + column_count += 1 + if self.showspouse: + of.write('\n' % _('Partner')) + column_count += 1 + if self.showparents: + of.write('\n' % _('Parents')) + column_count += 1 of.write('\n\n') person_handle_list = sort_people(db,person_handle_list) for (surname,handle_list) in person_handle_list: first = True - of.write('\n') + of.write('\n' % column_count) for person_handle in handle_list: person = db.get_person_from_handle(person_handle) if self.exclude_private: person = ReportUtils.sanitize_person(db,person) + + # surname column of.write('') + + # firstname column + of.write('') - if person.handle in restrict_list: - of.write(_('restricted')) - else: - birth_ref = person.get_birth_ref() - if birth_ref: - birth = db.get_event_from_handle(birth_ref.ref) - of.write(_dd.display(birth.get_date_object())) - of.write('\n') + # birth column + if self.showbirth: + of.write('') + + # death column + if self.showdeath: + of.write('') + + # spouse (partner) column + if self.showspouse: + of.write('') + + # parents column + if self.showparents: + of.write('') + + # finished writing all columns + of.write('\n') first = False of.write('\n
%s%s%s%s%s%s%s
 
 
') if first: of.write('%s' % (self.lnkfmt(surname),surname)) else: of.write(' ') - of.write('') + of.write('') path = self.build_path(person.handle,"ppl",False) self.person_link(of, self.build_name(path,person.handle), _nd.display_given(person), person.gramps_id,False) - of.write('') + of.write('
') + if person.handle in restrict_list: + of.write(_('restricted')) + else: + birth_ref = person.get_birth_ref() + if birth_ref: + birth = db.get_event_from_handle(birth_ref.ref) + of.write(_dd.display(birth.get_date_object())) + of.write('') + if person.handle in restrict_list: + of.write(_('restricted')) + else: + death_ref = person.get_death_ref() + if death_ref: + death = db.get_event_from_handle(death_ref.ref) + of.write(_dd.display(death.get_date_object())) + of.write('') + if person.handle in restrict_list: + of.write(_('restricted')) + else: + family_list = person.get_family_handle_list() + first_family = True + spouse_name = None + if family_list: + for family_handle in family_list: + family = db.get_family_from_handle(family_handle) + spouse_id = ReportUtils.find_spouse(person, family) + if spouse_id: + spouse = db.get_person_from_handle(spouse_id) + if self.exclude_private: + spouse = ReportUtils.sanitize_person(db, spouse) + spouse_name = spouse.get_primary_name().get_regular_name() + if not first_family: + of.write(', ') + of.write('%s' % spouse_name) + first_family = False + of.write('') + parent_handle_list = person.get_parent_family_handle_list() + if parent_handle_list: + parent_handle = parent_handle_list[0] + family = db.get_family_from_handle(parent_handle) + father_name = '' + mother_name = '' + father_id = family.get_father_handle() + mother_id = family.get_mother_handle() + father = db.get_person_from_handle(father_id) + mother = db.get_person_from_handle(mother_id) + if father and self.exclude_private: + father = ReportUtils.sanitize_person(db, father) + father_name = father.get_primary_name().get_regular_name() + if mother and self.exclude_private: + mother = ReportUtils.sanitize_person(db, mother) + mother_name = mother.get_primary_name().get_regular_name() + if mother and father: + of.write('%s, %s' % (father_name, mother_name)) + elif mother: + of.write('%s' % mother_name) + elif father: + of.write('%s' % father_name) + of.write('
\n') @@ -662,10 +807,19 @@ class SurnamePage(BasePage): of.write('

%s

\n' % msg) of.write('\n\n') of.write('\n' % _('Name')) - of.write('\n' % _('Birth date')) + if self.showbirth: + of.write('\n' % _('Birth')) + if self.showdeath: + of.write('\n' % _('Death')) + if self.showspouse: + of.write('\n' % _('Partner')) + if self.showparents: + of.write('\n' % _('Parents')) of.write('\n\n') for person_handle in person_handle_list: + + # firstname column person = db.get_person_from_handle(person_handle) if self.exclude_private: person = ReportUtils.sanitize_person(db,person) @@ -674,16 +828,85 @@ class SurnamePage(BasePage): self.person_link(of, self.build_name(path,person.handle), person.get_primary_name().get_first_name(), person.gramps_id,False) - of.write('\n') + of.write('') + + # birth column + if self.showbirth: + of.write('') + + # death column + if self.showdeath: + of.write('') + + # spouse (partner) column + if self.showspouse: + of.write('') + + # parents column + if self.showparents: + of.write('') + + # finished writing all columns + of.write('\n') of.write('\n
%s%s%s%s%s%s
') - if person.handle in restrict_list: - of.write(_('restricted')) - else: - birth_ref = person.get_birth_ref() - if birth_ref: - birth = db.get_event_from_handle(birth_ref.ref) - birth_date = _dd.display(birth.get_date_object()) - of.write(birth_date) - of.write('
') + if person.handle in restrict_list: + of.write(_('restricted')) + else: + birth_ref = person.get_birth_ref() + if birth_ref: + birth = db.get_event_from_handle(birth_ref.ref) + of.write(_dd.display(birth.get_date_object())) + of.write('') + if person.handle in restrict_list: + of.write(_('restricted')) + else: + death_ref = person.get_death_ref() + if death_ref: + death = db.get_event_from_handle(death_ref.ref) + of.write(_dd.display(death.get_date_object())) + of.write('') + if person.handle in restrict_list: + of.write(_('restricted')) + else: + family_list = person.get_family_handle_list() + first_family = True + spouse_name = None + if family_list: + for family_handle in family_list: + family = db.get_family_from_handle(family_handle) + spouse_id = ReportUtils.find_spouse(person, family) + if spouse_id: + spouse = db.get_person_from_handle(spouse_id) + if self.exclude_private: + spouse = ReportUtils.sanitize_person(db, spouse) + spouse_name = spouse.get_primary_name().get_regular_name() + if not first_family: + of.write(', ') + of.write('%s' % spouse_name) + first_family = False + of.write('') + parent_handle_list = person.get_parent_family_handle_list() + if parent_handle_list: + parent_handle = parent_handle_list[0] + family = db.get_family_from_handle(parent_handle) + father_name = '' + mother_name = '' + father_id = family.get_father_handle() + mother_id = family.get_mother_handle() + father = db.get_person_from_handle(father_id) + mother = db.get_person_from_handle(mother_id) + if father and self.exclude_private: + father = ReportUtils.sanitize_person(db, father) + father_name = father.get_primary_name().get_regular_name() + if mother and self.exclude_private: + mother = ReportUtils.sanitize_person(db, mother) + mother_name = mother.get_primary_name().get_regular_name() + if mother and father: + of.write('%s, %s' % (father_name, mother_name)) + elif mother: + of.write('%s' % mother_name) + elif father: + of.write('%s' % father_name) + of.write('
\n') self.display_footer(of,db) self.close_file(of) @@ -922,10 +1145,17 @@ class MediaPage(BasePage): self.display_note_object(of, photo.get_note_object()) self.display_attr_list(of, ReportUtils.sanitize_list( photo.get_attribute_list(), self.exclude_private)) + self.display_media_sources(of,db,photo) self.display_references(of,db,media_list) self.display_footer(of,db) self.close_file(of) + def display_media_sources(self,of,db,photo): + self.db = db + self.src_list = {} + sreflist = photo.get_source_references() + self.display_source_refs(of,db,sreflist) + def display_attr_list(self,of,attrlist=None): if not attrlist: return @@ -1105,7 +1335,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) @@ -1152,7 +1382,7 @@ class HomePage(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) @@ -1391,11 +1621,11 @@ class ContactPage(BasePage): if nobj: format = nobj.get_format() text = nobj.get() - + 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') @@ -1598,42 +1828,7 @@ class IndividualPage(BasePage): sreflist = self.src_refs + self.person.get_source_references() if not sreflist or self.restrict: return - of.write('
\n') - of.write('

%s

\n' % _('Source References')) - of.write('\n') - - index = 1 - for sref in sreflist: - lnk = (self.cur_name, self.page_title, self.gid) - shandle = sref.get_reference_handle() - if not shandle: - continue - if self.src_list.has_key(shandle): - if lnk not in self.src_list[shandle]: - self.src_list[shandle].append(lnk) - else: - self.src_list[shandle] = [lnk] - - source = self.db.get_source_from_handle(shandle) - title = source.get_title() - of.write('' % (index,index)) - of.write('\n') - index += 1 - of.write('
') - of.write('%d.') - self.source_link(of,source.handle,title,source.gramps_id,True) - tmp = [] - confidence = Utils.confidence.get(sref.confidence, _('Unknown')) - for (label,data) in [(_('Date'),_dd.display(sref.date)), - (_('Page'),sref.page), - (_('Confidence'),confidence), - (_('Text'),sref.text)]: - if data: - tmp.append("%s: %s" % (label,data)) - if len(tmp) > 0: - of.write('
' + '
'.join(tmp)) - of.write('
\n') - of.write('
\n') + self.display_source_refs(of,self.db,sreflist) def display_ind_pedigree(self,of): @@ -1844,6 +2039,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 ) @@ -1867,6 +2063,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') @@ -1874,9 +2071,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' % _("Other 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') @@ -1979,7 +2220,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): @@ -2054,6 +2295,21 @@ 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 + note_obj = event.get_note_object() + if note_obj: + note_text = note_obj.get() + if note_text != '': + if note_obj.get_format(): + text += '

\n'
+                    text += note_text
+                    text += '
\n' + else: + text += '

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

' + return text def get_citation_links(self, source_ref_list): @@ -2118,6 +2374,12 @@ class WebReport(Report): NWEBintronote NWEBhomenote NWEBnoid + NWEBlinkhome + NWEBshowbirth + NWEBshowdeath + NWEBshowspouse + NWEBshowparents + NWEBshowhalfsiblings """ self.database = database @@ -2137,6 +2399,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'] @@ -2293,7 +2561,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, @@ -2453,6 +2724,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' : '', @@ -2560,6 +2837,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 @@ -2667,6 +2962,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()) @@ -2678,6 +2981,12 @@ class WebReportOptions(ReportOptions): self.options_dict['NWEBrestrictyears'] = int(self.restrict_years.get_text()) self.options_dict['NWEBincpriv'] = int(not self.no_private.get_active()) self.options_dict['NWEBnoid'] = int(self.noid.get_active()) + 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['NWEBcontact'] = unicode(self.contact.get_handle()) self.options_dict['NWEBgallery'] = int(self.include_gallery.get_active()) self.options_dict['NWEBheader'] = unicode(self.header.get_handle())