Referenced Sources has been added to class RepositoryPage().

svn: r18284
This commit is contained in:
Rob G. Healey 2011-10-11 02:17:42 +00:00
parent 55b297d1fb
commit 2aad276c80

View File

@ -851,7 +851,7 @@ class BasePage(object):
@param: up - rather to add back directories or not? @param: up - rather to add back directories or not?
""" """
url = self.report.build_url_fname_html( source.handle, "src", up ) url = self.report.build_url_fname_html(source.get_handle(), "src", up)
gid = source.get_gramps_id() gid = source.get_gramps_id()
title = html_escape(source.get_title()) title = html_escape(source.get_title())
@ -5979,11 +5979,13 @@ class RepositoryListPage(BasePage):
# and close the file # and close the file
self.XHTMLWriter(repolistpage, of) self.XHTMLWriter(repolistpage, of)
#-----------------------------------------------------
#
# Repository Pages
#
#-----------------------------------------------------
class RepositoryPage(BasePage): class RepositoryPage(BasePage):
""" def __init__(self, report, title, repo, handle, source_list):
will create the individual Repository Pages
"""
def __init__(self, report, title, repo, handle):
gid = repo.get_gramps_id() gid = repo.get_gramps_id()
BasePage.__init__(self, report, title, gid) BasePage.__init__(self, report, title, gid)
db = report.database db = report.database
@ -6006,19 +6008,18 @@ class RepositoryPage(BasePage):
tbody = Html("tbody") tbody = Html("tbody")
table += tbody table += tbody
if self.noid or not gid: if not self.noid and gid:
gid = False trow = Html("tr") + (
Html("td", _("Gramps ID"), class_ ="ColumnAttribute", inline =True),
Html("td", gid, class_="ColumnValue", inline =True)
)
tbody += trow
tbody.extend( trow = Html("tr") + (
( Html("tr"), Html("td", _("Type"), class_ ="ColumnAttribute", inline =True),
Html("td", label, class_ ="ColumnType"), Html("td", str(repo.get_type()), class_ ="ColumnValue", inline =True)
Html("td", data or " ", class_ ="ColumnAttribute")
)
for label, data in [
(_("Gramps ID"), gid),
(_("Type"), str(repo.get_type()))
]
) )
tbody += trow
# repository: address(es)... repository addresses do NOT have Sources # repository: address(es)... repository addresses do NOT have Sources
repo_address = self.display_addr_list(repo.get_address_list(), False) repo_address = self.display_addr_list(repo.get_address_list(), False)
@ -6035,6 +6036,9 @@ class RepositoryPage(BasePage):
if notelist is not None: if notelist is not None:
repositorydetail += notelist repositorydetail += notelist
# display Repository Referenced Sources...
repositorydetail += self.__write_referenced_sources(handle, source_list)
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section
footer = self.write_footer() footer = self.write_footer()
@ -6044,6 +6048,48 @@ class RepositoryPage(BasePage):
# and close the file # and close the file
self.XHTMLWriter(repositorypage, of) self.XHTMLWriter(repositorypage, of)
def __write_referenced_sources(self, handle, source_list):
"""
This procedure writes out each of the sources related to the repository.
"""
db = self.report.database
repository = db.get_repository_from_handle(handle)
if not repository:
return None
repository_source_handles = [handle for (object_type, handle) in
db.find_backlink_handles(handle, include_classes = ['Source'])]
# begin Repository Referenced Sources...
with Html("div", class_ ="Subsection", id ="referenced_sources") as section:
section += Html("h4", _("Referenced Sources"), inline =True)
source_nbr = 0
for source_handle in repository_source_handles:
source = db.get_source_from_handle(source_handle)
if source:
# Get the list of references from this source to our repo
# (can be more than one, technically)
for reporef in source.get_reporef_list():
if reporef.ref == repository.get_handle():
source_nbr += 1
if source_handle in source_list:
source_name = self.source_link(source, up =True)
else:
source_name = source.get_title()
title = (('%(nbr)d. %(name)s (%(type)s) : %(call)s') %
{'nbr' : source_nbr,
'name' : source_name,
'type' : str(reporef.get_media_type()),
'call' : reporef.get_call_number()})
ordered = Html("ol", title)
section += ordered
return section
class AddressBookListPage(BasePage): class AddressBookListPage(BasePage):
def __init__(self, report, title, has_url_addr_res): def __init__(self, report, title, has_url_addr_res):
@ -6421,16 +6467,15 @@ class NavWebReport(Report):
# by galleries # by galleries
self.source_pages(source_list) self.source_pages(source_list)
# build classes ddressBookList and AddressBookPage
if self.inc_addressbook:
self.addressbook_pages(ind_list)
# build classes RepositoryListPage and RepositoryPage # build classes RepositoryListPage and RepositoryPage
if self.inc_repository: if self.inc_repository:
repolist = self.database.get_repository_handles() repolist = self.database.get_repository_handles()
if len(repolist): if len(repolist):
self.repository_pages(repolist) self.repository_pages(repolist, source_list)
# build classes ddressBookList and AddressBookPage
if self.inc_addressbook:
self.addressbook_pages(ind_list)
# if an archive is being used, close it? # if an archive is being used, close it?
if self.archive: if self.archive:
@ -6721,24 +6766,23 @@ class NavWebReport(Report):
if self.use_intro: if self.use_intro:
IntroductionPage(self, self.title) IntroductionPage(self, self.title)
def repository_pages(self, repolist): def repository_pages(self, repolist, source_list):
""" """
will create RepositoryPage() and RepositoryListPage() will create RepositoryPage() and RepositoryListPage()
""" """
repos_dict = {} repos_dict = {}
# Sort the repositories # Sort the repositories
for handle in repolist: for handle in repolist:
repo = self.database.get_repository_from_handle(handle) repository = self.database.get_repository_from_handle(handle)
key = repo.name + str(repo.get_gramps_id()) key = repository.get_name() + str(repository.get_gramps_id())
repos_dict[key] = (repo, handle) repos_dict[key] = (repository, handle)
keys = sorted(repos_dict, key =locale.strxfrm) keys = sorted(repos_dict, key =locale.strxfrm)
# set progress bar pass for Repositories # set progress bar pass for Repositories
repo_size = len(repos_dict) repository_size = len(repos_dict)
self.progress.set_pass(_('Creating repository pages'), repo_size) self.progress.set_pass(_('Creating repository pages'), repository_size)
# RepositoryListPage Class # RepositoryListPage Class
RepositoryListPage(self, self.title, repos_dict, keys) RepositoryListPage(self, self.title, repos_dict, keys)
@ -6746,7 +6790,7 @@ class NavWebReport(Report):
for index, key in enumerate(keys): for index, key in enumerate(keys):
(repo, handle) = repos_dict[key] (repo, handle) = repos_dict[key]
RepositoryPage(self, self.title, repo, handle) RepositoryPage(self, self.title, repository, handle, source_list)
self.progress.step() self.progress.step()
def addressbook_pages(self, ind_list): def addressbook_pages(self, ind_list):