More cleanup work on stylesheet. Continuing to convert NarrativeWeb to use the Html class and the with statement.

svn: r12698
This commit is contained in:
Rob G. Healey
2009-06-22 23:58:09 +00:00
parent cdf0e98a55
commit 1101b21ba0
2 changed files with 419 additions and 384 deletions

View File

@@ -206,7 +206,7 @@ span.preposition {
margin:0; margin:0;
height:1.5cm; height:1.5cm;
padding:0 0 .9em 0; padding:0 0 .9em 0;
background-color:#542; background-color:#453619;
border-bottom:solid 2px #6AF364; border-bottom:solid 2px #6AF364;
} }
#SiteTitle { #SiteTitle {
@@ -235,9 +235,20 @@ p#user_header {
color:#FFF; color:#FFF;
margin:0; margin:0;
padding:0; padding:0;
background-color:#542; background-color:#453619;
border-top:solid 2px #6AF364; border-top:solid 2px #6AF364;
} }
#footer p#top {
float:right;
text-align:right;
margin-top:20px;
margin-right:20px;
display:block;
}
#footer p#top a {
width:60px;
text-decoration:underline;
}
#footer a, #footer a:visited { #footer a, #footer a:visited {
text-decoration:none; text-decoration:none;
color:#FFF; color:#FFF;
@@ -252,21 +263,19 @@ p#user_header {
} }
#footer p#createdate { #footer p#createdate {
float:left; float:left;
width:45%; width:230px;
text-align:left; text-align:left;
margin-left:10px; margin-left:10px;
color:#FFF; color:#FFF;
} }
#footer p#copyright { #footer p#copyright {
float:right; float:center;
width:40%; text-align:center;
text-align:right;
color:#FFF; color:#FFF;
margin-right:10px; margin-top:10px;
}
#footer p#copyright img {
margin-right:10px;
} }
#footer p#copyright img { }
#user_footer { #user_footer {
width:70%; width:70%;
float:left; float:left;
@@ -360,15 +369,13 @@ div#alphabet ul li.letters a:hover {
margin-top:-6px; margin-top:-6px;
padding-top:11px; padding-top:11px;
padding-bottom:8px; padding-bottom:8px;
border-right:solid 1px #6AF364; background-color:#CCC;
border-left:solid 1px #6AF364; color:#000;
border-bottom:solid 4px #000; border-bottom:solid 4px #CCC;
background-color:#000;
color:#FFF;
} }
#navigation ul li.CurrentSection a:hover { #navigation ul li.CurrentSection a:hover {
background-color:#228A22; background-color:#000;
border-bottom:solid 4px #228A22; color:#FFF;
} }
#subnavigation ul li.CurrentSection a { #subnavigation ul li.CurrentSection a {
border-width:0 0 1px 0; border-width:0 0 1px 0;
@@ -603,6 +610,7 @@ table.individuallist tbody tr td.ColumnPartner a:hover {
#Sources { } #Sources { }
#Sources table.infolist tbody tr td.ColumnRowLabel { #Sources table.infolist tbody tr td.ColumnRowLabel {
padding-bottom:0; padding-bottom:0;
background-color:#FFF;
} }
#Sources table.infolist tbody tr td.ColumnName { #Sources table.infolist tbody tr td.ColumnName {
padding:0; padding:0;
@@ -610,7 +618,6 @@ table.individuallist tbody tr td.ColumnPartner a:hover {
#Sources table.infolist tbody tr td.ColumnName a { #Sources table.infolist tbody tr td.ColumnName a {
font-size:.9em; font-size:.9em;
padding:.1em 10px .3em 10px; padding:.1em 10px .3em 10px;
background-color:#FFF;
} }
#Sources table.infolist tbody tr td.ColumnName a:hover { #Sources table.infolist tbody tr td.ColumnName a:hover {
background-color:#C1B398; background-color:#C1B398;
@@ -997,7 +1004,7 @@ div#narrative {
/* Subsections : Source References /* Subsections : Source References
----------------------------------------------------- */ ----------------------------------------------------- */
div#sourcerefs { div#sourcerefs {
height:2.5cm; height:2.64cm;
overflow:auto; overflow:auto;
} }
div#sourcerefs ol { div#sourcerefs ol {

