Moved CreatorInfo from write_footer() back to write_header(). Removed maximum calendars years, and fixed display_year_nav().

svn: r11972
This commit is contained in:
Rob G. Healey 2009-02-12 07:56:51 +00:00
parent c0af02cadd
commit 4730f744ba
2 changed files with 77 additions and 79 deletions

View File

@ -295,7 +295,7 @@ class BasePage:
sorted_first_letter.sort(locale.strcoll) sorted_first_letter.sort(locale.strcoll)
num_ltrs = len(sorted_first_letter) num_ltrs = len(sorted_first_letter)
if num_ltrs <= 25: if num_ltrs <= 26:
of.write('\t<div id="navigation">\n') of.write('\t<div id="navigation">\n')
of.write('\t\t<ul>\n') of.write('\t\t<ul>\n')
for ltr in sorted_first_letter: for ltr in sorted_first_letter:
@ -303,20 +303,19 @@ class BasePage:
of.write('\t\t</ul>\n') of.write('\t\t</ul>\n')
of.write('\t</div>\n') of.write('\t</div>\n')
else: else:
nrows = (num_ltrs / 25) nrows = (num_ltrs / 26)
index = 0 index = 0
for rows in range(0, nrows): for rows in range(0, nrows):
of.write('\t<div id="navigation">\n') of.write('\t<div id="navigation">\n')
of.write('\t\t<ul>\n') of.write('\t\t<ul>\n')
cols = 0 cols = 0
while (cols <= 24 and index <= num_ltrs): while (cols <= 26 and index <= num_ltrs):
of.write('\t\t\t<li><a href="#%s">%s</a></li>\n' of.write('\t\t\t<li><a href="#%s">%s</a></li>\n'
% (sorted_first_letter[index], sorted_first_letter[index])) % (sorted_first_letter[index], sorted_first_letter[index]))
cols += 1 cols += 1
index += 1 index += 1
of.write('\t\t<ul>\n') of.write('\t\t<ul>\n')
of.write('\t</div>\n') of.write('\t</div>\n')
return of
def write_footer(self, of): def write_footer(self, of):
@ -337,13 +336,6 @@ class BasePage:
msg = _('Generated by <a href="http://gramps-project.org">' msg = _('Generated by <a href="http://gramps-project.org">'
'GRAMPS</a> on %(date)s') % {'date' : value} 'GRAMPS</a> on %(date)s') % {'date' : value}
if self.report.options['linkhome']:
home_person = self.report.database.get_default_person()
if home_person:
home_person_url = self.report.build_url_fname_html(home_person.handle, 'ppl', self.up)
home_person_name = home_person.get_primary_name().get_regular_name()
msg += _('<br />for <a href="%s">%s</a>') % (home_person_url, home_person_name)
of.write('\t<p id="createdate">%s</p>\n' % msg) of.write('\t<p id="createdate">%s</p>\n' % msg)
copy_nr = self.report.copyright copy_nr = self.report.copyright
@ -417,9 +409,17 @@ class BasePage:
header = self.report.options['headernote'] header = self.report.options['headernote']
if header: if header:
note = self.report.database.get_note_from_gramps_id(header) note = self.report.database.get_note_from_gramps_id(header)
of.write('\t<p id="user_header">') of.write('\t<p id="user_header">%s</p>\n' % note.get())
of.write(note.get())
of.write('</p>\n') linkhome = self.report.options['linkhome']
if linkhome:
home_person = self.report.database.get_default_person()
if home_person:
home_person_url = self.report.build_url_fname_html(home_person.handle, 'ppl', self.up)
home_person_name = home_person.get_primary_name().get_regular_name()
msg = _('Created for <a href="%s">%s</a>') % (home_person_url, home_person_name)
of.write('\t<p id="CreatorInfo">%s</p>\n' % msg)
of.write('</div>\n') of.write('</div>\n')
# Begin Navigation Menu # Begin Navigation Menu

View File

