More refactoring ... Help from Gerald Britton.

svn: r12123
This commit is contained in:
Rob G. Healey
2009-02-26 08:25:45 +00:00
parent 51b52a3952
commit 8c3bfdc44f
2 changed files with 42 additions and 49 deletions

View File

@ -101,6 +101,10 @@ from gen.lib.eventroletype import EventRoleType
# constants # constants
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# Names for stylesheets
_NARRATIVESCREEN = 'narrative-screen.css'
_NARRATIVEPRINT = 'narrative-print.css'
# variables for alphabet_navigation # variables for alphabet_navigation
_PERSON = 0 _PERSON = 0
_PLACE = 1 _PLACE = 1
@ -394,33 +398,34 @@ class BasePage:
(const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE)) (const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE))
of.write('\t<meta name="author" content="%s" />\n' % self.author) of.write('\t<meta name="author" content="%s" />\n' % self.author)
# Link to css behaviours # Link to media reference regions behaviour stylesheet
fname = os.path.join("styles", "behaviour.css") fname = os.path.join("styles", "behaviour.css")
url = self.report.build_url_fname(fname, None, self.up) url = self.report.build_url_fname(fname, None, self.up)
of.write('\t<link href="%s" rel="stylesheet" ' of.write('\t<link href="%s" rel="stylesheet" \n'
'type="text/css" media="screen">\n' % url) '\t\ttype="text/css" media="screen" />\n' % url)
# Link to screen stylesheet # Link to screen stylesheet
fname = os.path.join("styles", self.report.css) fname = os.path.join("styles", _NARRATIVESCREEN)
url = self.report.build_url_fname(fname, None, self.up) url = self.report.build_url_fname(fname, None, self.up)
of.write('\t<link href="%s" rel="stylesheet" ' of.write('\t<link href="%s" rel="stylesheet" \n'
'type="text/css" media="screen" />\n' % url) '\t\ttype="text/css" media="screen" />\n' % url)
# Link to printer stylesheet # Link to printer stylesheet
fname = os.path.join("styles", "Web_Print-Default.css") fname = os.path.join("styles", _NARRATIVEPRINT)
url = self.report.build_url_fname(fname, None, self.up) url = self.report.build_url_fname(fname, None, self.up)
of.write('\t<link href="%s" rel="stylesheet" ' of.write('\t<link href="%s" rel="stylesheet" \n'
'type="text/css" media="print" />\n' % url) '\t\ttype="text/css" media="print" />\n' % url)
# Link to GRAMPS favicon # Link to GRAMPS favicon
url = self.report.build_url_image('favicon.ico', 'images', self.up) url = self.report.build_url_image('favicon.ico', 'images', self.up)
of.write('\t<link href="%s" rel="Shortcut Icon" ' of.write('\t<link href="%s" rel="Shortcut Icon" \n'
'type="image/icon">\n' % url) '\t\ttype="image/icon" />\n' % url)
of.write('</head>\n\n') of.write('</head>\n\n')
of.write('<body id="NarrativeWeb">\n') # Terminated in write_footer() of.write('<body id="NarrativeWeb">\n') # Terminated in write_footer()
of.write('<div id="header">\n')
# begin header section
of.write('<div id="header">\n')
of.write('\t<h1 id="SiteTitle">%s</h1>\n' % html_escape(self.title_str)) of.write('\t<h1 id="SiteTitle">%s</h1>\n' % html_escape(self.title_str))
header = self.report.options['headernote'] header = self.report.options['headernote']
if header: if header:
@ -2973,11 +2978,11 @@ class NavWebReport(Report):
# copy screen stylesheet # copy screen stylesheet
if self.css: if self.css:
fname = os.path.join(const.DATA_DIR, self.css) fname = os.path.join(const.DATA_DIR, self.css)
self.copy_file(fname, self.css, "styles") self.copy_file(fname, _NARRATIVESCREEN, "styles")
# copy printer stylesheet # copy printer stylesheet
fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css") fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css")
self.copy_file(fname, "Web_Print-Default.css", "styles") self.copy_file(fname, _NARRATIVEPRINT, "styles")
imgs = [] imgs = []
@ -3630,4 +3635,4 @@ pmgr.register_report(
author_email = "don@gramps-project.org", author_email = "don@gramps-project.org",
description = _("Produces web (HTML) pages for individuals, or a set of " description = _("Produces web (HTML) pages for individuals, or a set of "
"individuals"), "individuals"),
) )

View File

