Updated menu in BirthdayReport. Changed alphabet navigation in NarrativeWeb. Updated WebCal to use name format option. Fixed a few elements in stylesheet.

svn: r12406
This commit is contained in:
Rob G. Healey 2009-04-06 03:49:47 +00:00
parent 26cb5e59c2
commit 0b61b4a8a4
4 changed files with 153 additions and 109 deletions

View File

@ -88,22 +88,33 @@ img {
background:none;
}
.content {
width:965px;
margin:0 auto;
padding-bottom:.5em;
background-color:#FFF;
color:#000;
}
.content div.snapshot {
float:right;
margin:1.6em;
margin:0;
padding:0;
background:none;
}
.content div.snapshot div.thumbnail {
margin:0;
padding:0;
padding:2em 0 0 0;
background:none;
}
.content div.snapshot div.thumbnail p {
display:none;
.content div.snapshot div.thumbnail a {
display:block;
width:96px;
margin:0 auto;
}
.fullclear {
width:100%;
height:1px;
margin:0;
padding:0;
clear:both;
}
/* General Text
@ -115,12 +126,11 @@ h2 {
display:none;
}
h3 {
width:80%;
font:normal 2em/1.2em serif;
text-align:left;
text-align:center;
margin:0;
padding:.5em 20px .2em 20px;
border-bottom:double 4px #453619;
border-bottom:double 4px #000;
}
h4 {
font:normal 1.2em/1.2em serif;
@ -128,7 +138,7 @@ h4 {
margin:0;
padding:.2em 0 .2em 20px;
background-color:#453619;
border-bottom:solid 1px #6AF364;
border-bottom:solid 2px #6AF364;
}
h5, h6 {
font:normal 1em/1.2em serif;
@ -276,6 +286,7 @@ p#user_header {
padding:0 0 0 9px;
background-color:#6AF364;
border-bottom:solid 2px #000;
border-top:solid 2px #000;
}
#alphabet ul li.letters {
margin:0;
@ -291,6 +302,7 @@ p#user_header {
color:#000;
margin:0;
padding:5px 5px;
text-decoration:none;
}
#alphabet ul li.letters a:hover {
background-color:#22822A;
@ -358,7 +370,7 @@ table.infolist {
padding:0;
background-color:#FFF;
}
table.infolist tr th {
table.infolist thead tr th {
font:normal 1.1em/1.2em serif;
color:#000;
margin:0;
@ -366,12 +378,12 @@ table.infolist tr th {
background-color:#6AF364;
border-bottom:solid 1px #000;
}
table.infolist tr th a {
table.infolist thead tr th a {
background-color:#6AF364;
color:#000;
}
table.infolist tr th a:hover {
table.infolist thead tr th a:hover {
background-color:#C1B398;
color:#000;
}
table.infolist tr td {
font:normal 1.1em/1.4em serif;
@ -425,15 +437,14 @@ table.infolist tbody tr td.ColumnParents span.mother:before {
----------------------------------------------------- */
#Surnames { }
#SurnameDetail p#description { padding-top:0; }
table.surnamelist tr thead th.ColumnSurname, #Surnames table.surnamelist tbody tr td.ColumnSurname {
table.surnamelist thead tr th.ColumnSurname, #Surnames table.surnamelist tbody tr td.ColumnSurname {
width:50%;
}
table.surnamelist tr th {
table.surnamelist thead tr th {
padding:0;
}
table.surnamelist tr th a, table.surnamelist tr th a:visited {
table.surnamelist thead tr th a, table.surnamelist thead tr th a:visited {
display:block;
color:#FFF;
text-align:left;
text-decoration:none;
padding:.2em 10px;
@ -466,10 +477,10 @@ table.surnamelist tbody tr td.ColumnSurname:hover, table#SortByName tbody tr td.
background-color:#C1B398;
}
table.surname {
border-bottom:solid 1px #453619;
border-bottom:solid 1px #000;
}
table.surname tbody tr td {
border-bottom:dashed 1px #453619;
border-bottom:dashed 1px #000;
}
table.surname thead tr th.ColumnName {
width:20%;
@ -484,9 +495,8 @@ table.surname tbody tr td.ColumnName a {
display:block;
padding:.6em 10px .6em 20px;
}
table.surname tbody tr td.ColumnName a span.grampsid {
display:none;
}
table.surname tbody tr td.ColumnName a span.grampsid { }
table.surname tbody tr td.ColumnName:hover {
background-color:#C1B398;
}
@ -739,6 +749,8 @@ div.subsection table.infolist {
----------------------------------------------------- */
div#events {
padding-bottom:0;
height:3cm;
overflow:auto;
}
div#events h4 {
margin-bottom:0;
@ -874,6 +886,10 @@ div#narrative {
/* Subsections : Source References
----------------------------------------------------- */
div#sourcerefs {
height:2.5cm;
overflow:auto;
}
div#sourcerefs ol {
list-style-type:decimal;
}
@ -1206,9 +1222,8 @@ body#WebCal {
.calendar tbody tr td ul li span.yearsmarried em {
color:#453619;
}
.calendar tbody tr td.highlight {
.calendar tbody tr td.highlight { }
}
.calendar tbody tr td.highlight div.date {
color:#0A65B5;
background-color:#C2E1FE;

View File

@ -2,6 +2,7 @@
#
# Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2008-2009 Brian G. Matherly
# Copyright (C) 2009 Rob G. Healey <robhealey1@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -27,8 +28,7 @@
#------------------------------------------------------------------------
from gettext import gettext as _
from gettext import ngettext
import datetime
import time
import datetime, time
#------------------------------------------------------------------------
#
@ -36,7 +36,7 @@ import time
#
#------------------------------------------------------------------------
import BaseDoc
from BasicUtils import name_displayer
from BasicUtils import name_displayer as _nd
from gen.plug import PluginManager
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_TEXT
from gen.plug.menu import BooleanOption, StringOption, NumberOption, \
@ -59,24 +59,24 @@ class CalendarReport(Report):
def __init__(self, database, options_class):
Report.__init__(self, database, options_class)
menu = options_class.menu
mgobn = lambda name:options_class.menu.get_option_by_name(name).get_value()
self.titletext = menu.get_option_by_name('titletext').get_value()
self.relationships = \
menu.get_option_by_name('relationships').get_value()
self.year = menu.get_option_by_name('year').get_value()
self.name_format = menu.get_option_by_name('name_format').get_value()
self.country = menu.get_option_by_name('country').get_value()
self.anniversaries = menu.get_option_by_name('anniversaries').get_value()
self.start_dow = menu.get_option_by_name('start_dow').get_value()
self.maiden_name = menu.get_option_by_name('maiden_name').get_value()
self.alive = menu.get_option_by_name('alive').get_value()
self.birthdays = menu.get_option_by_name('birthdays').get_value()
self.text1 = menu.get_option_by_name('text1').get_value()
self.text2 = menu.get_option_by_name('text2').get_value()
self.text3 = menu.get_option_by_name('text3').get_value()
self.titletext = mgobn('titletext')
self.relationships = mgobn('relationships')
self.year = mgobn('year')
self.name_format = mgobn('name_format')
self.country = mgobn('country')
self.anniversaries = mgobn('anniversaries')
self.start_dow = mgobn('start_dow')
self.maiden_name = mgobn('maiden_name')
self.alive = mgobn('alive')
self.birthdays = mgobn('birthdays')
self.text1 = mgobn('text1')
self.text2 = mgobn('text2')
self.text3 = mgobn('text3')
self.filter_option = menu.get_option_by_name('filter')
self.filter = self.filter_option.get_filter()
pid = menu.get_option_by_name('pid').get_value()
pid = mgobn('pid')
self.center_person = database.get_person_from_gramps_id(pid)
def get_name(self, person, maiden_name = None):
@ -102,7 +102,7 @@ class CalendarReport(Report):
else:
name = gen.lib.Name(primary_name)
name.set_display_as(self.name_format)
return name_displayer.display_name(name)
return _nd.display_name(name)
def add_day_item(self, text, month, day):
""" Add an item to a day. """
@ -152,7 +152,7 @@ class CalendarReport(Report):
if self.relationships:
name = self.center_person.get_primary_name()
self.doc.start_paragraph('BIR-Text3style')
self.doc.write_text(_("Relationships shown are to %s") % name_displayer.display_name(name))
self.doc.write_text(_("Relationships shown are to %s") % _nd.display_name(name))
self.doc.end_paragraph()
self.progress.set_pass(_('Formatting months...'), 12)
for month in range(1, 13):
@ -350,7 +350,7 @@ class CalendarOptions(MenuReportOptions):
# We must figure out the value of the first option before we can
# create the EnumeratedListOption
fmt_list = name_displayer.get_name_format()
fmt_list = _nd.get_name_format()
name_format = EnumeratedListOption(_("Name format"), fmt_list[0][0])
for num, name, fmt_str, act in fmt_list:
name_format.add_item(num, name)

View File

@ -288,6 +288,9 @@ class BasePage:
def alphabet_navigation(self, of, db, handle_list, key):
"""
Will create the alphabetical navigation bar...
handle_list -- a list of people's or Places' handles
key -- _PERSON or _PLACE
"""
sorted_set = {}
@ -301,24 +304,34 @@ class BasePage:
sorted_first_letter = sorted_set.keys()
sorted_first_letter.sort(locale.strcoll)
# remove a comma as a letter in Places at the least?
sorted_first_letter = [(ltr) for ltr in sorted_first_letter
if ltr != ',']
num_ltrs = len(sorted_first_letter)
if num_ltrs <= 26:
of.write('\t<div id="navigation">\n')
of.write('\t<div id="alphabet">\n')
of.write('\t\t<ul>\n')
for ltr in sorted_first_letter:
of.write('\t\t\t<li><a href="#%s">%s</a> </li>\n' % (ltr, ltr))
title_str = 'Surnames' if key == 0 else 'Places'
title_str += ' starting with %s' % ltr
of.write('\t\t\t<li class="letters"><a href="#%s" title="%s">%s</a></li>\n'
% (ltr, title_str, ltr))
of.write('\t\t</ul>\n')
of.write('\t</div>\n')
else:
nrows = (num_ltrs / 26)
index = 0
for rows in range(0, nrows):
of.write('\t<div id="navigation">\n')
of.write('\t<div id="alphabet">\n')
of.write('\t\t<ul>\n')
cols = 0
while (cols <= 26 and index <= num_ltrs):
of.write('\t\t\t<li><a href="#%s">%s</a></li>\n'
% (sorted_first_letter[index], sorted_first_letter[index]))
letter = sorted_first_letter[index]
title_str = 'Surnames' if key == 0 else 'Places'
title_str += ' starting with %s' % letter
of.write('\t\t\t<li class="letters"><a href="#%s" title="%s">%s</a></li>\n'
% (letter, title_str, letter))
cols += 1
index += 1
of.write('\t\t<ul>\n')

View File

@ -52,7 +52,7 @@ log = logging.getLogger(".WebPage")
# GRAMPS module
#
#------------------------------------------------------------------------
import gen.lib
from gen.lib import date, Date, Name, Person, NameType, EventType
import const
from GrampsCfg import get_researcher
from gen.plug import PluginManager
@ -60,12 +60,13 @@ from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_WEB
from gen.plug.menu import BooleanOption, NumberOption, StringOption, \
EnumeratedListOption, FilterOption, PersonOption, \
DestinationOption
import Utils
import GrampsLocale
from QuestionDialog import WarningDialog
from Utils import probably_alive
from Utils import probably_alive, ProgressMeter, xml_lang
from DateHandler import displayer as _dd
from BasicUtils import name_displayer as _nd
import libholiday
from libhtml import Html
@ -185,6 +186,7 @@ class WebCalReport(Report):
self.title_text = mgobn('title')
filter_option = options.menu.get_option_by_name('filter')
self.filter = filter_option.get_filter()
self.name_format = mgobn('name_format')
self.ext = mgobn('ext')
self.copy = mgobn('cright')
self.css = mgobn('css')
@ -193,7 +195,6 @@ class WebCalReport(Report):
self.start_dow = mgobn('start_dow')
self.multiyear = mgobn('multiyear')
self.start_year = mgobn('start_year')
self.end_year = mgobn('end_year')
@ -221,7 +222,7 @@ class WebCalReport(Report):
self.email = researcher.email
# set to today's date
self.today = gen.lib.date.Today()
self.today = date.Today()
self.warn_dir = True # Only give warning once.
@ -298,7 +299,7 @@ class WebCalReport(Report):
if month > 0:
try:
event_date = gen.lib.Date()
event_date = Date()
event_date.set_yr_mon_day(year, month, day)
except ValueError:
event_date = '...'
@ -436,7 +437,7 @@ class WebCalReport(Report):
subdirs = '../'*nr_up
# Header contants
xmllang = Utils.xml_lang()
xmllang = xml_lang()
_META1 = 'name="generator" content="%s %s %s"' % (const.PROGRAM_NAME, const.VERSION,
const.URL_HOMEPAGE)
_META2 = 'name="author" content="%s"' % self.author
@ -772,7 +773,7 @@ class WebCalReport(Report):
bday_anniv_list = self.calendar.get(month, {}).get(thisday.day, [])
# date is an instance because of subtracting abilities in date.py
event_date = gen.lib.Date()
event_date = Date()
event_date.set_yr_mon_day(thisday.year, thisday.month, thisday.day)
# get events for this day
@ -1108,6 +1109,40 @@ class WebCalReport(Report):
# close the file
self.close_file(od)
# ---------------------------------------------------------------------------------------
#
# Get person's short name
#
# ---------------------------------------------------------------------------------------
def get_name(self, person, maiden_name = None):
"""
Return person's name, unless maiden_name given, unless married_name
listed.
person -- person to get short name from
maiden_name -- either a woman's maiden name or man's surname
"""
# Get all of a person's names:
primary_name = person.primary_name
married_name = None
names = [primary_name] + person.get_alternate_names()
for name in names:
if int(name.get_type()) == NameType.MARRIED:
married_name = name
break # use first
# Now, decide which to use:
if maiden_name is not None:
if married_name is not None:
name = Name(married_name)
else:
name = Name(primary_name)
name.set_surname(maiden_name)
else:
name = Name(primary_name)
name.set_display_as(self.name_format)
return _nd.display_name(name)
# ---------------------------------------------------------------------------------------
#
# The database slave; Gathers information for calendars
@ -1141,12 +1176,13 @@ class WebCalReport(Report):
month = birth_date.get_month()
day = birth_date.get_day()
prob_alive_date = gen.lib.Date(this_year, month, day)
# date to figure if someone is still alive
prob_alive_date = Date(this_year, month, day)
# add some things to handle maiden name:
father_surname = None # husband, actually
sex = person.gender
if sex == gen.lib.Person.FEMALE:
if sex == Person.FEMALE:
# get husband's last name:
if self.maiden_name in ['spouse_first', 'spouse_last']:
@ -1164,7 +1200,7 @@ class WebCalReport(Report):
if father is not None:
father_name = father.primary_name
father_surname = _get_regular_surname(sex, father_name)
short_name = _get_short_name(person, father_surname)
short_name = self.get_name(person, father_surname)
alive = probably_alive(person, self.database, prob_alive_date)
if (self.alive and alive) or not self.alive:
text = _('%(short_name)s') % {'short_name' : short_name}
@ -1183,8 +1219,8 @@ class WebCalReport(Report):
if spouse_handle:
spouse = self.database.get_person_from_handle(spouse_handle)
if spouse:
spouse_name = _get_short_name(spouse)
short_name = _get_short_name(person)
spouse_name = self.get_name(spouse)
short_name = self.get_name(person)
# will return a marriage event or False if not married any longer
marriage_event = get_marriage_event(self.database, fam)
@ -1194,7 +1230,8 @@ class WebCalReport(Report):
month = event_obj.get_month()
day = event_obj.get_day()
prob_alive_date = gen.lib.Date(this_year, month, day)
# date to figure if someone is still alive
prob_alive_date = Date(this_year, month, day)
if event_obj.is_valid():
text = _('%(spouse)s and %(person)s') % {
@ -1224,7 +1261,7 @@ class WebCalReport(Report):
# Display date as user set in preferences
msg = _('Generated by <a href="http://gramps-project.org">'
'GRAMPS</a> on %(date)s') % {'date' : _dd.display(gen.lib.date.Today())}
'GRAMPS</a> on %(date)s') % {'date' : _dd.display(date.Today())}
p = Html('p', msg, id = 'createdate')
# add Generated by? to footer
@ -1263,7 +1300,7 @@ class WebCalReport(Report):
"""
# Create progress meter bar
self.progress = Utils.ProgressMeter(_("Web Calendar Report"), '')
self.progress = ProgressMeter(_("Web Calendar Report"), '')
# get data from database for birthdays/ anniversaries
self.collect_data(self.start_year)
@ -1278,6 +1315,7 @@ class WebCalReport(Report):
self.holidays = {}
# get the information, zero is equal to None
print self.country
if self.country != 0:
self.__get_holidays(cal_year)
@ -1364,6 +1402,15 @@ class WebCalOptions(MenuReportOptions):
self.__update_filters()
# We must figure out the value of the first option before we can
# create the EnumeratedListOption
fmt_list = _nd.get_name_format()
name_format = EnumeratedListOption(_("Name format"), fmt_list[0][0])
for num, name, fmt_str, act in fmt_list:
name_format.add_item(num, name)
name_format.set_help(_("Select the format to display names"))
menu.add_option(category_name, "name_format", name_format)
ext = EnumeratedListOption(_("File extension"), ".html" )
for etype in ['.html', '.htm', '.shtml', '.php', '.php3', '.cgi']:
ext.add_item(etype, etype)
@ -1389,7 +1436,7 @@ class WebCalOptions(MenuReportOptions):
category_name = _("Content Options")
# set to today's date for use in menu, etc.
today = gen.lib.date.Today()
today = date.Today()
self.__multiyear = BooleanOption(_('Create multiple year calendars'), False)
self.__multiyear.set_help(_('Whether to create Multiple year calendars or not.'))
@ -1583,6 +1630,11 @@ def mywriter(page, of):
#
# ---------------------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------
#
# Support Functions for this plugin
#
# ---------------------------------------------------------------------------------------
def _get_regular_surname(sex, name):
"""
Returns a name string built from the components of the Name instance.
@ -1592,48 +1644,12 @@ def _get_regular_surname(sex, name):
prefix = name.get_surname_prefix()
if prefix:
surname = prefix + " " + surname
if sex is not gen.lib.Person.FEMALE:
if sex is not Person.FEMALE:
suffix = name.get_suffix()
if suffix:
surname = surname + ", " + suffix
return surname
def _get_short_name(person, maiden_name=None):
""" Return person's name, unless maiden_name given,
unless married_name listed. """
# Get all of a person's names:
primary_name = person.primary_name
sex = person.gender
call_name = None
married_name = None
names = [primary_name] + person.get_alternate_names()
for name in names:
if int(name.get_type()) == gen.lib.NameType.MARRIED:
married_name = name
# Now, decide which to use:
if maiden_name:
if married_name:
first_name, family_name = married_name.get_first_name(), _get_regular_surname(sex, married_name)
call_name = married_name.get_call_name()
else:
first_name, family_name = primary_name.get_first_name(), maiden_name
call_name = primary_name.get_call_name()
else:
first_name, family_name = primary_name.get_first_name(), _get_regular_surname(sex, primary_name)
call_name = primary_name.get_call_name()
# If they have a nickname, use it?
if call_name:
first_name = call_name.strip()
else: # else just get the first name:
first_name = first_name.strip()
if " " in first_name:
# just one split max
first_name, rest = first_name.split(" ", 1)
return ("%s %s" % (first_name, family_name)).strip()
# Simple utility list to convert Gramps day-of-week numbering
# to calendar.firstweekday numbering
dow_gramps2iso = [ -1, calendar.SUNDAY, calendar.MONDAY, calendar.TUESDAY,
@ -1660,12 +1676,12 @@ def get_marriage_event(db, family):
marriage_event = False
for event_ref in family.get_event_ref_list():
event = db.get_event_from_handle(event_ref.ref)
if event.type in [gen.lib.EventType.MARRIAGE,
gen.lib.EventType.MARR_ALT]:
if event.type in [EventType.MARRIAGE,
EventType.MARR_ALT]:
marriage_event = event
elif event.type in [gen.lib.EventType.DIVORCE,
gen.lib.EventType.ANNULMENT,
gen.lib.EventType.DIV_FILING]:
elif event.type in [EventType.DIVORCE,
EventType.ANNULMENT,
EventType.DIV_FILING]:
marriage_event = False
return marriage_event