@ -431,47 +431,50 @@ class WebCalReport(Report):
currentsection = proper styling of this navigation bar currentsection = proper styling of this navigation bar
""" """
of.write('<div id="navigation">\n') # creating more than one year
of.write('\t<ul>\n') if not self.multiyear:
cols = 0 return
num_years = (self.end_year - self.start_year)
cal_year = self.start_year cal_year = self.start_year
while (cols <= 25 and cal_year <= self.end_year):
url = ''
currentsection = False
# begin subdir level nrows = (num_years / 16)
subdirs = ['..'] * nr_up for rows in range(0, (nrows + 1)):
subdirs.append(str(cal_year)) of.write('<div id="navigation">\n')
of.write('\t<ul>\n')
cols = 0
while (cols <= 15 and cal_year <= self.end_year):
url = ''
# each year will link to current month. # begin subdir level
# this will always need an extension added subdirs = ['..'] * nr_up
full_month_name = get_full_month_name(self.today.month) subdirs.append(str(cal_year))
# Note. We use '/' here because it is a URL, not a OS dependent # each year will link to current month.
# pathname. # this will always need an extension added
url = '/'.join(subdirs + [full_month_name]) + self.ext full_month_name = get_full_month_name(self.today.month)
# determine if we need to highlight??? # Note. We use '/' here because it is a URL, not a OS dependent
if str(cal_year) == currentsection: # pathname.
currentsection = True url = '/'.join(subdirs + [full_month_name]) + self.ext
# if True, highlight currentsection # determine if we need to highlight???
if currentsection: highlight = ''
section = ' id="CurrentSection"' if str(cal_year) == currentsection:
else: highlight = ' id="CurrentSection"'
section = ''
of.write('\t\t<li%s><a href="%s">%s</a></li>\n' of.write('\t\t<li%s><a href="%s">%d</a></li>\n'
% (section, url, str(cal_year))) % (highlight, url, cal_year))
# increase year # increase columns
cal_year += 1 cols += 1
# increase column # increase calendar year
cols += 1 cal_year += 1
of.write('\t</ul>\n') # close row and div section in for each row
of.write('</div>\n\n') of.write('\t</ul>\n')
of.write('</div>\n')
def calendar_common(self, of, nr_up, year, currentsection, title, use_home=False): def calendar_common(self, of, nr_up, year, currentsection, title, use_home=False):
""" """
@ -910,17 +913,11 @@ class WebCalReport(Report):
# Copy all files for the calendars being created # Copy all files for the calendars being created
self.copy_calendar_files() self.copy_calendar_files()
# create calendars with multiple years up to twenty-five years
# navigation bar length will only support twenty-five years at any given time
if self.multiyear: if self.multiyear:
# Clip to max 25 years
if ((self.end_year - self.start_year + 1) > 25):
self.end_year = self.start_year + 25 - 1
for cal_year in range(self.start_year, (self.end_year + 1)): for cal_year in range(self.start_year, (self.end_year + 1)):
# generate progress pass for year ???? # generate progress pass for year ????
self.progress.set_pass(_('Creating year %d calendars') % cal_year, '') self.progress.set_pass(_('Creating year %d calendars') % cal_year, 1)
# initialize the holidays dict to fill: # initialize the holidays dict to fill:
self.holidays = {} self.holidays = {}
@ -946,9 +943,6 @@ class WebCalReport(Report):
if self.country != 0: if self.country != 0:
self.__get_holidays(cal_year) self.__get_holidays(cal_year)
# generate progress pass for single year
#self.progress.set_pass(_('Creating calendars'), 12)
# create "WebCal" calendar pages # create "WebCal" calendar pages
self.web_cal(cal_year) self.web_cal(cal_year)
@ -1482,36 +1476,40 @@ def get_day_list(event_date, holiday_list, bday_anniv_list):
# number of years married, ex: 10 # number of years married, ex: 10
nyears = event_date.get_year() - date.get_year() nyears = event_date.get_year() - date.get_year()
# number of years for birthday, ex: 10 years # no negative years
age_str = event_date - date # years have to be at least zero
age_str.format(precision=1) if nyears > -1:
# a birthday # number of years for birthday, ex: 10 years
if event == 'Birthday': age_str = event_date - date
age_str.format(precision=1)
if nyears == 0: # a birthday
txt_str = _('%(person)s, <em>birth</em>') % { if event == 'Birthday':
'person' : text}
else:
txt_str = _('%(person)s, <em>%(age)s</em> old') % {
'person' : text, 'age' : age_str}
# an anniversary if nyears == 0:
elif event == 'Anniversary': txt_str = _('%(person)s, <em>birth</em>') % {
'person' : text}
else:
txt_str = _('%(person)s, <em>%(age)s</em> old') % {
'person' : text, 'age' : age_str}
if nyears == 0: # an anniversary
txt_str = _('%(couple)s, <em>wedding</em>') % { elif event == 'Anniversary':
if nyears == 0:
txt_str = _('%(couple)s, <em>wedding</em>') % {
'couple' : text} 'couple' : text}
else: else:
txt_str = (ngettext('%(couple)s, <em>%(years)d' txt_str = (ngettext('%(couple)s, <em>%(years)d'
'</em> year anniversary', '</em> year anniversary',
'%(couple)s, <em>%(years)d' '%(couple)s, <em>%(years)d'
'</em> year anniversary', nyears) '</em> year anniversary', nyears)
% {'couple' : text, 'years' : nyears}) % {'couple' : text, 'years' : nyears})
txt_str = '<span class="yearsmarried">%s</span>' % txt_str txt_str = '<span class="yearsmarried">%s</span>' % txt_str
if txt_str is not None: if txt_str is not None:
day_list.append((nyears, date, txt_str, event)) day_list.append((nyears, date, txt_str, event))
# sort them based on number of years # sort them based on number of years
# holidays will always be on top of day # holidays will always be on top of day