View File

@@ -100,7 +100,8 @@ from gen.proxy import PrivateProxyDb, LivingProxyDb
from gen.lib.eventroletype import EventRoleType from gen.lib.eventroletype import EventRoleType
from libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS from libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
# import HTML Class # import HTML Class from
# src/plugins/lib/libhtml.py
from libhtml import Html from libhtml import Html
# import styled notes from # import styled notes from
@@ -119,12 +120,7 @@ _NARRATIVESCREEN = 'narrative-screen.css'
_NARRATIVEPRINT = 'narrative-print.css' _NARRATIVEPRINT = 'narrative-print.css'
# variables for alphabet_navigation() # variables for alphabet_navigation()
_PERSON = 0 _PERSON, _PLACE = 0, 1
_PLACE = 1
# sort_birth_order()
_FAMILY = 0
_PARENTS = 1
# Web page filename extensions # Web page filename extensions
_WEB_EXT = ['.html', '.htm', '.shtml', '.php', '.php3', '.cgi'] _WEB_EXT = ['.html', '.htm', '.shtml', '.php', '.php3', '.cgi']
@@ -271,17 +267,20 @@ class BasePage(object):
# #
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
def mywriter(self, page, of): def mywriter(self, htmlinstance, of):
""" """
This function is simply to make the web page look pretty and readable Will format, write, and close the file
It is not for the browser, but for us, humans
of -- open file that is being written to
htmlinstance -- web page created with libhtml
src/plugins/lib/libhtml.py
""" """
page.write(lambda line: of.write(line + '\n')) htmlinstance.write(lambda line: of.write(line + '\n'))
# closes the file
self.report.close_file(of) self.report.close_file(of)
def get_copyright_license(self, copyright, up=False): def get_copyright_license(self, copyright, up=False):
""" """
will return either the text or image of the copyright license will return either the text or image of the copyright license
@@ -332,13 +331,21 @@ class BasePage(object):
name.set_display_as(name_format) name.set_display_as(name_format)
return _nd.display_name(name) return _nd.display_name(name)
def write_footer(self): def write_footer(self, counter, hyper=False):
""" """
Will create and display the footer section of each page... Will create and display the footer section of each page...
""" """
db = self.report.database db = self.report.database
footer = Html('div', id='footer') footer = Html('div', id='footer')
# add top of page link
if hyper and counter > 25:
footer += Html('p', id='top', inline=True) + (
Html('a', _('Top of Page'), id="top", href='#top'),
Html('a', name='bottom', title=_('Bottom'))
)
footer_note = self.report.options['footernote'] footer_note = self.report.options['footernote']
if footer_note: if footer_note:
note = db.get_note_from_gramps_id(footer_note) note = db.get_note_from_gramps_id(footer_note)
@@ -397,7 +404,7 @@ class BasePage(object):
# return footer to its caller # return footer to its caller
return footer return footer
def write_header(self, title): def write_header(self, title, hyper=False):
""" """
Note. 'title' is used as currentsection in the navigation links and Note. 'title' is used as currentsection in the navigation links and
as part of the header title. as part of the header title.
@@ -458,6 +465,13 @@ class BasePage(object):
) )
body += headerdiv body += headerdiv
# add bottom link
if hyper:
headerdiv += Html('p', id='bottom', inline=True) + (
Html('a', id="bottom", href='#bottom', inline=True),
Html('a', name='top')
)
header_note = self.report.options['headernote'] header_note = self.report.options['headernote']
if header_note: if header_note:
note = db.get_note_from_gramps_id(header_note) note = db.get_note_from_gramps_id(header_note)
@@ -934,8 +948,11 @@ class IndividualListPage(BasePage):
showpartner = report.options['showpartner'] showpartner = report.options['showpartner']
showparents = report.options['showparents'] showparents = report.options['showparents']
# add top of page link
counter = len(person_handle_list)
of = self.report.create_file("individuals") of = self.report.create_file("individuals")
indlistpage, body = self.write_header(_('Individuals')) indlistpage, body = self.write_header(_('Individuals'), hyper=True)
# begin Individuals division # begin Individuals division
with Html('div', class_='content', id='Individuals') as section: with Html('div', class_='content', id='Individuals') as section:
@@ -965,27 +982,22 @@ class IndividualListPage(BasePage):
trow += Html('th', _('Surname'), class_='ColumnSurname') + ( trow += Html('th', _('Surname'), class_='ColumnSurname') + (
Html('th', _('Name'), class_='ColumnName', inline=True) Html('th', _('Name'), class_='ColumnName', inline=True)
) )
column_count = 2
# table header -- show birth column # table header -- show birth column
if showbirth: if showbirth:
trow += Html('th', _('Birth'), class_='ColumnBirth', inline=True) trow += Html('th', _('Birth'), class_='ColumnBirth', inline=True)
column_count += 1
# table header -- show death column # table header -- show death column
if showdeath: if showdeath:
trow += Html('th', _('Death'), class_='ColumnDeath', inline=True) trow += Html('th', _('Death'), class_='ColumnDeath', inline=True)
column_count += 1
# table header -- show partmer column # table header -- show partmer column
if showpartner: if showpartner:
trow += Html('th', _('Partner'), class_='ColumnPartner', inline=True) trow += Html('th', _('Partner'), class_='ColumnPartner', inline=True)
column_count += 1
# table header -- show parents column # table header -- show parents column
if showparents: if showparents:
trow += Html('th', _('Parents'), class_='ColumnParents', inline=True) trow += Html('th', _('Parents'), class_='ColumnParents', inline=True)
column_count += 1
# begin table body # begin table body
tbody = Html('tbody') tbody = Html('tbody')
@@ -1113,11 +1125,10 @@ class IndividualListPage(BasePage):
# create clear line for proper styling # create clear line for proper styling
# create footer section # create footer section
footer = self.write_footer() footer = self.write_footer(counter, hyper=True)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# and close the file
self.mywriter(indlistpage, of) self.mywriter(indlistpage, of)
class SurnamePage(BasePage): class SurnamePage(BasePage):
@@ -1271,14 +1282,12 @@ class SurnamePage(BasePage):
# add surnames table # add surnames table
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section
footer = self.write_footer() footer = self.write_footer(counter=0)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# and close the file
self.mywriter(surnamepage, of) self.mywriter(surnamepage, of)
class PlaceListPage(BasePage): class PlaceListPage(BasePage):
def __init__(self, report, title, place_handles, src_list): def __init__(self, report, title, place_handles, src_list):
@@ -1286,8 +1295,11 @@ class PlaceListPage(BasePage):
self.src_list = src_list # TODO verify that this is correct self.src_list = src_list # TODO verify that this is correct
db = report.database db = report.database
# add top of page link
counter = len(place_handles)
of = self.report.create_file("places") of = self.report.create_file("places")
placelistpage, body = self.write_header(_('Places')) placelistpage, body = self.write_header(_('Places'), hyper=True)
# begin places division # begin places division
with Html('div', class_='content', id='Places') as section: with Html('div', class_='content', id='Places') as section:
@@ -1357,11 +1369,10 @@ class PlaceListPage(BasePage):
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section
footer = self.write_footer() footer = self.write_footer(counter, hyper=True)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# and close the file
self.mywriter(placelistpage, of) self.mywriter(placelistpage, of)
class PlacePage(BasePage): class PlacePage(BasePage):
@@ -1457,11 +1468,10 @@ class PlacePage(BasePage):
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section
footer = self.write_footer() footer = self.write_footer(counter=0)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# and close the file
self.mywriter(placepage, of) self.mywriter(placepage, of)
class MediaPage(BasePage): class MediaPage(BasePage):
@@ -1556,7 +1566,7 @@ class MediaPage(BasePage):
self.copy_thumbnail(handle, photo) self.copy_thumbnail(handle, photo)
self.page_title = photo.get_description() self.page_title = photo.get_description()
media, body = self.write_header("%s - %s" % (_('Gallery'), self.page_title)) mediapage, body = self.write_header("%s - %s" % (_('Gallery'), self.page_title))
# begin GalleryDetail division # begin GalleryDetail division
gallerydetail = Html('div', class_='content', id='GalleryDetail') gallerydetail = Html('div', class_='content', id='GalleryDetail')
@@ -1747,12 +1757,11 @@ class MediaPage(BasePage):
body += (gallerydetail, fullclear) body += (gallerydetail, fullclear)
# add footer section # add footer section
footer = self.write_footer() footer = self.write_footer(counter=0)
body += footer body += footer
# send page out for processing # send page out for processing
# and close the file self.mywriter(mediapage, of)
self.mywriter(media, of)
def gallery_nav_link(self, handle, name, up=False): def gallery_nav_link(self, handle, name, up=False):
@@ -1852,12 +1861,15 @@ class SurnameListPage(BasePage):
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
db = report.database db = report.database
# amount of surnames to be created
counter = len(person_handle_list)
if order_by == self.ORDER_BY_NAME: if order_by == self.ORDER_BY_NAME:
of = self.report.create_file(filename) of = self.report.create_file(filename)
surnamelist, body = self.write_header(_('Surnames')) surnamelist, body = self.write_header(_('Surnames'), hyper=True)
else: else:
of = self.report.create_file("surnames_count") of = self.report.create_file("surnames_count")
surnamelist, body = self.write_header(_('Surnames by person count')) surnamelist, body = self.write_header(_('Surnames by person count'), hyper=True)
# begin surnames division # begin surnames division
with Html('div', class_='content', id='surnames') as section: with Html('div', class_='content', id='surnames') as section:
@@ -1960,11 +1972,10 @@ class SurnameListPage(BasePage):
# create footer section # create footer section
# add clearline for proper styling # add clearline for proper styling
# bring all body pieces together # bring all body pieces together
footer = self.write_footer() footer = self.write_footer(counter, hyper=True)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# and close the file
self.mywriter(surnamelist, of) self.mywriter(surnamelist, of)
def surname_link(self, fname, name, opt_val=None, up=False): def surname_link(self, fname, name, opt_val=None, up=False):
@@ -2014,11 +2025,10 @@ class IntroductionPage(BasePage):
# add clearline for proper styling # add clearline for proper styling
# create footer section # create footer section
footer = self.write_footer() footer = self.write_footer(counter=0)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# and close the file
self.mywriter(intropage, of) self.mywriter(intropage, of)
class HomePage(BasePage): class HomePage(BasePage):
@@ -2058,11 +2068,10 @@ class HomePage(BasePage):
# create clear line for proper styling # create clear line for proper styling
# create footer section # create footer section
footer = self.write_footer() footer = self.write_footer(counter=0)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# and close the file
self.mywriter(homepage, of) self.mywriter(homepage, of)
class SourceListPage(BasePage): class SourceListPage(BasePage):
@@ -2071,8 +2080,11 @@ class SourceListPage(BasePage):
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
db = report.database db = report.database
# add bottom and top links
counter = len(handle_set)
of = self.report.create_file("sources") of = self.report.create_file("sources")
sourcelistpage, body = self.write_header(_('Sources')) sourcelistpage, body = self.write_header(_('Sources'), hyper=True)
# begin source list division # begin source list division
with Html('div', class_='content', id='sources') as section: with Html('div', class_='content', id='sources') as section:
@@ -2121,11 +2133,10 @@ class SourceListPage(BasePage):
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section
footer = self.write_footer() footer = self.write_footer(counter=0, hyper=True)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# and close the file
self.mywriter(sourcelistpage, of) self.mywriter(sourcelistpage, of)
class SourcePage(BasePage): class SourcePage(BasePage):
@@ -2193,11 +2204,10 @@ class SourcePage(BasePage):
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section
footer = self.write_footer() footer = self.write_footer(counter=0)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# and close the file
self.mywriter(sourcepage, of) self.mywriter(sourcepage, of)
class MediaListPage(BasePage): class MediaListPage(BasePage):
@@ -2206,8 +2216,11 @@ class MediaListPage(BasePage):
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
db = report.database db = report.database
# add bottom and top links
counter = len(self.report.photo_list)
of = self.report.create_file("gallery") of = self.report.create_file("gallery")
gallery, body = self.write_header(_('Gallery')) medialistpage, body = self.write_header(_('Gallery'), hyper=True)
# begin gallery division # begin gallery division
with Html('div', class_='content', id='Gallery') as section: with Html('div', class_='content', id='Gallery') as section:
@@ -2221,16 +2234,20 @@ class MediaListPage(BasePage):
# begin gallery table and table head # begin gallery table and table head
with Html('table', class_='infolist gallerylist') as table: with Html('table', class_='infolist gallerylist') as table:
section += table section += table
with Html('thead') as thead:
# begin table head
thead = Html('thead')
table += thead table += thead
with Html('tr') as trow:
trow = Html('tr') + (
Html('th', ' ', class_='ColumnRowLabel', inline=True),
Html('th', _('Name'), class_='ColumnName', inline=True),
Html('th', _('Date'), class_='ColumnDate', inline=True)
)
thead += trow thead += trow
trow += Html('th', ' ', class_='ColumnRowLabel', inline=True)
trow += Html('th', _('Name'), class_='ColumnName', inline=True)
trow += Html('th', _('Date'), class_='ColumnDate', inline=True)
# begin table body # begin table body
with Html('tbody') as tbody: tbody = Html('tbody')
table += tbody table += tbody
index = 1 index = 1
@@ -2243,27 +2260,24 @@ class MediaListPage(BasePage):
title = media.get_description() title = media.get_description()
if not title: if not title:
title = "[untitled]" title = "[untitled]"
with Html('tr') as trow:
trow = Html('tr') + (
Html('td', index, class_='ColumnRowLabel', inline=True),
)
tbody += trow tbody += trow
with Html('td', index, class_='ColumnRowLabel', inline=True) as tcell: tcell = Html('td', class_='ColumnName') + \
trow += tcell self.media_ref_link(handle, title)
with Html('td', class_='ColumnName') as tcell:
trow += tcell
hyper = self.media_ref_link(handle, title)
tcell += hyper
with Html('td', date, class_='ColumnDate', inline=True) as tcell:
trow += tcell trow += tcell
trow += Html('td', date, class_='ColumnDate', inline=True)
index += 1 index += 1
# add footer section # add footer section
# add clearline for proper styling # add clearline for proper styling
# bring body pieces back together footer = self.write_footer(counter, hyper=True)
footer = self.write_footer()
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# and close the file self.mywriter(medialistpage, of)
self.mywriter(gallery, of)
def media_ref_link(self, handle, name, up=False): def media_ref_link(self, handle, name, up=False):
@@ -2416,11 +2430,10 @@ class DownloadPage(BasePage):
# clear line for proper styling # clear line for proper styling
# create footer section # create footer section
footer = self.write_footer() footer = self.write_footer(counter=0)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# close the file
self.mywriter(downloadpage, of) self.mywriter(downloadpage, of)
class ContactPage(BasePage): class ContactPage(BasePage):
@@ -2488,11 +2501,10 @@ class ContactPage(BasePage):
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section
footer = self.write_footer() footer = self.write_footer(counter=0)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for porcessing # send page out for porcessing
# and close the file
self.mywriter(contactpage, of) self.mywriter(contactpage, of)
class IndividualPage(BasePage): class IndividualPage(BasePage):
@@ -2606,11 +2618,10 @@ class IndividualPage(BasePage):
# add clearline for proper styling # add clearline for proper styling
# create footer section # create footer section
footer = self.write_footer() footer = self.write_footer(counter=0)
body += (fullclear, footer) body += (fullclear, footer)
# send page out for processing # send page out for processing
# and close the file
self.mywriter(indivdetpage, of) self.mywriter(indivdetpage, of)
def display_attr_list(self, attrlist=None): def display_attr_list(self, attrlist=None):
@@ -3221,12 +3232,12 @@ class IndividualPage(BasePage):
db = self.report.database db = self.report.database
# begin parents division # begin parents division
sect_parents = Html('div', id='parents', class_='subsection') with Html('div', class_='subsection', id='parents') as section:
sect_title = Html('h4', _('Parents'), inline=True) section += Html('h4', _('Parents'), inline=True)
sect_parents += sect_title
# begin parents table # begin parents table
parent_table = Html('table', class_='infolist') with Html('table', class_='infolist') as table:
section += table
first = True first = True
if parent_list: if parent_list:
@@ -3247,26 +3258,26 @@ class IndividualPage(BasePage):
break break
if not first: if not first:
trow = Html('tr') trow = Html('tr') +(
tabcol = Html('td', ' ', colspan=2, inline=True) Html('td', ' ', colspan=2, inline=True)
trow += tabcol )
parent_table += trow table += trow
else: else:
first = False first = False
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if father_handle: if father_handle:
trow = Html('tr') trow = Html('tr')
table += trow
tabcol1, tabcol2 = self.display_parent(father_handle, _('Father'), frel) tabcol1, tabcol2 = self.display_parent(father_handle, _('Father'), frel)
trow += (tabcol1, tabcol2) trow += (tabcol1, tabcol2)
parent_table += trow
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
if mother_handle: if mother_handle:
trow = Html('tr') trow = Html('tr')
table += trow
tabcol1, tabcol2 = self.display_parent(mother_handle, _('Mother'), mrel) tabcol1, tabcol2 = self.display_parent(mother_handle, _('Mother'), mrel)
trow += (tabcol1, tabcol2) trow += (tabcol1, tabcol2)
parent_table += trow
first = False first = False
if len(child_ref_list) > 1: if len(child_ref_list) > 1:
@@ -3275,22 +3286,29 @@ class IndividualPage(BasePage):
sibling.add(child_handle) # remember that we've already "seen" this child sibling.add(child_handle) # remember that we've already "seen" this child
# now that we have all natural siblings, display them... # now that we have all natural siblings, display them...
if birthorder: if len(sibling):
sibling = sort_birth_order(db, sibling, key=_PARENTS) trow = Html('tr') + (
Html('td', _('Siblings'), class_='ColumnAttribute', inline=True)
if len(sibling) > 0: )
trow = Html('tr') table += trow
tabcol1 = Html('td', _('Siblings'), class_='ColumnAttribute', inline=True) tcell = Html('td', class_='ColumnValue')
tabcol2 = Html('td', class_='ColumnValue') trow += tcell
ordered = Html('ol') ordered = Html('ol')
tcell += ordered
if birthorder:
kids = []
kids = sorted(add_birthdate(db, sibling))
for birth_date, child_handle in kids:
if child_handle != self.person.handle:
ordered += self.display_child_link(child_handle)
else:
for child_handle in sibling: for child_handle in sibling:
if child_handle != self.person.handle: if child_handle != self.person.handle:
kid_link = self.display_child_link(child_handle) ordered += self.display_child_link(child_handle)
ordered += kid_link
tabcol2 += ordered
trow += (tabcol1, tabcol2)
parent_table += trow
# Also try to identify half-siblings # Also try to identify half-siblings
half_siblings = set() half_siblings = set()
@@ -3324,26 +3342,32 @@ class IndividualPage(BasePage):
# we have a new half sibling # we have a new half sibling
half_siblings.add(half_child_handle) half_siblings.add(half_child_handle)
if birthorder: # now that we have all half- siblings, display them...
half_siblings = sort_birth_order(db, half_siblings, key=_PARENTS)
# now that we have all of the half-siblings, print them out
if len(half_siblings): if len(half_siblings):
trow = Html('tr') trow = Html('tr') + (
tabcol1 = Html('td', _('Half Siblings'), class_='ColumnAttribute', inline=True) Html('td', _('Half Siblings'), class_='ColumnAttribute', inline=True),
tabcol2 = Html('td', class_='ColumnValue') )
table += trow
tcell = Html('td', class_='ColumnValue')
trow += tcell
ordered = Html('ol') ordered = Html('ol')
tcell += ordered
if birthorder:
kids = []
kids = sorted(add_birthdate(db, half_siblings))
for birth_date, child_handle in kids:
ordered += self.display_child_link(child_handle)
else:
for child_handle in half_siblings: for child_handle in half_siblings:
kid_link = self.display_child_link(child_handle) ordered += self.display_child_link(child_handle)
ordered += kid_link
tabcol2 += ordered
trow += (tabcol1, tabcol2)
parent_table += trow
# get step-siblings # get step-siblings
step_siblings = set()
if showallsiblings: if showallsiblings:
step_siblings = set()
# to find the step-siblings, we need to identify # to find the step-siblings, we need to identify
# all of the families that can be linked back to # all of the families that can be linked back to
@@ -3408,28 +3432,31 @@ class IndividualPage(BasePage):
# we have a new step sibling # we have a new step sibling
step_siblings.add(step_child_handle) step_siblings.add(step_child_handle)
if birthorder: # now that we have all step- siblings, display them...
step_iblings = sort_birth_order(db, step_siblings, key=_PARENTS) if len(step_siblings):
trow = Html('tr') + (
# now that we have all of the step-siblings, print them out Html('td', _('Step Siblings'), class_='ColumnAttribute', inline=True)
if len(step_siblings) > 0: )
trow = Html('tr') table += trow
tabcol1 = Html('td', _('Step Siblings'), class_='ColumnAttribute', inline=True) tcell = Html('td', class_='ColumnValue')
tabcol2 = Html('td', class_='ColumnValue') trow += tcell
ordered = Html('ol') ordered = Html('ol')
tcell += ordered
if birthorder:
kids = []
kids = sorted(add_birthdate(db, step_siblings))
for birth_date, child_handle in kids:
ordered += self.display_child_link(child_handle)
else:
for child_handle in step_siblings: for child_handle in step_siblings:
kid_link = self.display_child_link(child_handle) ordered += self.display_child_link(child_handle)
ordered += kid_link
tabcol2 += ordered
trow += (tabcol1, tabcol2)
parent_table += trow
# add table to parent division # return parents division to its caller
sect_parents += parent_table return section
# return division to its caller
return sect_parents
def display_ind_families(self): def display_ind_families(self):
""" """
@@ -3454,19 +3481,24 @@ class IndividualPage(BasePage):
self.display_partner(family, table) self.display_partner(family, table)
childlist = family.get_child_ref_list() childlist = family.get_child_ref_list()
if childlist: if childlist:
trow = Html('tr') trow = Html('tr') + (
Html('td', ' ', class_='ColumnType', inline=True),
Html('td', _('Children'), class_='ColumnAttribute', inline=True)
)
table += trow table += trow
tcell1 = Html('td', ' ', class_='ColumnType', inline=True) tcell = Html('td', class_='ColumnValue')
tcell2 = Html('td', _('Children'), class_='ColumnAttribute', inline=True) trow += tcell
tcell3 = Html('td', class_='ColumnValue')
trow += (tcell1, tcell2, tcell3)
ordered = Html('ol') ordered = Html('ol')
tcell3 += ordered tcell += ordered
childlist = [child_ref.ref for child_ref in childlist] childlist = [child_ref.ref for child_ref in childlist]
# TODO. Optionally sort on birthdate
if self.report.options['birthorder']: if self.report.options['birthorder']:
childlist = sort_birth_order(db, childlist, key=_FAMILY) kids = []
kids = sorted(add_birthdate(db, childlist))
for birth_date, child_handle in kids:
ordered += self.display_child_link(child_handle)
else:
for child_handle in childlist: for child_handle in childlist:
ordered += self.display_child_link(child_handle) ordered += self.display_child_link(child_handle)
@@ -4658,14 +4690,21 @@ def alphabet_navigation(db, handle_list, key):
if not sorted_first_letter: if not sorted_first_letter:
return None return None
# begin alphabet division and set up table # begin alphabet division
alphabet = Html('div', id='alphabet') with Html('div', id='alphabet') as section:
alpha_table = Html('table', class_='alphabet')
# begin alphabet table
with Html('table', class_='alphabet infolist') as table:
section += table
num_ltrs = len(sorted_first_letter) num_ltrs = len(sorted_first_letter)
if num_ltrs <= 26: if num_ltrs <= 26:
trow = Html('tr') trow = Html('tr')
table += trow
unordered = Html('ul') unordered = Html('ul')
trow += unordered
for ltr in sorted_first_letter: for ltr in sorted_first_letter:
title_str = _('Surnames') if key == 0 else _('Places') title_str = _('Surnames') if key == 0 else _('Places')
if lang_country == "sv_SE" and ltr == u'V': if lang_country == "sv_SE" and ltr == u'V':
@@ -4679,17 +4718,17 @@ def alphabet_navigation(db, handle_list, key):
Html('a', ltr, href='#%s' % ltr, title=title_str) Html('a', ltr, href='#%s' % ltr, title=title_str)
) )
# bring table pieces back together
trow += unordered
alpha_table += trow
else: else:
nrows = (num_ltrs / 26) + 1 nrows = (num_ltrs / 28) + 1
index = 0 index = 0
for rows in range(0, nrows): for rows in range(0, nrows):
trow = Html('tr') trow = Html('tr')
table += trow
unordered = Html('ul') unordered = Html('ul')
trow += unordered
cols = 0 cols = 0
while (cols <= 26 and index < num_ltrs): while (cols <= 28 and index < num_ltrs):
ltr = sorted_first_letter[index] ltr = sorted_first_letter[index]
title_str = _('Surnames') if key == 0 else _('Places') title_str = _('Surnames') if key == 0 else _('Places')
if lang_country == "sv_SE" and letter == u'V': if lang_country == "sv_SE" and letter == u'V':
@@ -4705,22 +4744,14 @@ def alphabet_navigation(db, handle_list, key):
cols += 1 cols += 1
index += 1 index += 1
# bring table pieces to table row
trow += unordered
# attach table row to table
alpha_table += trow
# close the table
alphabet += alpha_table
# return alphabet navigation to its callers # return alphabet navigation to its callers
return alphabet return section
def sort_birth_order(db, childlist, key): def add_birthdate(db, childlist):
""" """
This will sort a list of child handles in birth order This will sort a list of child handles in birth order
""" """
sorted_children = [] sorted_children = []
for child_handle in childlist: for child_handle in childlist:
child = db.get_person_from_handle(child_handle) child = db.get_person_from_handle(child_handle)
@@ -4731,36 +4762,33 @@ def sort_birth_order(db, childlist, key):
birth_event = db.get_event_from_handle(birth_ref.ref) birth_event = db.get_event_from_handle(birth_ref.ref)
birth_date = birth_event.get_date_object() birth_date = birth_event.get_date_object()
if birth_date is not None: if birth_date is not None:
if 1423 < birth_date.get_year() <= 2100:
year = birth_date.get_year() year = birth_date.get_year()
if year:
year = str(year)
else: else:
year = 1423 year = str(1001)
if 0 < birth_date.get_month() <= 12:
month = birth_date.get_month() month = birth_date.get_month()
if month:
if 0 < month < 10:
month = '0' + str(month)
else: else:
month = 1 month = str(month)
if 0 < birth_date.get_day() <= 31: else:
month = str(12)
day = birth_date.get_day() day = birth_date.get_day()
if day:
if 0 < day < 10:
day = '0' + str(day)
else: else:
day = 1 day = str(day)
else: else:
year, month, day = 1423, 1, 1 day = str(31)
date_obj = datetime.date(year, month, day) else:
year, month, day = str(1001), str(12), str(31)
date_obj = year + month + day
sorted_children.append((date_obj, child_handle)) sorted_children.append((date_obj, child_handle))
sorted_children.sort() return sorted_children
if key ==_FAMILY:
childlist = []
else:
childlist = set()
for birth_date, handle in sorted_children:
if key == _FAMILY:
childlist.append(handle)
else:
childlist.add(handle)
return childlist
# ------------------------------------------ # ------------------------------------------
# #