Re-did Internet Address Book. it is now Address Book. Current styles for my work on Address Book in stylesheet.

svn: r13529
This commit is contained in:
Rob G. Healey 2009-11-09 04:37:49 +00:00
parent 19522ec975
commit 232bb80d6c
2 changed files with 399 additions and 214 deletions

View File

@ -383,7 +383,7 @@ table.infolist tr td a {
color: #000; color: #000;
} }
table.infolist tr.BeginLetter td, table.infolist tr.BeginSurname td { table.infolist tr.BeginLetter td, table.infolist tr.BeginSurname td {
border-top:solid 1px #228A22; border-top:solid 1px #5D835F;
} }
table.infolist tr td.ColumnLetter { table.infolist tr td.ColumnLetter {
width:3%; width:3%;
@ -891,32 +891,48 @@ div#RepositoryList table.repolist tbody tr td.ColumnName {
background-color: #FFF; background-color: #FFF;
} }
/* Internet Address Book /* Address Book
------------------------------------------------------ */ ------------------------------------------------------ */
div#InternetAddressBook { div#AddressBookList, AddressBookDetail {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
div#InternetAddressBook table.addressbook { div#AddressBookList table.addressbook {
margin: .3em 0 .3em 0; margin: .3em 0 .3em 0;
} }
div#InternetAddressBook table.addressbook tbody tr.BeginName { div#AddressBookList table.addressbook tbody tr.Totals {
border-top: solid 1px #000; border: solid 1px #5D835F;
} }
div#InternetAddressBook table.addressbook tbody tr td { div#AddressBookList tble.addressbook tbody tr.Totals td {
background-color: #FFF; text-align: left;
border-bottom: dashed 1px #000;
}
div#InternetAddressBook table.addressbook tbody tr td.ColumnType {
background-color: #D8F3D6; background-color: #D8F3D6;
width: 15%;
} }
div#InternetAddressBook table.addressbook tbody tr td.ColumnName { div#AddressBookList table.addressbook tbody tr td {
width: 30%; background-color: #D8F3D6;
text-align: center;
border: solid 1px #5D835F;
} }
div#InternetAddressBook table.addressbook tbody tr td.ColumnLink { div#AddressBookList table.addressbook tbody tr td.ColumnRowLabel {
width: 4%;
}
div#AddressBookList table.addressbook tbody tr td.ColumnName {
background-color: #FFF;
text-align: left;
width: 70%; width: 70%;
} }
div#AddressBookList table.addressbook tbody tr td.ColumnName a {
display: block;
padding: 6px 0px 6px 0px;
}
div#AddressBookList table.addressbook tbody tr td.ColumnAddress {
width: 8%;
}
div#AddressBookList table.adressbook tbody tr td.ColumnResidence {
width: 8%;
}
div#AddressBookList table.addressbook tbody tr td.ColumnWebLinks {
width: 8%;
}
/* Subsections /* Subsections
----------------------------------------------------- */ ----------------------------------------------------- */
@ -997,15 +1013,13 @@ table.infolist tbody tr td.ColumnValue p {
/* Subsections : Attributes /* Subsections : Attributes
----------------------------------------------------- */ ----------------------------------------------------- */
div#attributes { } div#attributes {
margin: 0;
padding: 0;
}
table.attrlist { table.attrlist {
width: 100%; width: 100%;
} }
table.attrlist thead tr th {
font-weight: bold;
text-transform: uppercase;
}
table.attrlist tbody tr { table.attrlist tbody tr {
border: solid 1px #5D835F; border: solid 1px #5D835F;
} }
@ -1015,6 +1029,9 @@ table.attrlist tbody tr td {
table.attrlist tbody tr td.ColumnType { table.attrlist tbody tr td.ColumnType {
width: 200px; width: 200px;
} }
table.attrlist tbody tr td.ColumnAttribute {
width: 10%;
}
table.attrlist tbody tr td.ColumnValue { table.attrlist tbody tr td.ColumnValue {
width: 250px; width: 250px;
} }
@ -1106,40 +1123,39 @@ table.ldsordlist tbody tr td.ColumnLDSSources {
/* Subsections : Addresses /* Subsections : Addresses
----------------------------------------------------- */ ----------------------------------------------------- */
div#Addresses { div#Addresses {
padding-bottom:0; margin: 0;
padding: 0;
} }
div#Addresses table.infolist { div#Addresses table.infolist {
font-size:.35cm; font-size: 12px;
background-color: #FFF; background- color: #D8F3D6;
} }
div#Addresses table.infolist tbody tr td { div#Addresses table.infolist tbody tr td {
border-bottom:solid 1px #000; border-bottom: solid 1px #5D835F;
padding-top:.4em;
padding-bottom:.4em;
} }
div#Addresses table.infolist tbody tr td.ColumnDate { div#Addresses table.infolist tbody tr td.ColumnDate {
width:15%; width: 15%;
} }
div#Addresses table.infolist tbody tr td.ColumnStreetAddress { div#Addresses table.infolist tbody tr td.ColumnStreetAddress {
width:30%; width: 30%;
} }
div#Addresses table.infolist tbody tr td.ColumnCity { div#Addresses table.infolist tbody tr td.ColumnCity {
width:8%; width: 8%;
} }
div#Addresses table.infolist tbody tr td.ColumnCounty { div#Addresses table.infolist tbody tr td.ColumnCounty {
with:8%; with: 8%;
} }
div#Addresses table.infolist tbody tr td.ColumnState { div#Addresses table.infolist tbody tr td.ColumnState {
width:12%; width: 12%;
} }
div#Addresses table.infolist tbody tr td.ColumnCntry { div#Addresses table.infolist tbody tr td.ColumnCntry {
width:5%; width: 5%;
} }
div#Addresses table.infolist tbody tr td.ColumnPostalcode { div#Addresses table.infolist tbody tr td.ColumnPostalcode {
width:10%; width: 10%;
} }
div#Addresses table.infolist tbody tr td.ColumnPhone { div#Addresses table.infolist tbody tr td.ColumnPhone {
width:15%; width: 15%;
} }
/* Subsections : Gallery /* Subsections : Gallery

View File

@ -99,7 +99,6 @@ from gui.utils import ProgressMeter
import ThumbNails import ThumbNails
import ImgManip import ImgManip
import Mime import Mime
from Utils import probably_alive, xml_lang
from QuestionDialog import ErrorDialog, WarningDialog from QuestionDialog import ErrorDialog, WarningDialog
from BasicUtils import name_displayer as _nd from BasicUtils import name_displayer as _nd
from DateHandler import displayer as _dd from DateHandler import displayer as _dd
@ -275,11 +274,13 @@ class BasePage(object):
def __init__(self, report, title, gid = None): def __init__(self, report, title, gid = None):
""" """
report - instance of NavWebReport Holds all of the things that each class needs to have...
title - text for the <title> tag
gid - Gramps ID
"""
@param: report - instance of NavWebReport
@param: title - text for the title
@param: gid - Gramps ID
"""
self.up = False
# class to do conversion of styled notes to html markup # class to do conversion of styled notes to html markup
self._backend = HtmlBackend() self._backend = HtmlBackend()
@ -293,7 +294,6 @@ class BasePage(object):
self.author = Utils.get_researcher().get_name() self.author = Utils.get_researcher().get_name()
if self.author: if self.author:
self.author = self.author.replace(',,,', '') self.author = self.author.replace(',,,', '')
self.up = False
# TODO. All of these attributes are not necessary, because we have # TODO. All of these attributes are not necessary, because we have
# also the options in self.options. Besides, we need to check which # also the options in self.options. Besides, we need to check which
@ -305,7 +305,7 @@ class BasePage(object):
self.create_media = report.options['gallery'] self.create_media = report.options['gallery']
self.inc_events = report.options['inc_events'] self.inc_events = report.options['inc_events']
self.exiftagsopt = report.options['exiftagsopt'] self.exiftagsopt = report.options['exiftagsopt']
def get_birth_date(self, db, person): def get_birth_date(self, db, person):
""" Will return a date object for a person's birthdate """ """ Will return a date object for a person's birthdate """
@ -697,14 +697,36 @@ class BasePage(object):
# return hyperlink to its callers # return hyperlink to its callers
return hyper return hyper
def dump_addresses(self, addrobj, showsrc = True): def display_addr_list(self, addrlist, showsrc):
"""
display a person's addresses ...
@param: addrlist -- a list of address handles
@param: showsrc -- whether to show sources or not?
"""
if not addrlist:
return None
# begin addresses division and title
with Html("div", class_ = "subsection", id = "Addresses") as section:
section += Html("h4", _("Addresses"), inline = True)
# write out addresses()
section += self.dump_addresses(addrlist, showsrc)
# return address division to its caller
return section
def dump_addresses(self, addrlist, showsrc):
""" """
will display an object's addresses, url list, note list, will display an object's addresses, url list, note list,
and source references. and source references.
@param: addrobj = either person or repository address object @param: addrlist = either person or repository address list
@param: showsrc = True -- person @param: showsrc = True -- person
False -- repository False -- repository
None -- do not show sources
""" """
def write_address_header(showsrc): def write_address_header(showsrc):
@ -723,7 +745,7 @@ class BasePage(object):
# if showsrc = True -- an individual's address else repository # if showsrc = True -- an individual's address else repository
if showsrc: if showsrc:
addr_header.append([SHEAD, 'Sources']) addr_header.append([SHEAD, "Sources"])
for (label, colclass) in addr_header: for (label, colclass) in addr_header:
trow += Html("th", label, class_ = "Column%s" % colclass, inline = True) trow += Html("th", label, class_ = "Column%s" % colclass, inline = True)
@ -738,9 +760,13 @@ class BasePage(object):
with Html("table") as table: with Html("table") as table:
summaryarea += table summaryarea += table
# get table class based on either person or repository # get table class based on showsrc
table.attr = 'class = "infolist addrlist"' if showsrc \ if showsrc == True:
else 'class = "infolist repolist"' table.attr = 'class = "infolist addrlist"'
elif showsrc == False:
table.attr = 'class = "infolist repolist"'
else:
table.attr = 'class = "infolist addressbook"'
# begin table head # begin table head
thead = Html("thead") thead = Html("thead")
@ -754,7 +780,7 @@ class BasePage(object):
table += tbody table += tbody
# get address list from an object; either repository or person # get address list from an object; either repository or person
for address in addrobj.get_address_list(): for address in addrlist:
trow = Html("tr") trow = Html("tr")
tbody += trow tbody += trow
@ -780,13 +806,27 @@ class BasePage(object):
trow += Html("td", value, class_ = "Column%s" % colclass, inline = True) trow += Html("td", value, class_ = "Column%s" % colclass, inline = True)
# address: notelist # address: notelist
notelist = self.display_note_list(address.get_note_list()) if showsrc is not None:
if notelist is not None: notelist = self.display_note_list(address.get_note_list())
summaryarea += notelist if notelist is not None:
summaryarea += notelist
# return summaryarea division to its callers # return summaryarea division to its callers
return summaryarea return summaryarea
def addressbook_link(self, handle, up = False):
""" createsa hyperlink for an address book link based on person's handle """
db = self.report.database
url = self.report.build_url_fname_html(handle, "addr", up)
person = db.get_person_from_handle(handle)
person_name = self.get_name(person)
addr_hyper = Html("a", person_name, href = url, title = html_escape(person_name))
# return addressbook hyperlink to its caller
return addr_hyper
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
@ -954,7 +994,7 @@ class BasePage(object):
db = self.report.database db = self.report.database
# Header constants # Header constants
xmllang = xml_lang() xmllang = Utils.xml_lang()
_META1 = 'name="generator" content="%s %s %s"' % ( _META1 = 'name="generator" content="%s %s %s"' % (
const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE
) )
@ -991,7 +1031,7 @@ class BasePage(object):
# Link to GRAMPS favicon # Link to GRAMPS favicon
fname = "/".join(['images', 'favicon.ico']) fname = "/".join(['images', 'favicon.ico'])
url5 = self.report.build_url_image('favicon.ico', 'images', self.up) url5 = self.report.build_url_image("favicon.ico", "images", self.up)
# create stylesheet and favicon links # create stylesheet and favicon links
links = [Html("link", href = url5, type = "image/x-icon", rel = "shortcut icon"), links = [Html("link", href = url5, type = "image/x-icon", rel = "shortcut icon"),
@ -1052,7 +1092,7 @@ class BasePage(object):
('contact', _("Contact"), self.report.use_contact), ('contact', _("Contact"), self.report.use_contact),
('sources', SHEAD, True), ('sources', SHEAD, True),
('repositories', _("Repositories"), inc_repos), ('repositories', _("Repositories"), inc_repos),
("Internet_Address_Book", _("Internet Address Book"), self.report.add_book) ("addressbook", _("Address Book"), self.report.addressbook)
] ]
navigation = Html("div", id = 'navigation') navigation = Html("div", id = 'navigation')
@ -1095,11 +1135,11 @@ class BasePage(object):
elif nav_text == _("Media"): elif nav_text == _("Media"):
if "img" in self.report.cur_fname: if "img" in self.report.cur_fname:
cs = True cs = True
elif nav_text == _("Internet Address Book"): elif nav_text == _("Address Book"):
if "iab" in self.report.cur_fname: if "addr" in self.report.cur_fname:
cs = True cs = True
cs = cs and 'class="CurrentSection"' or '' cs = 'class = "CurrentSection"' if cs else ""
ul += (Html("li", attr = cs, inline = True) + ul += (Html("li", attr = cs, inline = True) +
Html("a", nav_text, href = url) Html("a", nav_text, href = url)
) )
@ -1270,11 +1310,6 @@ class BasePage(object):
descr = uri descr = uri
_type = url.get_type() _type = url.get_type()
uri = url.get_path()
descr = url.get_description()
if not descr:
descr = uri
list = Html("li") list = Html("li")
ordered += list ordered += list
@ -1306,22 +1341,23 @@ class BasePage(object):
# return web links to its caller # return web links to its caller
return section return section
# Only used in IndividualPage.display_ind_sources
# and MediaPage.display_media_sources
def display_source_refs(self, bibli): def display_source_refs(self, bibli):
if bibli.get_citation_count() == 0: if bibli.get_citation_count() == 0:
return None return None
db = self.report.database db = self.report.database
with Html("div", id = "sourcerefs", class_ = "subsection") as section: # begin Source References division and title
with Html("div", id = "sourcerefs", class_ = "subsection") as section:
section += Html("h4", _("Source References"), inline = True) section += Html("h4", _("Source References"), inline = True)
# begin ordered list ordered = Html("ol")
ordered1 = Html("ol")
section += ordered1
cindex = 0 cindex = 0
for citation in bibli.get_citation_list(): for citation in bibli.get_citation_list():
cindex += 1
cindex += 1
# Add this source to the global list of sources to be displayed # Add this source to the global list of sources to be displayed
# on each source page. # on each source page.
lnk = (self.report.cur_fname, self.page_title, self.gid) lnk = (self.report.cur_fname, self.page_title, self.gid)
@ -1335,35 +1371,40 @@ class BasePage(object):
# Add this source and its references to the page # Add this source and its references to the page
source = db.get_source_from_handle(shandle) source = db.get_source_from_handle(shandle)
title = source.get_title() title = source.get_title()
list1 = Html("li")
ordered1 += list1
hyper = self.source_link(source.handle, "sref%d" % cindex, title, source.gramps_id, True)
list1 += hyper
ordered2 = Html("ol") list = Html("li", inline = True)
list1 += ordered2
hyper = (Html("a", name = "sref%d" % cindex) +
self.source_link(source.handle, title, source.gramps_id, True)
)
list += hyper
ordered1 = Html("ol")
list += ordered1
for key, sref in citation.get_ref_list(): for key, sref in citation.get_ref_list():
tmp = [] tmp = []
confidence = Utils.confidence.get(sref.confidence, _("Unknown")) confidence = Utils.confidence.get(sref.confidence, _('Unknown'))
if confidence == _("Normal"): if confidence == _('Normal'):
confidence = None confidence = None
for (label, data) in [(DHEAD, format_date(sref.date)), for (label, data) in [(_("Date"), format_date(sref.date)),
(_("Page"), sref.page), (_("Page"), sref.page),
(_("Confidence"), confidence)]: (_("Confidence"), confidence)]:
if data: if data:
tmp.append("%s: %s" % (label, data)) tmp.append("%s: %s" % (label, data))
notelist = sref.get_note_list() notelist = sref.get_note_list()
for notehandle in notelist: for notehandle in notelist:
note = db.get_note_from_handle(notehandle) note = db.get_note_from_handle(notehandle)
note_text = self.get_note_format(note) note_text = self.get_note_format(note)
tmp.append("%s: %s" % (_("Text"), note_text)) tmp.append("%s: %s" % (_('Text'), note_text))
if len(tmp) > 0: if len(tmp) > 0:
list2 = (Html("li") +
Html("a", '; &nbsp; '.join(tmp), name = "sref%d%s" % (cindex, key), inline = True) list1 = Html("li")
) ordered1 += list1
ordered2 += list2
hyper1 = Html("a", '; &nbsp; '.join(tmp), name = "sref%d%s" % (cindex, key))
list1 += hyper1
# return section to its callers # return section to its callers
return section return section
@ -1498,6 +1539,75 @@ class BasePage(object):
# return hyperlink to its callers # return hyperlink to its callers
return hyper return hyper
def dump_place(self, place, table, gid):
""" dump a place from the database """
if not self.noid and gid:
trow = Html("tr") + (
Html("td", GRAMPSID, class_ = "ColumnAttribute", inline = True),
Html("td", gid, class_ = "ColumnValue", inline = True)
)
table += trow
if place.main_loc:
ml = place.get_main_location()
if ml and not ml.is_empty():
for val in [
(LATITUDE, place.lat),
(LONGITUDE, place.long),
(STREET, ml.street),
(CITY, ml.city),
(PARISH, ml.parish),
(COUNTY, ml.county),
(STATE, ml.state),
(POSTAL, ml.postal),
(COUNTRY, ml.country),
(LOCATIONS, place.get_alternate_locations() ) ]:
if val[1]:
trow = Html("tr") + (
Html("td", val[0], class_ = "ColumnAttribute", inline = True),
Html("td", val[1], class_ = "ColumnValue", inline = True)
)
table += trow
# return place table to its callers
return table
def dump_residence(self, has_res):
""" creates a residence from the daTABASE """
if not has_res:
return None
db = self.report.database
# begin residence division
with Html("div", id = "Residence", class_ = "content") as residence:
residence += Html("h4", _("Residence"), inline = True)
with Html("table", class_ = "infolist place") as table:
residence += table
place_handle = has_res.get_place_handle()
if place_handle:
place = db.get_place_from_handle(place_handle)
if place:
self.dump_place(place, table, place.gramps_id)
descr = has_res.get_description()
if descr:
with Html("table", class_ = "infolist") as table:
residence += table
trow = Html("tr") + (
Html("td", DESCRHEAD, class_ = "ColumnAttribute", inline = True),
Html("td", descr, class_ = "ColumnValue")
)
table += trow
# return information to its callers
return residence
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
# # Web Page Fortmatter and writer # # Web Page Fortmatter and writer
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
@ -1951,6 +2061,7 @@ class PlaceListPage(BasePage):
class PlacePage(BasePage): class PlacePage(BasePage):
def __init__(self, report, title, place_handle, src_list, place_list): def __init__(self, report, title, place_handle, src_list, place_list):
""" creates the individual place pages """
db = report.database db = report.database
place = db.get_place_from_handle(place_handle) place = db.get_place_from_handle(place_handle)
@ -1981,33 +2092,8 @@ class PlacePage(BasePage):
with Html("table", class_ = "infolist place") as table: with Html("table", class_ = "infolist place") as table:
summaryarea += table summaryarea += table
if not self.noid: # list the place
trow = Html("tr") + ( self.dump_place(place, table, place.gramps_id)
Html("td", GRAMPSID, class_ = "ColumnAttribute", inline = True),
Html("td", place.gramps_id, class_ = "ColumnValue", inline = True)
)
table += trow
if place.main_loc:
ml = place.main_loc
for val in [
(LATITUDE, place.lat),
(LONGITUDE, place.long),
(STREET, ml.street),
(CITY, ml.city),
(PARISH, ml.parish),
(COUNTY, ml.county),
(STATE, ml.state),
(POSTAL, ml.postal),
(COUNTRY, ml.country),
(LOCATIONS, place.get_alternate_locations() ) ]:
if val[1]:
trow = Html("tr") + (
Html("td", val[0], class_ = "ColumnAttribute", inline = True),
Html("td", val[1], class_ = "ColumnValue", inline = True)
)
table += trow
# place gallery # place gallery
if self.create_media: if self.create_media:
@ -3314,8 +3400,8 @@ class IndividualPage(BasePage):
if sect5 is not None: if sect5 is not None:
individualdetail += sect5 individualdetail += sect5
# display address(es) # display address(es) and show sources if any
sect6 = self.display_addresses() sect6 = self.display_addr_list(self.person.get_address_list(), True)
if sect6 is not None: if sect6 is not None:
individualdetail += sect6 individualdetail += sect6
@ -3751,7 +3837,7 @@ class IndividualPage(BasePage):
birth_date = birth.get_date_object() birth_date = birth.get_date_object()
if birth_date is not None and birth_date != Date.EMPTY: if birth_date is not None and birth_date != Date.EMPTY:
alive = probably_alive(self.person, db, date.Today() ) alive = Utils.probably_alive(self.person, db, date.Today() )
death_date = None death_date = None
death_ref = self.person.get_death_ref() death_ref = self.person.get_death_ref()
@ -3845,25 +3931,6 @@ class IndividualPage(BasePage):
# return section to its caller # return section to its caller
return section return section
def display_addresses(self):
"""
display a person's addresses ...
"""
alist = self.person.get_address_list()
if not alist:
return None
# begin addresses division and title
with Html("div", class_ = "subsection", id = "Addresses") as section:
section += Html("h4", _("Addresses"), inline = True)
# write out addresses()
section += self.dump_addresses(self.person)
# return address division to its caller
return section
def display_lds_ordinance(self, person): def display_lds_ordinance(self, person):
""" """
display LDS information for a person or family display LDS information for a person or family
@ -4533,7 +4600,7 @@ class RepositoryPage(BasePage):
table += trow table += trow
# repository: address(es) # repository: address(es)
addresses = self.dump_addresses(repo, False) addresses = self.dump_addresses(repo.get_address_list(), False)
if addresses is not None: if addresses is not None:
repositorydetail += addresses repositorydetail += addresses
@ -4556,115 +4623,172 @@ class RepositoryPage(BasePage):
# and close the file # and close the file
self.XHTMLWriter(repositorypage, of) self.XHTMLWriter(repositorypage, of)
class InternetAddressBook(BasePage): class AddressBookListPage(BasePage):
"""
Will Create an Internet Address Book of people's web sites and email addresses
"""
def __init__(self, report, title, ind_list, iab_progress): def __init__(self, report, title, has_url_address):
"""
Create a list of individual's that have either internet addresses or
address/ Residence events
@param: has_url_address -- a list of (sort_name, person_handle, has_add, has_rtes, and has_url
"""
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
db = report.database db = report.database
# Name the file, and create it # Name the file, and create it
of = self.report.create_file("Internet_Address_Book") of = self.report.create_file("addressbook")
# Add xml, doctype, meta and stylesheets # Add xml, doctype, meta and stylesheets
iabpage, body = self.write_header(_("Internet Address Book")) addressbooklistpage, body = self.write_header("%s - %s" % (title, _("Address Book List")))
# begin page division # begin AddressBookList division
with Html("div", class_ = "content", id = "InternetAddressBook") as addbook: with Html("div", class_ = "content", id = "AddressBookList") as addressbooklist:
body += addbook body += addressbooklist
# Internet Address Book Page message # Internet Address Book Page message
msg = _("This page contains an index of all the individuals in the " msg = _("This page contains an index of all the individuals in the "
"database, sorted by their GRAMPS ID. Selecting the person&#8217;s " "database, sorted by their surname. Selecting the person&#8217;s "
"name will take you to that person&#8217;s individual page. " "name will take you to their Address Book&#8217;s individual page.")
"Selecting a link will take you to their website or e-mail address.") addressbooklist += Html("p", msg, id = "description")
addbook += Html("p", msg, id = "description")
# begin Address Book table # begin Address Book table
with Html("table", class_ = "infolist addressbook") as table: with Html("table", class_ = "infolist addressbook") as table:
addbook += table addressbooklist += table
thead = Html("thead") thead = Html("thead")
table += thead table += thead
trow = Html("tr") + ( trow = Html("tr")
Html("th", THEAD, class_ = "ColumnType", inline = True),
Html("th", _("Name"), class_ = "ColumnName", inline = True),
Html("th", _("Link"), class_ = "ColumnLink", inline = True)
)
thead += trow thead += trow
for (label, colclass) in [
["&nbsp;", "RowLabel"],
[_("Name"), "Name"],
[_("Address"), "Address"],
[_("Residence"), "Residence"],
[_("Web Links"), "WebLinks"] ]:
trow += Html("th", label, class_ = "Column%s" % colclass, inline = True)
tbody = Html("tbody") tbody = Html("tbody")
table += tbody table += tbody
for person_handle in ind_list: # local counters for total line
iab_progress.step() index, countadd, countres, counturl = 0, 0, 0, 0
for (sort_name, person_handle, has_add, has_res, has_url) in has_url_address:
person = db.get_person_from_handle(person_handle) person = db.get_person_from_handle(person_handle)
urllist = person.get_url_list() index += 1
first = True address = None
for url in urllist: residence = None
weblinks = None
trow = Html("tr") # has address but no residence event
tbody += trow if has_add and not has_res:
address = "X"
countadd += 1
# Internet link type # has residence, but no addresses
_type = url.get_type() elif has_res and not has_add:
trow += Html("td", str(_type), class_ = "ColumnType", inline = True) residence = "X"
countres += 1
if first: # has residence and addresses too
trow.attr = 'class = "BeginName"' elif has_add and has_res:
address = "X"
residence = "X"
countadd += 1
countres += 1
person_url = self.report.build_url_fname_html(person.handle, "ppl", False) # has Web Links
person_hyper = self.person_link(person_url, person, True, gid = person.gramps_id) if has_url:
else: weblinks = "X"
person_hyper = "&nbsp;" counturl += 1
first = False
trow += Html("td", person_hyper, class_ = "ColumnName") trow = Html("tr")
tbody += trow
uri = url.get_path() for (colclass, data) in [
descr = url.get_description() ["RowLabel", index],
if not descr: ["Name", self.addressbook_link(person_handle)],
descr = uri ["Address", address],
["Residence", residence],
tcell = Html("td", class_ = "ColumnLink") ["WebLinks", weblinks] ]:
trow += tcell data = data or "&nbsp;"
# Email address trow += Html("td", data, class_ = "Column%s" % colclass, inline = True)
if _type == UrlType.EMAIL:
if not uri.startswith("mailto:"):
tcell += Html("a",descr, href = 'mailto: %s' % uri)
else:
tcell += Html("a", descr, href = "%s" % uri)
# Web Site address # create totals row for table
elif _type == UrlType.WEB_HOME: trow = Html("tr", class_ = "Totals") + (
if not uri.startswith("http://"): Html("td", _("Total"), classs_ = "ColumnRowlabel", inline = True),
tcell += Html("a", descr, href = 'http://%s' % uri) Html("td", index, class_ = "ColumnName", inline = True),
else: Html("td", countadd, class_ = "ColumnAddress", inline = True),
tcell += Html("a", href = "%s" % uri) Html("td", countres, class_ = "ColumnResidence", inline = True),
Html("td", counturl, class_ = "ColumnWebLinks", inline = True)
# FTP server address )
elif _type == UrlType.WEB_FTP: tbody += trow
if not uri.startswith("ftp://"):
tcell += Html("a", descr, href = 'ftp://%s' % uri)
else:
tcell += Html("a", drscr, href = "%s" % uri)
# custom type
else:
tcell += Html("a", descr, href = uri)
# Add footer and clearline # Add footer and clearline
footer = self.write_footer() footer = self.write_footer()
body += (fullclear, footer) body += (fullclear, footer)
# write the file and close it # send the page out for processing
self.XHTMLWriter(iabpage, of) # and close the file
self.XHTMLWriter(addressbooklistpage, of)
class AddressBookPage(BasePage):
def __init__(self, report, title, person_handle, has_add, has_res, has_url):
"""
Creates the individual address book pages
@parm: title = title for this report
@param: has_add -- a list of address handles or None
@param: has_res -- a residence event or None
@param: has_url -- list of url handles or None
"""
db = report.database
person = db.get_person_from_handle(person_handle)
BasePage.__init__(self, report, title, person.gramps_id)
self.up = True
# set the file name and open file
of = self.report.create_file(person_handle, "addr")
addressbookpage, body = self.write_header("%s - %s" % (title, _("Address Book")))
# begin address book page division and section title
with Html("div", class_ = "content", id = "AddressBookDetail") as addressbookdetail:
body += addressbookdetail
addressbookdetail += Html("h3", self.get_name(person), inline = True)
# individual has a url
if has_url:
addressbookdetail += self.display_url_list(has_url)
# individual has an address, and not a residence event
if has_add and not has_res:
addressbookdetail += self.display_addr_list(has_add, None)
# individual has a residence event and no addresses
elif has_res and not has_add:
addressbookdetail += self.dump_residence(has_res)
# individual has both
elif has_add and has_res:
addressbookdetail += self.display_addr_list(has_add, None)
addressbookdetail += self.dump_residence(has_res)
# add fullclear for proper styling
# and footer section to page
footer = self.write_footer()
body += (fullclear, footer)
# send page out for processing
# and close the file
self.XHTMLWriter(addressbookpage, of)
class NavWebReport(Report): class NavWebReport(Report):
@ -4753,7 +4877,7 @@ class NavWebReport(Report):
self.birthorder = self.options['birthorder'] self.birthorder = self.options['birthorder']
# get option for Internet Address Book # get option for Internet Address Book
self.add_book = self.options["add_book"] self.addressbook = self.options["addressbook"]
if self.use_home: if self.use_home:
self.index_fname = "index" self.index_fname = "index"
@ -4878,7 +5002,7 @@ class NavWebReport(Report):
# build class InternetAddressBook # build class InternetAddressBook
if self.add_book: if self.addressbook:
self.address_book_page(ind_list) self.address_book_page(ind_list)
# if an archive is being used, close it? # if an archive is being used, close it?
@ -5231,11 +5355,55 @@ class NavWebReport(Report):
self.progress.step() self.progress.step()
def address_book_page(self, ind_list): def address_book_page(self, ind_list):
"""
Creates classes AddressBookListPage and AddressBookPage
"""
# set progress pass db = self.database
self.progress.set_pass(_("Creating internet address book page ..."), len(ind_list)) has_url_address = []
InternetAddressBook(self, self.title, ind_list, self.progress) for person_handle in ind_list:
person = db.get_person_from_handle(person_handle)
addrlist = person.get_address_list()
evt_ref_list = person.get_event_ref_list()
urllist = person.get_url_list()
has_add = None
has_url = None
if addrlist:
has_add = addrlist
if urllist:
has_url = urllist
has_res = None
for event_ref in evt_ref_list:
event = db.get_event_from_handle(event_ref.ref)
# get event type
evt_type = str(event.get_type() )
if evt_type == "Residence":
has_res = event
break
if has_add or has_res or has_url:
primary_name = person.get_primary_name()
sort_name = ''.join([primary_name.get_surname(), ", ", primary_name.get_first_name()])
data = (sort_name, person_handle, has_add, has_res, has_url)
has_url_address.append(data)
# Determine if we build Address Book
if has_url_address:
has_url_address.sort()
AddressBookListPage(self, self.title, has_url_address)
self.progress.set_pass(_("Creating address book pages ..."), len(has_url_address))
for (sort_name, person_handle, has_add, has_res, has_url) in has_url_address:
self.progress.step()
AddressBookPage(self, self.title, person_handle, has_add, has_res, has_url)
def add_image(self, option_name, height=0): def add_image(self, option_name, height=0):
pic_id = self.options[option_name] pic_id = self.options[option_name]
@ -5727,9 +5895,10 @@ class NavWebOptions(MenuReportOptions):
inc_gendex.set_help(_('Whether to include a GENDEX file or not')) inc_gendex.set_help(_('Whether to include a GENDEX file or not'))
menu.add_option(category_name, 'inc_gendex', inc_gendex) menu.add_option(category_name, 'inc_gendex', inc_gendex)
add_book = BooleanOption(_("Include an Internet Address Book Page"), True) addressbook = BooleanOption(_("Include address book pages"), False)
add_book.set_help(_("Whether to add an Internet Address Book or not?")) addressbook.set_help(_("Whether to add Address Book pages or not which can include"
menu.add_option(category_name, "add_book", add_book) " e-mail and website addresses and personal address/ residence events?"))
menu.add_option(category_name, "addressbook", addressbook)
def __archive_changed(self): def __archive_changed(self):
""" """