Cleanup of class SourcePage.

svn: r18567
This commit is contained in:
Rob G. Healey 2011-12-10 19:37:09 +00:00
parent 126eec72b1
commit 199cedbc12

View File

@ -4216,13 +4216,10 @@ class SourceListPage(BasePage):
self.XHTMLWriter(sourcelistpage, of) self.XHTMLWriter(sourcelistpage, of)
class SourcePage(BasePage): class SourcePage(BasePage):
def __init__(self, report, title, source, handle, src_list):
def __init__(self, report, title, handle, src_list):
db = report.database
source = db.get_source_from_handle(handle)
if not source: if not source:
return None return None
db = report.database
BasePage.__init__(self, report, title, source.get_gramps_id()) BasePage.__init__(self, report, title, source.get_gramps_id())
self.page_title = source.get_title() self.page_title = source.get_title()
@ -4233,31 +4230,31 @@ class SourcePage(BasePage):
sourcepage, head, body = self.write_header(_('Sources')) sourcepage, head, body = self.write_header(_('Sources'))
# begin source detail division # begin source detail division
with Html("div", class_ = "content", id = "SourceDetail") as section: with Html("div", class_ = "content", id = "SourceDetail") as sourcedetail:
body += section body += sourcedetail
if self.create_media: if self.create_media:
media_list = source.get_media_list() media_list = source.get_media_list()
thumbnail = self.display_first_image_as_thumbnail(media_list, source) thumbnail = self.display_first_image_as_thumbnail(media_list, source)
if thumbnail is not None: if thumbnail is not None:
section += thumbnail sourcedetail += thumbnail
# add section title # add section title
section += Html("h3", html_escape(source.get_title()), inline = True) sourcedetail += Html("h3", html_escape(source.get_title()), inline = True)
# begin sources table # begin sources table
with Html("table", class_ = "infolist source") as table: with Html("table", class_ = "infolist source") as table:
section += table sourcedetail += table
tbody = Html("tbody") tbody = Html("tbody")
table += tbody table += tbody
grampsid = None source_gid = False
if not self.noid and self.gid: if not self.noid and self.gid:
grampsid = self.gid source_gid = source.get_gramps_id()
for (label, val) in [ for (label, val) in [
(_("Gramps ID"), grampsid), (_("Gramps ID"), source_gid),
(_("Author"), source.author), (_("Author"), source.author),
(_("Publication information"), source.pubinfo), (_("Publication information"), source.pubinfo),
(_("Abbreviation"), source.abbrev) ]: (_("Abbreviation"), source.abbrev) ]:
@ -4273,23 +4270,22 @@ class SourcePage(BasePage):
# additional media # additional media
sourcemedia = self.display_additional_images_as_gallery(media_list, source) sourcemedia = self.display_additional_images_as_gallery(media_list, source)
if sourcemedia is not None: if sourcemedia is not None:
section += sourcemedia sourcedetail += sourcemedia
# additional notes # additional notes
notelist = self.display_note_list(source.get_note_list() notelist = self.display_note_list(source.get_note_list())
)
if notelist is not None: if notelist is not None:
section += notelist sourcedetail += notelist
# source repository list # source repository list
repo_ref_list = source.get_reporef_list() repo_ref_list = source.get_reporef_list()
if repo_ref_list: if repo_ref_list:
with Html("div", id = "subsection", class_ = "Repositories") as reposection: with Html("div", id = "subsection", class_ = "references") as repo_references:
section += reposection sourcedetail += repo_references
reposection += Html("h4", _("Repositories"), inline = True) repo_references += Html("h4", _("Repositories"), inline = True)
ordered = Html("ol") ordered = Html("ol")
reposection += ordered repo_references += ordered
for repo_ref in repo_ref_list: for repo_ref in repo_ref_list:
repository = db.get_repository_from_handle(repo_ref.ref) repository = db.get_repository_from_handle(repo_ref.ref)
@ -4302,10 +4298,9 @@ class SourcePage(BasePage):
ordered += list ordered += list
# references # references
references = self.display_references(src_list[source.get_handle()] references = self.display_references(src_list[source.get_handle()])
)
if references is not None: if references is not None:
section += references sourcedetail += references
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section
@ -6723,14 +6718,17 @@ class NavWebReport(Report):
""" """
creates SourceListPage and SourcePage creates SourceListPage and SourcePage
""" """
db = self.database
self.user.begin_progress(_("Narrated Web Site Report"), self.user.begin_progress(_("Narrated Web Site Report"),
_("Creating source pages"), len(source_list)) _("Creating source pages"),
len(source_list))
SourceListPage(self, self.title, source_list.keys()) SourceListPage(self, self.title, source_list.keys())
for key in source_list: for shandle in source_list:
SourcePage(self, self.title, key, source_list) source = db.get_source_from_handle(shandle)
SourcePage(self, self.title, source, shandle, source_list)
self.user.step_progress() self.user.step_progress()
self.user.end_progress() self.user.end_progress()