@ -74,6 +74,10 @@ import libholiday
# constants # constants
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# Calendar stylesheet names
_CALENDARSCREEN = 'calendar-screen.css'
_CALENDARPRINT = 'calendar-print.css'
# Mainz stylesheet graphics # Mainz stylesheet graphics
# will only be used if Mainz is slected as the stylesheet # will only be used if Mainz is slected as the stylesheet
_WEBBKGD = "Web_Mainz_Bkgd.png" _WEBBKGD = "Web_Mainz_Bkgd.png"
@ -205,23 +209,13 @@ class WebCalReport(Report):
self.alive = mgobn('alive').get_value() self.alive = mgobn('alive').get_value()
self.birthday = mgobn('birthdays').get_value() self.birthday = mgobn('birthdays').get_value()
self.anniv = mgobn('anniversaries').get_value() self.anniv = mgobn('anniversaries').get_value()
self.home_link = mgobn('home_link').get_value().strip() self.home_link = mgobn('home_link').get_value()
self.month_notes = [mgobn('note_jan').get_value(), self.month_notes = [mgobn('note_' + month).get_value() \
mgobn('note_feb').get_value(), for month in ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']]
mgobn('note_mar').get_value(),
mgobn('note_apr').get_value(),
mgobn('note_may').get_value(),
mgobn('note_jun').get_value(),
mgobn('note_jul').get_value(),
mgobn('note_aug').get_value(),
mgobn('note_sep').get_value(),
mgobn('note_oct').get_value(),
mgobn('note_nov').get_value(),
mgobn('note_dec').get_value()]
# identify researcher name and e-mail address # identify researcher name and e-mail address
# as Narrated WebSite already does # as NarrativeWeb already does
researcher = get_researcher() researcher = get_researcher()
self.author = researcher.name self.author = researcher.name
if self.author: if self.author:
@ -328,11 +322,11 @@ class WebCalReport(Report):
# Copy the screen stylesheet # Copy the screen stylesheet
if self.css: if self.css:
fname = os.path.join(const.DATA_DIR, self.css) fname = os.path.join(const.DATA_DIR, self.css)
self.copy_file(fname, self.css, "styles") self.copy_file(fname, _CALENDARSCREEN, "styles")
# copy print stylesheet # copy print stylesheet
fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css") fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css")
self.copy_file(fname, "Web_Print-Default.css", "styles") self.copy_file(fname, _CALENDARPRINT, "styles")
# set imgs to empty # set imgs to empty
imgs = [] imgs = []
@ -682,21 +676,19 @@ class WebCalReport(Report):
(const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE)) (const.PROGRAM_NAME, const.VERSION, const.URL_HOMEPAGE))
of.write('\t<meta name="author" content="%s" />\n\n' % self.author) of.write('\t<meta name="author" content="%s" />\n\n' % self.author)
subdirs = ['..'] * nr_up
# link to screen stylesheet # link to screen stylesheet
fname = '/'.join(subdirs + ['styles'] + [self.css]) fname = '../'*nr_up + 'styles/' + _CALENDARSCREEN
of.write('\t<link rel="stylesheet" href="%s"\n' % fname) of.write('\t<link rel="stylesheet" href="%s"\n' % fname)
of.write('\t\ttype="text/css" media="screen">\n') of.write('\t\ttype="text/css" media="screen" />\n')
# link to print stylesheet # link to print stylesheet
if add_print: if add_print:
fname = '/'.join(subdirs + ['styles'] + ["Web_Print-Default.css"]) fname = '../'*nr_up + 'styles/' + _CALENDARPRINT
of.write('\t<link rel="stylesheet" href="%s"\n' % fname) of.write('\t<link rel="stylesheet" href="%s"\n' % fname)
of.write('\t\ttype="text/css" media="print">\n') of.write('\t\ttype="text/css" media="print" />\n')
# link to GRAMPS favicon # link to GRAMPS favicon
fname = '/'.join(subdirs + ['images'] + ['favicon.ico']) fname = '../'*nr_up + 'images/' + 'favicon.ico'
of.write('\t<link rel="shortcut icon" href="%s" \n' % fname) of.write('\t<link rel="shortcut icon" href="%s" \n' % fname)
of.write('\t\ttype="image/icon" />\n') of.write('\t\ttype="image/icon" />\n')
@ -948,8 +940,7 @@ class WebCalReport(Report):
# do some error correcting if needed # do some error correcting if needed
if self.multiyear: if self.multiyear:
if self.end_year < self.start_year: if self.end_year < self.start_year:
# Huh? Why start_year+1? self.end_year = self.start_year
self.end_year = self.start_year + 1
nr_up = 1 # Number of directory levels up to get to self.html_dir / root nr_up = 1 # Number of directory levels up to get to self.html_dir / root
@ -1350,8 +1341,8 @@ def _get_short_name(person, maiden_name=None):
""" Return person's name, unless maiden_name given, """ Return person's name, unless maiden_name given,
unless married_name listed. """ unless married_name listed. """
# Get all of a person's names: # Get all of a person's names:
primary_name = person.get_primary_name() primary_name = person.primary_name
sex = person.get_gender() sex = person.gender
married_name = None married_name = None
names = [primary_name] + person.get_alternate_names() names = [primary_name] + person.get_alternate_names()
@ -1362,20 +1353,17 @@ def _get_short_name(person, maiden_name=None):
# Now, decide which to use: # Now, decide which to use:
if maiden_name is not None: if maiden_name is not None:
if married_name is not None: if married_name is not None:
first_name, family_name = married_name.get_first_name(), \ first_name, family_name = married_name.get_first_name(), _get_regular_surname(sex, married_name)
_get_regular_surname(sex, married_name)
call_name = married_name.get_call_name() call_name = married_name.get_call_name()
else: else:
first_name, family_name = primary_name.get_first_name(), \ first_name, family_name = primary_name.get_first_name(), maiden_name
maiden_name
call_name = primary_name.get_call_name() call_name = primary_name.get_call_name()
else: else:
first_name, family_name = primary_name.get_first_name(), \ first_name, family_name = primary_name.get_first_name(), _get_regular_surname(sex, primary_name)
_get_regular_surname(sex, primary_name)
call_name = primary_name.get_call_name() call_name = primary_name.get_call_name()
# If they have a nickname use it # If they have a nickname use it
if call_name is not None and call_name.strip() != "": if call_name is not None and call_name.strip() is not "":
first_name = call_name.strip() first_name = call_name.strip()
else: # else just get the first name: else: # else just get the first name:
first_name = first_name.strip() first_name = first_name.strip()