From fd75d680eac24fc96f94cb4161329eef43989fe1 Mon Sep 17 00:00:00 2001 From: "Rob G. Healey" Date: Sat, 11 Sep 2010 17:06:49 +0000 Subject: [PATCH] Jakim Friant: Changes made to the Ancestor Tree. svn: r15877 --- src/gen/display/name.py | 13 +++++++ src/plugins/webreport/NarrativeWeb.py | 56 +++++++++++++++++++-------- src/plugins/webreport/WebCal.py | 16 ++++---- 3 files changed, 62 insertions(+), 23 deletions(-) diff --git a/src/gen/display/name.py b/src/gen/display/name.py index 2aca5c56f..5defc81e4 100644 --- a/src/gen/display/name.py +++ b/src/gen/display/name.py @@ -528,6 +528,19 @@ def fn(%s): num = self._is_format_valid(name.sort_as) return self.name_formats[num][_F_FN](name) + def truncate(self, full_name, max_length=15, elipsis="..."): + name_out = "" + if len(full_name) <= max_length: + name_out = full_name + else: + last_space = full_name.rfind(" ", max_length) + if (last_space) > -1: + name_out = full_name[:last_space] + else: + name_out = full_name[:max_length] + name_out += " " + elipsis + return name_out + def raw_sorted_name(self, raw_data): """ Return a text string representing the L{Name} instance diff --git a/src/plugins/webreport/NarrativeWeb.py b/src/plugins/webreport/NarrativeWeb.py index 07ea8d6c3..fe29e6e2d 100644 --- a/src/plugins/webreport/NarrativeWeb.py +++ b/src/plugins/webreport/NarrativeWeb.py @@ -92,7 +92,7 @@ import ThumbNails import ImgManip import gen.mime from QuestionDialog import ErrorDialog, WarningDialog -from gen.display.name import displayer as _nd +from gen.display.name import displayer as _nd from DateHandler import displayer as _dd from gen.proxy import PrivateProxyDb, LivingProxyDb from libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS @@ -1798,7 +1798,7 @@ class BasePage(object): person_name = _get_short_name(person.gender, person.primary_name) elif name_style == _NAME_STYLE_SHORT: full_name = self.get_name(person) - short_name = Html("span", full_name[:15] + "...", class_ = "shortname", inline = True) + short_name = Html("span", _nd.truncate(full_name), class_ = "shortname", inline = True) person_name = Html("span", full_name, class_ = "fullname", inline = True) elif name_style is None: # abnormal specialty situation person_name = person @@ -2124,7 +2124,10 @@ class IndividualListPage(BasePage): birth_date = _find_birth_date(db, person) if birth_date is not None: - tcell += _dd.display(birth_date) + if birth_date.fallback: + tcell += Html('em', _dd.display(birth_date), inline = True) + else: + tcell += _dd.display(birth_date) else: tcell += " " @@ -2135,7 +2138,10 @@ class IndividualListPage(BasePage): death_date = _find_death_date(db, person) if death_date is not None: - tcell += _dd.display(death_date) + if death_date.fallback: + tcell += Html('em', _dd.display(death_date), inline = True) + else: + tcell += _dd.display(death_date) else: tcell += " " @@ -2280,7 +2286,10 @@ class SurnamePage(BasePage): birth_date = _find_birth_date(db, person) if birth_date is not None: - tcell += _dd.display(birth_date) + if birth_date.fallback: + tcell += Html('em', _dd.display(birth_date), inline = True) + else: + tcell += _dd.display(birth_date) else: tcell += " " @@ -2291,7 +2300,10 @@ class SurnamePage(BasePage): death_date = _find_death_date(db, person) if death_date is not None: - tcell += _dd.display(death_date) + if death_date.fallback: + tcell += Html('em', _dd.display(death_date), inline = True) + else: + tcell += _dd.display(death_date) else: tcell += " " @@ -4200,12 +4212,11 @@ class IndividualPage(BasePage): divclass = "unknown" boxbg = Html("div", class_ = "boxbg %s AncCol%s" % (divclass, col), - style="top: %dpx; left: %dpx; min-height: 3em;" % (top, xoff+1) + style="top: %dpx; left: %dpx;" % (top, xoff+1) ) full_name = self.get_name(person) - short_name = Html("span", full_name[:15] + "...", class_ = "shortname", inline = True) - person_name = short_name + Html("span", full_name, class_ = "fullname") + short_name = Html("span", _nd.truncate(full_name), class_ = "shortname", inline = True) if person.handle in self.ind_list: thumbnailUrl = None @@ -4236,7 +4247,8 @@ class IndividualPage(BasePage): url = self.report.build_url_fname_html(person.handle, "ppl", True) boxbg += self.person_link(url, person, _NAME_STYLE_SHORT, thumbnailUrl=thumbnailUrl) else: - boxbg += Html("span", person_name, class_ = "unlinked", inline = True) + boxbg += Html("span", short_name, class_ = "shortname unlinked", inline = True) + boxbg += Html("span", fullname, class_ = "fullname unlinked", inline = True) shadow = Html("div", class_ = "shadow", inline = True, style="top: %dpx; left: %dpx;" % (top+_SHADOW, xoff+_SHADOW) ) @@ -6953,40 +6965,52 @@ def add_birthdate(db, childlist): # return the list of child handles and their birthdates return sorted_children +# TODO: See http://www.gramps-project.org/bugs/view.php?id=4200 for issues about +# marking the fall-back date with itallics +# def _find_birth_date(db, person): """ will look for a birth date within the person's events """ + date_out = None birth_ref = person.get_birth_ref() if birth_ref: birth = db.get_event_from_handle(birth_ref.ref) - return birth.get_date_object() + date_out = birth.get_date_object() + date_out.fallback = False else: event_list = person.get_primary_event_ref_list() for event_ref in event_list: event = db.get_event_from_handle(event_ref.ref) if event.get_type().is_birth_fallback(): - return event.get_date_object() - return None + date_out = event.get_date_object() + date_out.fallback = True + log.debug("setting fallback to true for '%s'" % (event)) + break + return date_out def _find_death_date(db, person): """ will look for a death date within a person's events """ + date_out = None death_ref = person.get_death_ref() if death_ref: death = db.get_event_from_handle(death_ref.ref) if death: - return death.get_date_object() + date_out = death.get_date_object() + date_out.fallback = False else: event_list = person.get_primary_event_ref_list() for event_ref in event_list: event = db.get_event_from_handle(event_ref.ref) if event.get_type().is_death_fallback(): - return event.get_date_object() - return None + date_out = event.get_date_object() + date_out.fallback = True + break + return date_out def build_event_data(db, ind_list): """ diff --git a/src/plugins/webreport/WebCal.py b/src/plugins/webreport/WebCal.py index 49ac2ae24..de10db3cc 100644 --- a/src/plugins/webreport/WebCal.py +++ b/src/plugins/webreport/WebCal.py @@ -417,7 +417,7 @@ class WebCalReport(Report): body.attr = "id = '%(idtag)s'" % { 'idtag' : body_id } # GRAMPS favicon - fname1 = os.path.join(subdirs, "images", "favicon.ico") + fname1 = os.path.join(subdirs, "images", "favicon2.ico") # _CALENDARSCREEN stylesheet fname2 = os.path.join(subdirs, "styles", _CALENDARSCREEN) @@ -428,27 +428,29 @@ class WebCalReport(Report): ) # links for GRAMPS favicon and stylesheets - links = Html("link", rel='shortcut icon', href=fname1, type = "image/x-icon") + ( - Html("link",rel="stylesheet", href=fname2, type="text/css", media= "screen", indent = False) + links = Html("link", rel = 'shortcut icon', href = fname1, type = "image/x-icon") + ( + Html("link",rel = "stylesheet", href = fname2, type = "text/css", media = "screen", indent = False) ) # add printer stylesheet to webcalendar() and one_day() only if add_print: fname = os.path.join(subdirs, "styles", _CALENDARPRINT) - links += Html("link",rel="stylesheet", href=fname,type="text/css", media="print", indent = False) + links += Html("link",rel = "stylesheet", href = fname,type = "text/css", media = "print", indent = False) # add horizontal menu if css == Blue or Visually because there is no menus if CSS[self.css]["navigation"]: # Link to Navigation Menus stylesheet fname = os.path.join(subdirs, "styles", "Web_Navigation-Menus.css") - links.extend( Html("link", href = fname, type = "text/css", media = "screen", rel = "stylesheet") ) + links.extend( + Html("link", href = fname, type = "text/css", media = "screen", rel = "stylesheet") + ) # add meta tags and links to head section head += (meta, links) # start header division section - header = Html("div", id="header") + ( + header = Html("div", id = "header") + ( # page title Html("h1", title, id = "SiteTitle", inline = True) @@ -465,7 +467,7 @@ class WebCalReport(Report): msg = _('Created for %(author)s') % {'author' : self.author} if msg is not None: - header += Html("p", msg, id="CreatorInfo") + header += Html("p", msg, id = "CreatorInfo") # return to its callers; either webcalendar(), year_glance(), or one_day() return page, body