From 980f5a3a5118efc67e8860d1aec832159a0fad37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Charette?= Date: Thu, 23 Aug 2007 09:54:37 +0000 Subject: [PATCH] moved the source reference code from IndividualPage into BasePage so it can also be used by media objects svn: r8856 --- ChangeLog | 4 ++ src/plugins/NarrativeWeb.py | 116 ++++++++++++++++++++---------------- 2 files changed, 69 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index 068246a5e..2f79e5f76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-08-23 Stephane Charette + * src/plugins/NarrativeWeb.py: moved the source reference code from + IndividualPage into BasePage so it can also be used by media objects + 2007-08-22 Don Allingham * src/GrampsDbUtils/_GedcomParse.py: use FACT for custom attributes, handle custom event descriptions as notes diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index 1d419ff0c..6d6aa5839 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -503,6 +503,61 @@ class BasePage: of.write('\n') of.write('\n') + def display_source_refs(self, of, db): + if self.bibli.get_citation_count() == 0: + return + of.write('
\n') + of.write('

%s

\n' % _('Source References')) + of.write('\n') + + cindex = 0 + for citation in self.bibli.get_citation_list(): + cindex += 1 + # Add this source to the global list of sources to be displayed + # on each source page. + lnk = (self.cur_name, self.page_title, self.gid) + shandle = citation.get_source_handle() + 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] + + # Add this source and its references to the page + source = self.db.get_source_from_handle(shandle) + title = source.get_title() + of.write('' % (cindex,cindex)) + of.write('\n') + + for key,sref in citation.get_ref_list(): + of.write('\t') + of.write('' % (cindex,key)) + of.write('\n') + of.write('
') + of.write('%d.') + self.source_link(of,source.handle,title,source.gramps_id,True) + of.write('

') + of.write('

') + of.write('' % (cindex,key)) + of.write('%d%s.') + + tmp = [] + confidence = Utils.confidence.get(sref.confidence, _('Unknown')) + for (label,data) in [(_('Date'),_dd.display(sref.date)), + (_('Page'),sref.page), + (_('Confidence'),confidence)]: + if data: + tmp.append("%s: %s" % (label,data)) + notelist = sref.get_note_list() + for notehandle in notelist: + note = self.db.get_note_from_handle(notehandle) + tmp.append("%s: %s" % (_('Text'),note.get(True))) + if len(tmp) > 0: + of.write('
'.join(tmp)) + of.write('

') + of.write('

\n') + of.write('
\n') + def display_references(self,of,db,handlelist): if not handlelist: return @@ -1101,10 +1156,19 @@ class MediaPage(BasePage): self.display_note_list(of, db, photo.get_note_list()) self.display_attr_list(of, photo.get_attribute_list()) + 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 = {} + self.bibli = Bibliography() + for sref in photo.get_source_references(): + self.bibli.add_reference(sref) + self.display_source_refs(of, db) + def display_attr_list(self,of,attrlist=None): if not attrlist: return @@ -1769,57 +1833,7 @@ class IndividualPage(BasePage): self.bibli.add_reference(sref) if self.restrict or self.bibli.get_citation_count() == 0: return - of.write('
\n') - of.write('

%s

\n' % _('Source References')) - of.write('\n') - - cindex = 0 - for citation in self.bibli.get_citation_list(): - cindex += 1 - # Add this source to the global list of sources to be displayed - # on each source page. - lnk = (self.cur_name, self.page_title, self.gid) - shandle = citation.get_source_handle() - 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] - - # Add this source and its references to the page - source = self.db.get_source_from_handle(shandle) - title = source.get_title() - of.write('' % (cindex,cindex)) - of.write('\n') - - for key,sref in citation.get_ref_list(): - of.write('\t') - of.write('' % (cindex,key)) - of.write('\n') - of.write('
') - of.write('%d.') - self.source_link(of,source.handle,title,source.gramps_id,True) - of.write('

') - of.write('

') - of.write('' % (cindex,key)) - of.write('%d%s.') - - tmp = [] - confidence = Utils.confidence.get(sref.confidence, _('Unknown')) - for (label,data) in [(_('Date'),_dd.display(sref.date)), - (_('Page'),sref.page), - (_('Confidence'),confidence)]: - if data: - tmp.append("%s: %s" % (label,data)) - notelist = sref.get_note_list() - for notehandle in notelist: - note = self.db.get_note_from_handle(notehandle) - tmp.append("%s: %s" % (_('Text'),note.get(True))) - if len(tmp) > 0: - of.write('
'.join(tmp)) - of.write('

') - of.write('

\n') - of.write('
\n') + self.display_source_refs(of, self.db) def display_ind_pedigree(self,of):