Complete re- write of SourcePage Citation Referents section. It now works correctly and the web page source layout is also correct, which afects the page layout.

svn: r18821
This commit is contained in:
Rob G. Healey 2012-02-05 07:00:17 +00:00
parent 49cf1d753d
commit fd706ae824

View File

@ -1031,55 +1031,33 @@ class BasePage(object):
hyper += Html("span", " [%s]" % gid, class_ = "grampsid", inline = True) hyper += Html("span", " [%s]" % gid, class_ = "grampsid", inline = True)
return hyper return hyper
def get_family_link(self, family, ppl_handle_list, type_ = "Html"): def get_family_string(self, family):
""" """
returns the husband and spouse link... returns a hyperlink for each person linked to the Family Page
""" """
husband, spouse = [None]*2 husband, spouse = [False]*2
husband_handle = family.get_father_handle() husband_handle = family.get_father_handle()
spouse_handle = family.get_mother_handle() spouse_handle = family.get_mother_handle()
if (husband_handle and husband_handle in ppl_handle_list): husband = self.dbase_.get_person_from_handle(husband_handle)
husband = self.dbase_.get_person_from_handle(husband_handle) spouse = self.dbase_.get_person_from_handle(spouse_handle)
if husband:
husband_name = self.get_name(husband)
if type_ == "String": if husband:
url = self.report.build_url_fname_html(husband_handle, 'ppl', up = self.up) husband_name = self.get_name(husband)
husband_link = self.person_link(url, husband, _NAME_STYLE_DEFAULT, gid = husband.get_gramps_id()) hlink = self.family_link(family.get_handle(), husband_name, uplink = self.up)
else: if spouse:
husband_link = self.family_link(family.get_handle(), husband_name, family.get_gramps_id(), self.up) spouse_name = self.get_name(spouse)
slink = self.family_link(family.get_handle(), spouse_name, uplink = self.up)
if (spouse_handle and spouse_handle in ppl_handle_list): title_str = ''
spouse = self.dbase_.get_person_from_handle(spouse_handle) if husband and spouse:
if spouse: title_str = '%s ' % hlink + _("and") + ' %s' % slink
spouse_name = self.get_name(spouse) elif husband:
title_str = '%s ' % hlink
if type_ == "String": elif spouse:
url = self.report.build_url_fname_html(spouse_handle, 'ppl', up = self.up) title_str = '%s ' % slink
spouse_link = self.person_link(url, spouse, _NAME_STYLE_DEFAULT, gid = spouse.get_gramps_id()) return title_str
else:
spouse_link = self.family_link(family.get_handle(), spouse_name, family.get_gramps_id(), self.up)
# return Html instead of a string...
if type_ == "Html":
web_link = Html("li")
if spouse and husband:
web_link += 'H%s ' % husband_link + _("and") + ' %s' % spouse_link
elif spouse:
web_link += spouse_link
elif husband:
web_link += husband_link
return web_link
else:
if husband and spouse:
self.page_title += "%s and %s" % (husband_link, spouse_link)
elif husband:
self.page_title += "%s" % husband_link
elif spouse:
self.page_title += "%s" % spouse_link
return self.page_title
def event_link(self, event_handle, event_title, gid = None, uplink = False): def event_link(self, event_handle, event_title, gid = None, uplink = False):
""" """
@ -3307,7 +3285,7 @@ class FamilyPage(BasePage):
self.person = spouse self.person = spouse
# determine if husband and wife, husband only, or spouse only.... # determine if husband and wife, husband only, or spouse only....
self.page_title = _("Family of ") + self.get_family_link(family, ppl_handle_list, type_ = "String") self.page_title = _("Family of ") + self.get_family_string(family)
relationshipdetail += Html("h2", self.page_title, inline = True) relationshipdetail += Html("h2", self.page_title, inline = True)
# display relationships # display relationships
@ -3936,7 +3914,7 @@ class MediaPage(BasePage):
body += mediadetail body += mediadetail
# media navigation # media navigation
with Html("div", id = "GalleryNav") as medianav: with Html("div", id = "GalleryNav", role = "navigation") as medianav:
mediadetail += medianav mediadetail += medianav
if prev: if prev:
medianav += self.media_nav_link(prev, _("Previous"), True) medianav += self.media_nav_link(prev, _("Previous"), True)
@ -4570,8 +4548,11 @@ class SourcePage(BasePage):
} }
});""" });"""
# begin Source Citation Referents section
with Html("div", class_ ="subsection", id = "SourceCitationReferents") as section: with Html("div", class_ ="subsection", id = "SourceCitationReferents") as section:
sourcedetail += section sourcedetail += section
# add secion title
section += Html("h4", _("Citation References"), inline =True) section += Html("h4", _("Citation References"), inline =True)
# ordered and list item #1, Citation Volume/ Page... # ordered and list item #1, Citation Volume/ Page...
@ -4593,116 +4574,121 @@ class SourcePage(BasePage):
# unordered and list item #2, Object Type... # unordered and list item #2, Object Type...
unordered2 = Html("ul", class_ = "Col2 ObjectType", id = "menu") unordered2 = Html("ul", class_ = "Col2 ObjectType", id = "menu")
list1 += unordered2
# Citation Referents have Person objects... # Citation Referents have Person objects...
if people_list: if people_list:
list2 = Html("li") list2 = Html("li")
unordered2 += list2
hyper2 = Html("a", _("People"), href = "#", title = _("People")) list2.extend(
list2 += hyper2 Html("a", _("People"), href = "#", title = _("People"), inline = True)
)
# ordered and list item #3, Surname... # unordered and list item #3, Surname...
unordered3 = Html("ul", class_ = "Col3 Surname") unordered3 = Html("ul", class_ = "Col3 Surname")
hyper2 += unordered3
displayed = [] displayed = []
for (surname, handle_list) in people_list: for (surname, people_handle_list) in people_list:
if surname not in displayed: if surname not in displayed:
list3 = Html("li") list3 = Html("li")
hyper3 = Html("a", surname, href = "#", title = surname) list3.extend(
Html("a", surname, href = "#", title = surname, inline = True)
)
# ordered #4, Display Name... # unordered list #4, Display Name...
unordered4 = Html("ul", class_ = "Col4 DisplayName") unordered4 = Html("ul", class_ = "Col4 DisplayName")
for person_handle in handle_list: for person_handle in people_handle_list:
person = self.dbase_.get_person_from_handle(person_handle) person = self.dbase_.get_person_from_handle(person_handle)
if person: if person:
url = self.report.build_url_fname_html(person_handle, "ppl", up = self.up) url = self.report.build_url_fname_html(person_handle, "ppl", up = self.up)
unordered4.extend( unordered4.extend(
Html("li", self.person_link(url, person, False)) Html("li", self.person_link(url, person, False), inline = True)
) )
hyper3 += unordered4
list3 += hyper3 list3 += unordered4
unordered3 += list3 unordered3 += list3
displayed.append(surname) displayed.append(surname)
list2 += unordered3
unordered2 += list2
# Citation Referents have Family Objects... # Citation Referents have Family Objects...
if (self.inc_families and family_list): if (self.inc_families and family_list):
list2 = Html("li") + ( list2 = Html("li")
list2.extend(
Html("a", _("Families"), href = "#", title = _("Families"), inline = True) Html("a", _("Families"), href = "#", title = _("Families"), inline = True)
) )
unordered2 += list2
# unordered and list item #3, Husband and Spouse FamilyLink... # unordered and list item #3, Husband and Spouse FamilyLink...
unordered3 = Html("ul", class_ = "Col3 Husband-n-Spouse") unordered3 = Html("ul", class_ = "Col3 Husband-n-Spouse")
list2 += unordered3
for family_handle in family_list: for family_handle in family_list:
family = self.dbase_.get_family_from_handle(family_handle) family = self.dbase_.get_family_from_handle(family_handle)
if (family and family_handle in db_family_handles): if (family and family_handle in db_family_handles):
family_title = self.get_family_link(family, ppl_handle_list, "String")
hyper = self.family_link(family_handle, "", uplink = self.up)
list3 = Html("li") + ( unordered3.extend(
Html("a", family_title, href = hyper, title = family_title, inline = True) Html("li", self.get_family_string(family))
) )
unordered3 += list3 list2 += unordered3
unordered2 += list2
# Citation Referents have Event Objects... # Citation Referents have Event Objects...
if (self.inc_events and event_list): if (self.inc_events and event_list):
list2 = Html("li") + ( list2 = Html("li")
list2.extend(
Html("a", _("Events"), href = "#", title = _("Events"), inline = True) Html("a", _("Events"), href = "#", title = _("Events"), inline = True)
) )
unordered2 += list2
# get event types and the handles that go with them... # get event types and the handles that go with them...
event_handle_list, event_types = build_event_data_by_events(self.dbase_, event_list) event_handle_list, event_types = build_event_data_by_events(self.dbase_, event_list)
# unOrdered and list item #3, EventType # unOrdered and list item #3, EventType...
unordered3 = Html("ul", class_ = "Col3 EventType") unordered3 = Html("ul", class_ = "Col3 EventType")
list2 += unordered3
# separate events by their types and then thier event handles # separate events by their types and then thier event handles
for (event_type, data_list) in sort_event_types(self.dbase_, event_types, event_handle_list): for (event_type, event_list) in sort_event_types(self.dbase_, event_types, event_handle_list):
# sort data_list by date of event and event handle... # sort data_list by date of event and event handle...
data_list = sorted(data_list, key = operator.itemgetter(0, 1)) event_list = sorted(event_list, key = operator.itemgetter(0, 1))
list3 = Html("li") + ( list3 = Html("li")
list3.extend(
Html("a", event_type, href = "#", title = event_type, inline = True) Html("a", event_type, href = "#", title = event_type, inline = True)
) )
unordered3 += list3
# unOrdered and list item #4, Event Date... # unOrdered and list item #4, Event Date...
unordered4 = Html("ul", class_ = "Col4 EventDate") unordered4 = Html("ul", class_ = "Col4 EventDate")
list3 += unordered4
for (sort_value, event_handle) in data_list: for (sort_value, event_handle) in event_list:
event = self.dbase_.get_event_from_handle(event_handle) event = self.dbase_.get_event_from_handle(event_handle)
if (event and event_handle in db_event_handles): if (event and event_handle in db_event_handles):
event_date = _dd.display(event.get_date_object()) event_date = _dd.display(event.get_date_object())
list4 = Html("li")
list4.extend(
Html("a", event_date, href = "#", title = event_date, inline = True)
)
# unordered list #5, Husband-n-Spouse
unordered5 = Html("ul", class_ = "Col5")
# marriage or Divorce Event... # marriage or Divorce Event...
if event.get_type() in [gen.lib.EventType.MARRIAGE, gen.lib.EventType.DIVORCE]: if event.get_type() in [gen.lib.EventType.MARRIAGE, gen.lib.EventType.DIVORCE]:
for (classname, newhandle) in self.dbase_.find_backlink_handles(event_handle, ["Family"]): for (classname, newhandle) in self.dbase_.find_backlink_handles(event_handle, ["Family"]):
family = self.dbase_.get_family_from_handle(newhandle) family = self.dbase_.get_family_from_handle(newhandle)
if (family and newhandle in db_family_handles): if (family and newhandle in db_family_handles):
family_title = self.get_family_link(family, ppl_handle_list, "String") unordered5.extend(
hyper = self.family_link(newhandle, "", uplink = self.up) Html("li", self.get_family_string(family))
list4 = Html("li") + (
Html("a", family_title, href = hyper, title = family_title, inline = True)
) )
unordered4 += list4
# any other event types... # any other event types...
else: else:
@ -4713,101 +4699,94 @@ class SourcePage(BasePage):
for (classname, newhandle) in back_handle_list: for (classname, newhandle) in back_handle_list:
obj = self.dbase_.get_person_from_handle(newhandle) obj = self.dbase_.get_person_from_handle(newhandle)
if obj: if obj:
hyper = self.event_link(event_handle, "", uplink = self.up) unordered5.extend(
list4 = Html("li") + ( Html("li", self.event_link(event_handle, self.get_name(obj),
Html("a", self.get_name(obj), href = hyper, inline = True) uplink = self.up), inline = True)
) )
unordered4 += list4
# this occurs when an event has multiple participants... # this occurs when an event has multiple participants...
else: else:
list4 = Html("li") + (
Html("a", event_date, href = "#", title = event_date, inline = True)
)
unordered4 += list4
# unordered and list item #5, Multiple Participants in an event...
unordered5 = Html("ul", class_ = "Col5 Multiple-Participants")
list4 += unordered5
for (classname, newhandle) in back_handle_list: for (classname, newhandle) in back_handle_list:
obj = self.dbase_.get_person_from_handle(newhandle) obj = self.dbase_.get_person_from_handle(newhandle)
if obj: if obj:
hyper = self.event_link(event_handle, "", uplink = self.up) unordered5.extend(
list5 = Html("li") + ( Html("li", self.event_link(event_handle, self.get_name(obj),
Html("a", self.get_name(obj), href = hyper, inline = True) uplink = self.up), inline = True)
) )
unordered5 += list5 list4 += unordered5
unordered4 += list4
list3 += unordered4
unordered3 += list3
list2 += unordered3
unordered2 += list2
# Citation Referents have Place Objects... # Citation Referents have Place Objects...
if place_list: if place_list:
list2 = Html("li") + ( list2 = Html("li")
list2.extend(
Html("a", _("Places"), href = "#", title = _("Places"), inline = True) Html("a", _("Places"), href = "#", title = _("Places"), inline = True)
) )
unordered2 += list2
# unordered and list item #3, Place Title... # unordered and list item #3, Place Title...
unordered3 = Html("ul", class_ = "Col3 PlaceTitle") unordered3 = Html("ul", class_ = "Col3 PlaceTitle")
list2 += unordered3
for place_handle in place_list: for place_handle in place_list:
place = self.dbase_.get_place_from_handle(place_handle) place = self.dbase_.get_place_from_handle(place_handle)
if (place and place_handle in db_place_handles): if (place and place_handle in db_place_handles):
hyper = self.place_link(place_handle, "", uplink = self.up) unordered3.extend(
list3 = Html("li") + ( Html("li", self.place_link(place_handle, place.get_title(), uplink = self.up),
Html("a", place.get_title(), href = hyper, title = place.get_title(), inline = True) inline = True)
) )
unordered3 += list3 list2 += unordered3
unordered2 += list2
# Citation Referents have Source Objects... # Citation Referents have Source Objects...
if source_list: if source_list:
list2 = Html("li") + ( list2 = Html("li")
list2.extend(
Html("a", _("Sources"), href = "#", title = _("Sources"), inline = True) Html("a", _("Sources"), href = "#", title = _("Sources"), inline = True)
) )
unordered2 += list2
# unordered and list item #3, Source Title... # unordered and list item #3, Source Title...
unordered3 = Html("ul", class_ = "Col3 SourceTitle") unordered3 = Html("ul", class_ = "Col3 SourceTitle")
list2 += unordered3
for source_handle in source_list: for source_handle in source_list:
source = self.dbase_.get_source_from_handle(source_handle) source = self.dbase_.get_source_from_handle(source_handle)
if (source and source_handle in db_source_handles): if (source and source_handle in db_source_handles):
source_title = source.get_title() unordered3.extend(
Html("li", self.source_link(source, uplink = self.up), inline = True)
hyper = self.source_link(source_handle, "", uplink = self.up)
list3 = Html("li") + (
Html("a", source_title, href = hyper, title = source_title, inline = True)
) )
unordered3 += list3 list2 += unordered3
unordered2 += list2
# Citation Referents have Repository Objects... # Citation Referents have Repository Objects...
if (inc_repositories and repo_list): if (inc_repositories and repo_list):
list2 = Html("li") + ( list2 = Html("li")
list2.extend(
Html("a", _("Repositories"), href = "#", title = _("Repositories"), inline = True) Html("a", _("Repositories"), href = "#", title = _("Repositories"), inline = True)
) )
unordered2 += list2
# unordered and list item #3, Repository Name... # unordered and list item #3, Repository Name...
unordered3 = Html("ul", class_ = "Col3 RepositoryName") unordered3 = Html("ul", class_ = "Col3 RepositoryName")
list2 += unordered3
for repository_handle in repo_list: for repository_handle in repo_list:
repository = self.dbase_.get_repository_from_handle(repository_handle) repository = self.dbase_.get_repository_from_handle(repository_handle)
if (repository and repository_handle in db_repository_handles): if (repository and repository_handle in db_repository_handles):
repo_title = repository.get_name() unordered3.extend(
hyper = self.repository_link(repository_handle, "", uplink = self.up) Html("li", self.repository_link(repository_handle, repository.get_name(),
uplink = self.up), inline = True)
list3 = Html("li") + (
Html("a", repo_title, href = hyper, title = repo_title, inline = True)
) )
unordered3 += list3 list2 += unordered3
unordered2 += list2
# Citation Referents has Media Objects... # Citation Referents has Media Objects...
if (self.create_media and media_list): if (self.create_media and media_list):
@ -4816,9 +4795,10 @@ class SourcePage(BasePage):
media_list = sorted(media_list, key = sort.by_media_title_key) media_list = sorted(media_list, key = sort.by_media_title_key)
list2 = Html("li") list2 = Html("li")
unordered2 += list2
hyper2 = Html("a", _("Media"), href = "#", title = _("Media")) list2.extend(
Html("a", _("Media"), href = "#", title = _("Media"), inline = True)
)
# unordered and list item #3, Thumbnail Link... # unordered and list item #3, Thumbnail Link...
unordered3 = Html("ul", class_ = "Col3 MediaLink") unordered3 = Html("ul", class_ = "Col3 MediaLink")
@ -4826,7 +4806,6 @@ class SourcePage(BasePage):
for media_handle in media_list: for media_handle in media_list:
media = self.dbase_.get_object_from_handle(media_handle) media = self.dbase_.get_object_from_handle(media_handle)
if (media and media_handle in db_media_handles): if (media and media_handle in db_media_handles):
media_title = media.get_description()
mime_type = media.get_mime_type() mime_type = media.get_mime_type()
if mime_type: if mime_type:
@ -4835,16 +4814,19 @@ class SourcePage(BasePage):
newpath = self.report.build_url_fname(newpath, up = self.up) newpath = self.report.build_url_fname(newpath, up = self.up)
unordered3.extend( unordered3.extend(
Html("li", self.media_link(media_handle, newpath, Html("li", self.media_link(media_handle, newpath, media.get_description(),
media.get_description(), self.up, usedescr = False)) self.up, usedescr = False), inline = True)
) )
else: else:
unordered3.extend( unordered3.extend(
Html("li", self.doc_link(media_handle, media.get_description(), Html("li", self.doc_link(media_handle, media.get_description(),
self.up, usedescr = False)) self.up, usedescr = False), inline = True)
) )
hyper2 += unordered3 list2 += unordered3
list2 += hyper2 unordered2 += list2
# must be attached at the very end of the refs list...
list1 += unordered2
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section