0001624: Source reference hyperlinks do not always work in Narrated Web Site

svn: r9971
This commit is contained in:
Brian Matherly 2008-02-01 02:23:51 +00:00
parent 7ede2b4376
commit d45a2fc957
2 changed files with 30 additions and 13 deletions

View File

@ -1,3 +1,7 @@
2008-01-31 Brian Matherly <brian@gramps-project.org>
* src/ReportBase/_Bibliography.py: Fix 0001624: Source reference hyperlinks
do not always work in Narrated Web Site
2008-01-28 Benny Malengier <benny.malengier@gramps-project.org> 2008-01-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/plugins/MarkerReport.py: fix bug #1669 with None type cmp * src/plugins/MarkerReport.py: fix bug #1669 with None type cmp

View File

@ -24,6 +24,8 @@ Contain and organize bibliographic information.
""" """
import string import string
from gen.lib import SourceRef as SourceRef
class Citation: class Citation:
""" """
Store information about a citation and all of its references. Store information about a citation and all of its references.
@ -44,7 +46,7 @@ class Citation:
""" """
return self.__src_handle return self.__src_handle
def set_source_handle(self,handle): def set_source_handle(self, handle):
""" """
Set the handle for the source that this citation is for. Set the handle for the source that this citation is for.
@ -83,7 +85,7 @@ class Citation:
second_letter = string.lowercase[ ref_count % letter_count ] second_letter = string.lowercase[ ref_count % letter_count ]
key = first_letter + second_letter key = first_letter + second_letter
self.__ref_list.append((key,source_ref)) self.__ref_list.append((key, source_ref))
return key return key
class Bibliography: class Bibliography:
@ -96,7 +98,7 @@ class Bibliography:
MODE_NOTE = 2**3 MODE_NOTE = 2**3
MODE_ALL = MODE_DATE | MODE_PAGE | MODE_CONF | MODE_NOTE MODE_ALL = MODE_DATE | MODE_PAGE | MODE_CONF | MODE_NOTE
def __init__(self,mode=MODE_ALL): def __init__(self, mode=MODE_ALL):
""" """
A bibliography will store citations (sources) and references to those A bibliography will store citations (sources) and references to those
citations (source refs). Duplicate entries will not be added. To change citations (source refs). Duplicate entries will not be added. To change
@ -132,7 +134,7 @@ class Bibliography:
""" """
source_handle = source_ref.get_reference_handle() source_handle = source_ref.get_reference_handle()
cindex = 0 cindex = 0
rkey = None rkey = ""
citation = None citation = None
citation_found = False citation_found = False
for citation in self.__citation_list: for citation in self.__citation_list:
@ -148,13 +150,14 @@ class Bibliography:
self.__citation_list.append(citation) self.__citation_list.append(citation)
if self.__sref_has_info(source_ref): if self.__sref_has_info(source_ref):
for key,ref in citation.get_ref_list(): for key, ref in citation.get_ref_list():
if self.__srefs_are_equal(ref,source_ref): if self.__srefs_are_equal(ref, source_ref):
# if a reference like this already exists, don't add another one # if a reference like this already exists, don't add
return (cindex,key) # another one
return (cindex, key)
rkey = citation.add_reference(source_ref) rkey = citation.add_reference(source_ref)
return (cindex,rkey) return (cindex, rkey)
def get_citation_count(self): def get_citation_count(self):
""" """
@ -174,15 +177,21 @@ class Bibliography:
""" """
return self.__citation_list return self.__citation_list
def __sref_has_info(self,source_ref): def __sref_has_info(self, source_ref):
"""
Determine if this source_ref has any useful information based on the
current mode.
"""
if ( self.mode & self.MODE_PAGE ) == self.MODE_PAGE: if ( self.mode & self.MODE_PAGE ) == self.MODE_PAGE:
if source_ref.get_page() != "": if source_ref.get_page() != "":
return True return True
if ( self.mode & self.MODE_DATE ) == self.MODE_DATE: if ( self.mode & self.MODE_DATE ) == self.MODE_DATE:
if source_ref.get_date_object() != None: date = source_ref.get_date_object()
if date != None and not date.is_empty():
return True return True
if ( self.mode & self.MODE_CONF ) == self.MODE_CONF: if ( self.mode & self.MODE_CONF ) == self.MODE_CONF:
if source_ref.get_confidence_level() != None: confidence = source_ref.get_confidence_level()
if confidence != None and confidence != SourceRef.CONF_NORMAL:
return True return True
if ( self.mode & self.MODE_NOTE ) == self.MODE_NOTE: if ( self.mode & self.MODE_NOTE ) == self.MODE_NOTE:
if len(source_ref.get_note_list()) != 0: if len(source_ref.get_note_list()) != 0:
@ -190,7 +199,11 @@ class Bibliography:
# Can't find anything interesting. # Can't find anything interesting.
return False return False
def __srefs_are_equal(self,source_ref1,source_ref2): def __srefs_are_equal(self, source_ref1, source_ref2):
"""
Determine if two source references are equal based on the
current mode.
"""
if self.mode == self.MODE_ALL: if self.mode == self.MODE_ALL:
return source_ref1.is_equal(source_ref2) return source_ref1.is_equal(source_ref2)
if ( self.mode & self.MODE_PAGE ) == self.MODE_PAGE: if ( self.mode & self.MODE_PAGE ) == self.MODE_PAGE: