Update from Rob Healey and Jason Simanek: new stylesheets and

some (small?) changes in the generated HTML.
(( Not fully tested, please give it a try ))
	* src/plugins/NarrativeWeb.py


svn: r10869
This commit is contained in:
Kees Bakker 2008-07-16 07:59:29 +00:00
parent 0ffd81bac2
commit 445da31691

View File

@ -114,13 +114,9 @@ _XOFFSET = 5
# stylesheets.
_CSS_FILES = [
# First is used as default selection.
[_("Basic - Ash"), 'NWeb-Screen_Basic-Ash.css'],
[_("Basic - Cypress"), 'NWeb-Screen_Basic-Cypress.css'],
[_("Basic - Lilac"), 'NWeb-Screen_Basic-Lilac.css'],
[_("Basic - Peach"), 'NWeb-Screen_Basic-Peach.css'],
[_("Basic - Spruce"), 'NWeb-Screen_Basic-Spruce.css'],
[_("Mainz"), 'NWeb-Screen_Mainz.css'],
[_("Nebraska"), 'NWeb-Screen_Nebraska.css'],
[_("Evergreen"), 'Web_Evergreen.css'],
[_("Nebraska"), 'Web_Nebraska.css'],
[_("Simply Red"), 'Web_Simply-Red.css'],
[_("No style sheet"), ''],
]
@ -149,32 +145,32 @@ _CC = [
'<a rel="license" href="http://creativecommons.org/licenses/by/2.5/">'
'<img alt="Creative Commons License - By attribution" '
'title="Creative Commons License - By attribution" '
'src="#PATH#images/somerights20.gif" /></a>',
'src="%(gif_fname)s" /></a>',
'<a rel="license" href="http://creativecommons.org/licenses/by-nd/2.5/">'
'<img alt="Creative Commons License - By attribution, No derivations" '
'title="Creative Commons License - By attribution, No derivations" '
'src="#PATH#images/somerights20.gif" /></a>',
'src="%(gif_fname)s" /></a>',
'<a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/">'
'<img alt="Creative Commons License - By attribution, Share-alike" '
'title="Creative Commons License - By attribution, Share-alike" '
'src="#PATH#images/somerights20.gif" /></a>',
'src="%(gif_fname)s" /></a>',
'<a rel="license" href="http://creativecommons.org/licenses/by-nc/2.5/">'
'<img alt="Creative Commons License - By attribution, Non-commercial" '
'title="Creative Commons License - By attribution, Non-commercial" '
'src="#PATH#images/somerights20.gif" /></a>',
'src="%(gif_fname)s" /></a>',
'<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.5/">'
'<img alt="Creative Commons License - By attribution, Non-commercial, No derivations" '
'title="Creative Commons License - By attribution, Non-commercial, No derivations" '
'src="#PATH#images/somerights20.gif" /></a>',
'src="%(gif_fname)s" /></a>',
'<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/">'
'<img alt="Creative Commons License - By attribution, Non-commerical, Share-alike" '
'title="Creative Commons License - By attribution, Non-commerical, Share-alike" '
'src="#PATH#images/somerights20.gif" /></a>'
'src="%(gif_fname)s" /></a>'
]
_COPY_OPTIONS = [
@ -285,28 +281,34 @@ class BasePage:
of.write('</p>\n')
of.write('\t</div>\n')
copyright = self.report.copyright
if copyright == 0:
of.write('\t<div id="copyright">\n')
of.write('\t\t<p>')
value = _dp.parse(time.strftime('%b %d %Y'))
value = _dd.display(value)
msg = _('Generated by <a href="http://gramps-project.org">'
'GRAMPS</a> on %(date)s') % { 'date' : value }
of.write('\t<p id="createdate" />')
of.write(msg)
of.write('</p>\n')
of.write('\t<p id="copyright">')
copy_nr = self.report.copyright
if copy_nr == 0:
if self.author:
year = time.localtime()[0]
cright = _('&copy; %(year)d %(person)s') % {
'person' : self.author,
'year' : year }
of.write('%s' % cright)
of.write('</p>\n')
of.write('\t</div>\n')
elif copyright <= 6:
of.write('\t<div id="copyright">')
text = _CC[copyright]
if self.up:
# FIXME. Using ../../..
text = text.replace('#PATH#', '../../../')
else:
text = text.replace('#PATH#', '')
elif 0 < copy_nr < 7:
text = _CC[copy_nr]
fname = build_url_fname("somerights20.gif", 'images', self.up)
text = text % {'gif_fname' : fname}
of.write(text)
of.write('</div>\n')
of.write('</p>\n')
of.write('\t<p id="quality"><a href="http://validator.w3.org/check?uri=referer">')
of.write('<img src="http://www.w3.org/Icons/valid-xhtml10" ')
of.write('alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></p>\n')
of.write('\t\t<div class="fullclear"></div>\n')
of.write('</div>\n')
@ -329,14 +331,25 @@ class BasePage:
of.write(' <title>%s - %s</title>\n' % (html_escape(self.title_str), html_escape(title)))
of.write(' <meta http-equiv="Content-Type" content="text/html; ')
of.write('charset=%s" />\n' % self.report.encoding)
of.write(' <meta name="robots" content="noindex" />\n')
of.write(' <meta name="generator" content="GRAMPS 3.1.x: ')
of.write('http://www.gramps-project.org" />\n')
author = get_researcher().get_name()
if author:
author = author.replace(',,,', '')
of.write(' <meta name="author" content="%s" />\n' % author)
# Link to narrative.css
url = self.report.build_url_fname(_NARRATIVESCREEN, None, self.up)
of.write(' <link href="%s" rel="stylesheet" type="text/css" title="GRAMPS Style" media="screen" />\n' % url)
fname = os.path.join("styles", _NARRATIVESCREEN)
url = self.report.build_url_fname(fname, None, self.up)
of.write(' <link href="%s" rel="stylesheet" type="text/css" '
'media="screen" />\n' % url)
# Link to narrativePrint.css
url = self.report.build_url_fname(_NARRATIVEPRINT, None, self.up)
of.write(' <link href="%s" rel="stylesheet" type="text/css" media="print" />\n' % url)
fname = os.path.join("styles", _NARRATIVEPRINT)
url = self.report.build_url_fname(fname, None, self.up)
of.write(' <link href="%s" rel="stylesheet" type="text/css" '
'media="print" />\n' % url)
# Link to favicon.ico
url = self.report.build_url_image('favicon.ico', 'images', self.up)
@ -344,14 +357,11 @@ class BasePage:
of.write(' <!-- %sId%s -->\n' % ('$', '$'))
of.write('</head>\n\n')
of.write('<body>\n') # Terminated in write_footer()
of.write('<body id="NarrativeWeb">\n') # Terminated in write_footer()
of.write(' <div id="header">\n')
of.write('<div id="Header">\n')
value = _dp.parse(time.strftime('%b %d %Y'))
value = _dd.display(value)
msg = _('Generated by <a href="http://gramps-project.org">'
'GRAMPS</a> on %(date)s') % { 'date' : value }
# FIXME. Do we want an empty GRAMPSinfo div below if no self.linkhome?
msg = ""
db = self.report.database
if self.linkhome:
@ -359,7 +369,7 @@ class BasePage:
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)
msg = _('Created for <a href="%s">%s</a>') % (home_person_url, home_person_name)
of.write(' <div id="GRAMPSinfo">%s</div>\n' % msg)
of.write(' <h1 id="SiteTitle">%s</h1>\n' % html_escape(self.title_str))
@ -371,13 +381,13 @@ class BasePage:
of.write('</p>\n')
of.write('\t</div>\n')
# Begin Navigation Menu
of.write(' <div id="Navigation">\n')
of.write(' <ol>\n')
# Begin Navigation Menu
of.write(' <div id="navigation">\n')
of.write(' <ul>\n')
self.display_nav_links(of, title)
of.write(' </ol>\n')
of.write(' </ul>\n')
of.write(' </div>\n') # End Navigation Menu
divid = ''
@ -1767,8 +1777,14 @@ class IndividualPage(BasePage):
def draw_box(self, of, center, col, person):
top = center - _HEIGHT/2
xoff = _XOFFSET+col*(_WIDTH+_HGAP)
of.write('\t\t\t<div class="boxbg" style="top: %dpx; left: %dpx;">\n' % (top, xoff+1))
sex = person.get_gender()
if sex == gen.lib.Person.MALE:
divclass = "boxbg male"
elif sex == gen.lib.Person.FEMALE:
divclass = "boxbg female"
else:
divclass = "boxbg unknown"
of.write('\t\t\t<div class="%s" style="top: %dpx; left: %dpx;">\n' % (divclass, top, xoff+1))
of.write('\t\t\t\t<div class="box">')
if person.handle in self.ind_list:
person_name = _nd.display(person)
@ -2679,21 +2695,25 @@ class NavWebReport(Report):
ind_list = self.build_person_list()
# Generate the CSS file if requested
if self.css != '':
self.write_css(self.css)
if self.css:
self.copy_css(self.css)
imgs = []
if self.css == "Web_Mainz.css":
# Copy Mainz Style Images
imgs += ["NWeb_Mainz_Bkgd.png",
"NWeb_Mainz_Header.png",
"NWeb_Mainz_Mid.png",
"NWeb_Mainz_MidLight.png",
"document.png"]
# Copy Mainz Style Images
imgs = ["NWeb_Mainz_Bkgd.png",
"NWeb_Mainz_Header.png",
"NWeb_Mainz_Mid.png",
"NWeb_Mainz_MidLight.png",
"document.png",
"favicon.ico"]
# Copy the Creative Commons icon if the Creative Commons
# license is requested
if 0 < self.copyright < 7:
imgs += ["somerights20.gif"]
imgs += ["favicon.ico"]
for f in imgs:
from_path = os.path.join(const.IMAGE_DIR, f)
to_path = os.path.join("images", f)
@ -2726,21 +2746,21 @@ class NavWebReport(Report):
ind_list = self.filter.apply(self.database, ind_list)
return ind_list
def write_css(self, css_file):
def copy_css(self, css_file):
"""
Copy the CSS file to the destination.
Copy the CSS files to the target directory.
"""
if self.archive:
fname = os.path.join(const.DATA_DIR, css_file)
self.archive.add(fname, _NARRATIVESCREEN)
gname = os.path.join(const.DATA_DIR, "NWeb-Print_Default.css")
self.archive.add(gname, _NARRATIVEPRINT)
fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css")
self.archive.add(fname, _NARRATIVEPRINT)
else:
shutil.copyfile(os.path.join(const.DATA_DIR, css_file),
os.path.join(self.html_dir, _NARRATIVESCREEN))
shutil.copyfile(os.path.join(const.DATA_DIR, "NWeb-Print_Default.css"),
os.path.join(self.html_dir, _NARRATIVEPRINT))
os.path.join(self.html_dir, "styles", _NARRATIVESCREEN))
shutil.copyfile(os.path.join(const.DATA_DIR, "Web_Print-Default.css"),
os.path.join(self.html_dir, "styles", _NARRATIVEPRINT))
def person_pages(self, ind_list, place_list, source_list):
@ -2977,7 +2997,7 @@ class NavWebReport(Report):
os.makedirs(dest)
dest = os.path.join(dest, to_fname)
if from_fname != dest:
shutil.copyfile(from_fname, dest)
self.store_file(from_fname, dest)
elif self.warn_dir:
WarningDialog(
_("Possible destination error") + "\n" +
@ -3060,6 +3080,10 @@ class NavWebOptions(MenuReportOptions):
self.__archive_changed()
title = StringOption(_("Web site title"), _('My Family Tree'))
title.set_help(_("The title of the web site"))
menu.add_option(category_name, "title", title)
self.__filter = FilterOption(_("Filter"), 0)
self.__filter.set_help(
_("Select filter to restrict people that appear on calendar"))
@ -3073,10 +3097,6 @@ class NavWebOptions(MenuReportOptions):
self.__update_filters()
title = StringOption(_("Web site title"), _('My Family Tree'))
title.set_help(_("The title of the web site"))
menu.add_option(category_name, "title", title)
ext = EnumeratedListOption(_("File extension"), ".html" )
for etype in ['.html', '.htm', '.shtml', '.php', '.php3', '.cgi']:
ext.add_item(etype, etype)
@ -3097,7 +3117,7 @@ class NavWebOptions(MenuReportOptions):
encoding.set_help( _("The encoding to be used for the web files"))
menu.add_option(category_name, "encoding", encoding)
css = EnumeratedListOption(_('Stylesheet'), _CSS_FILES[0][1])
css = EnumeratedListOption(_('StyleSheet'), _CSS_FILES[0][1])
for style in _CSS_FILES:
css.add_item(style[1], style[0])
css.set_help( _('The stylesheet to be used for the web page'))