svn: r13638
This commit is contained in:
Gerald Britton 2009-11-19 20:10:49 +00:00
parent c227803a1b
commit ddb4a6bd0f

View File

@ -238,14 +238,12 @@ def get_gendex_data(database, event_ref):
if place: if place:
location = place.get_main_location() location = place.get_main_location()
if location and not location.is_empty(): if location and not location.is_empty():
if location.get_city().strip(): poe = ", ".join(l for l in
poe = location.get_city().strip() [
if location.get_state().strip(): location.get_city().strip(),
if poe: poe += ", " location.get_state().strip(),
poe += location.get_state().strip() location.get_country().strip()
if location.get_country().strip(): ] if l)
if poe: poe += ", "
poe += location.get_country().strip()
return doe, poe return doe, poe
def format_date(date): def format_date(date):
@ -314,10 +312,9 @@ class BasePage(object):
birth = ReportUtils.get_birth_or_fallback(db, person) birth = ReportUtils.get_birth_or_fallback(db, person)
if birth: if birth:
d = birth.get_date_object().to_calendar(self.calendar)
birth_year = birth.get_date_object().to_calendar(self.calendar).get_year() birth_year, birth_month, birth_day = \
birth_month = birth.get_date_object().to_calendar(self.calendar).get_month() d.get_year(), d.get_month(), d.get_day()
birth_day = birth.get_date_object().to_calendar(self.calendar).get_day()
else: else:
birth_year, birth_month, birth_day = 2199, 12, 31 birth_year, birth_month, birth_day = 2199, 12, 31
birth_date = Date(birth_year, birth_month, birth_day) birth_date = Date(birth_year, birth_month, birth_day)
@ -330,10 +327,9 @@ class BasePage(object):
death = ReportUtils.get_death_or_fallback(db, person) death = ReportUtils.get_death_or_fallback(db, person)
if death: if death:
d = death.get_date_object().to_calendar(self.calendar)
death_year = death.get_date_object().to_calendar(self.calendar).get_year() death_year, death_month, death_day = \
death_month = death.get_date_object().to_calendar(self.calendar).get_month() d.get_year(), d.get_month(), d.get_day()
death_day = death.get_date_object().to_calendar(self.calendar).get_day()
else: else:
death_year, death_month, death_day = 2199, 12, 31 death_year, death_month, death_day = 2199, 12, 31
death_date = Date(death_year, death_month, death_day) death_date = Date(death_year, death_month, death_day)
@ -357,13 +353,13 @@ class BasePage(object):
if showsrc: if showsrc:
srcrefs = self.get_citation_links(attr.get_source_references() ) or " " srcrefs = self.get_citation_links(attr.get_source_references() ) or " "
source_row = ("Sources", srcrefs) source_row = ("Sources", srcrefs)
attr_data_row.append(source_row) attr_data_row.append(source_row)
# get attribute note list # get attribute note list
notelist = attr.get_note_list() notelist = attr.get_note_list()
notelist = self.display_note_list(notelist) or " " notelist = self.display_note_list(notelist) or " "
note_row = ("Notes", notelist) note_row = ("Notes", notelist)
attr_data_row.append(note_row) attr_data_row.append(note_row)
# display attribute list # display attribute list
@ -395,12 +391,12 @@ class BasePage(object):
text = "" text = ""
if len(gid_list): if len(gid_list):
text = text + " <sup>" text += " <sup>"
for ref in gid_list: for ref in gid_list:
index, key = self.bibli.add_reference(ref) index, key = self.bibli.add_reference(ref)
id_ = "%d%s" % (index+1, key) id_ = "%d%s" % (index+1, key)
text = text + '<a href = "#sref%s">%s</a>' % (id_, id_) text += '<a href="#sref%s">%s</a>' % (id_, id_)
text = text + "</sup>" text += "</sup>"
# return citation list text to its callers # return citation list text to its callers
return text return text
@ -416,11 +412,8 @@ class BasePage(object):
# styled notes # styled notes
htmlnotetext = self.styled_note(note.get_styledtext(), htmlnotetext = self.styled_note(note.get_styledtext(),
note.get_format()) note.get_format())
if htmlnotetext: text = htmlnotetext or Html("p", note_text)
text = htmlnotetext
else:
text = Html("p", note_text)
# return text of the note to its callers # return text of the note to its callers
return text return text
@ -452,19 +445,28 @@ class BasePage(object):
#preformatted, retain whitespace. #preformatted, retain whitespace.
#so use \n\n for paragraph detection #so use \n\n for paragraph detection
#FIXME: following split should be regex to match \n\s*\n instead? #FIXME: following split should be regex to match \n\s*\n instead?
htmllist += Html("pre", indent = None, inline = True) htmllist += Html("pre", indent=None) + \
(l + str(Html('br')) for l in markuptext.split('\n'))
'''
Html('pre',indent=None)
for line in markuptext.split('\n\n'): for line in markuptext.split('\n\n'):
htmllist += Html("p") htmllist += Html("p")
for realline in line.split('\n'): for realline in line.split('\n'):
htmllist += realline htmllist += realline
htmllist += Html('br') htmllist += Html('br')
'''
elif format == 0: elif format == 0:
#flowed #flowed
#FIXME: following split should be regex to match \n\s*\n instead? #FIXME: following split should be regex to match \n\s*\n instead?
htmllist.extend(Html('p') + para for para in markuptext.split("\n\n"))
'''
for line in markuptext.split("\n\n"): for line in markuptext.split("\n\n"):
htmllist += Html("p") htmllist += Html("p")
htmllist += line htmllist += line
'''
return htmllist return htmllist
@ -480,14 +482,14 @@ class BasePage(object):
db = self.report.database db = self.report.database
# begin unordered list # begin unordered list
unordered = Html("ul") ul = Html("ul")
ul.extend(
for notehandle in notelist: self.get_note_format(
note = db.get_note_from_handle(notehandle) db.get_note_from_handle(notehandle))
unordered += self.get_note_format(note) for notehandle in notelist)
# return unordered note list to its callers # return unordered note list to its callers
return unordered return ul
def display_event_row(self, evt, evt_ref, showplc, showdescr, showsrc, shownote, subdirs, hyp): def display_event_row(self, evt, evt_ref, showplc, showdescr, showsrc, shownote, subdirs, hyp):
""" """
@ -518,7 +520,7 @@ class BasePage(object):
data = data or "&nbsp;" data = data or "&nbsp;"
# determine if information will fit on same line? # determine if information will fit on same line?
samerow = True if (data == "&nbsp;" or colclass == "Date") else False samerow = (data == "&nbsp;" or colclass == "Date")
trow += Html("td", data, class_ = "Column%s" % colclass, inline = samerow) trow += Html("td", data, class_ = "Column%s" % colclass, inline = samerow)
@ -673,7 +675,7 @@ class BasePage(object):
value = value or "&nbsp;" value = value or "&nbsp;"
# determine if inline = True or False # determine if inline = True or False
samerow = True if (value == "&nbsp;" or colclass == "LDSDate") else False samerow = (value == "&nbsp;" or colclass == "LDSDate")
trow += Html("td", value, class_ = "Column%s" % colclass, inline = samerow) trow += Html("td", value, class_ = "Column%s" % colclass, inline = samerow)
@ -1279,7 +1281,7 @@ class BasePage(object):
note_text = unicode(str(note_text), errors='replace') note_text = unicode(str(note_text), errors='replace')
# add section title # add section title
section += Html("h4", _("Narrative"), inline = True) section += Html("h4", _("Narrative"), inline=True)
# attach note # attach note
section += note_text section += note_text
@ -1629,7 +1631,7 @@ class BasePage(object):
htmlinstance -- web page created with libhtml htmlinstance -- web page created with libhtml
src/plugins/lib/libhtml.py src/plugins/lib/libhtml.py
""" """
htmlinstance.write(lambda line: of.write(line + '\n')) htmlinstance.write(lambda line: of.write(line + '\n'))
# closes the file # closes the file
@ -4556,10 +4558,7 @@ class RepositoryListPage(BasePage):
if rtype == xtype[2]: if rtype == xtype[2]:
rtype = xtype[1] rtype = xtype[1]
break break
if rtype: tcell += rtype or "&nbsp;"
tcell += rtype
else:
tcell += "&nbsp;"
# repository name and hyperlink # repository name and hyperlink
repo_title = html_escape(repo.name) repo_title = html_escape(repo.name)
@ -5241,8 +5240,8 @@ class NavWebReport(Report):
# get death info: # get death info:
dod, pod = get_gendex_data(self.database, person.get_death_ref()) dod, pod = get_gendex_data(self.database, person.get_death_ref())
fp.write("%s|%s|%s|%s|%s|%s|%s|\n" % fp.write(
(url, surname, fullname, dob, pob, dod, pod)) '|'.join((url, surname, fullname, dob, pob, dod, pod)) + '|\n')
def surname_pages(self, ind_list): def surname_pages(self, ind_list):
""" """