2005-02-01 09:16:29 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-28 11:11:40 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2007-07-24 09:58:17 +05:30
|
|
|
# Copyright (C) 2007 Johan Gonqvist <johan.gronqvist@gmail.com>
|
2007-09-28 17:46:12 +05:30
|
|
|
# Copyright (C) 2007 Gary Burton <gary.burton@zen.co.uk>
|
2008-06-18 10:36:25 +05:30
|
|
|
# Copyright (C) 2007-2008 Stephane Charette <stephanecharette@gmail.com>
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2008 Brian G. Matherly
|
2005-02-01 09:16:29 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
2008-03-10 01:42:56 +05:30
|
|
|
# it under the terms of the GNU General Public License as published by
|
2005-02-01 09:16:29 +05:30
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
"""
|
|
|
|
Narrative Web Page generator.
|
|
|
|
"""
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2008-03-15 02:37:35 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Suggested pylint usage:
|
|
|
|
# --max-line-length=100 Yes, I know PEP8 suggest 80, but this has longer lines
|
|
|
|
# --argument-rgx='[a-z_][a-z0-9_]{1,30}$' Several identifiers are two characters
|
|
|
|
# --variable-rgx='[a-z_][a-z0-9_]{1,30}$' Several identifiers are two characters
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
2005-02-01 09:16:29 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import os
|
2008-05-21 00:54:03 +05:30
|
|
|
import re
|
2005-08-18 11:28:28 +05:30
|
|
|
import md5
|
|
|
|
import time
|
|
|
|
import locale
|
2005-02-01 09:16:29 +05:30
|
|
|
import shutil
|
2005-08-18 11:28:28 +05:30
|
|
|
import codecs
|
2005-12-06 12:08:09 +05:30
|
|
|
import tarfile
|
2008-03-08 22:10:19 +05:30
|
|
|
import operator
|
2008-04-01 01:20:37 +05:30
|
|
|
from TransUtils import sgettext as _
|
2005-08-18 11:28:28 +05:30
|
|
|
from cStringIO import StringIO
|
2007-01-08 09:18:49 +05:30
|
|
|
from textwrap import TextWrapper
|
2007-10-04 09:26:41 +05:30
|
|
|
from unicodedata import normalize
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2006-03-05 10:01:24 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Set up logging
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".WebPage")
|
|
|
|
|
2005-02-01 09:16:29 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS module
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2005-02-01 09:16:29 +05:30
|
|
|
import const
|
2005-08-18 11:28:28 +05:30
|
|
|
from GrampsCfg import get_researcher
|
2005-02-01 09:16:29 +05:30
|
|
|
import Sort
|
2008-05-19 00:54:28 +05:30
|
|
|
from PluginUtils import (PluginManager, FilterOption, EnumeratedListOption,
|
2008-03-08 22:10:19 +05:30
|
|
|
PersonOption, BooleanOption, NumberOption,
|
|
|
|
StringOption, DestinationOption, NoteOption,
|
2008-02-19 01:37:09 +05:30
|
|
|
MediaOption)
|
2008-03-08 22:10:19 +05:30
|
|
|
from ReportBase import (Report, ReportUtils, MenuReportOptions, CATEGORY_WEB,
|
2008-02-19 01:37:09 +05:30
|
|
|
MODE_GUI, MODE_CLI, Bibliography)
|
2005-02-01 09:16:29 +05:30
|
|
|
import Utils
|
2007-09-11 03:44:33 +05:30
|
|
|
import ThumbNails
|
2007-11-04 08:59:58 +05:30
|
|
|
import ImgManip
|
2007-11-03 11:13:12 +05:30
|
|
|
import Mime
|
2005-08-18 11:28:28 +05:30
|
|
|
from QuestionDialog import ErrorDialog, WarningDialog
|
2007-06-28 11:11:40 +05:30
|
|
|
from BasicUtils import name_displayer as _nd
|
2005-02-04 19:24:02 +05:30
|
|
|
from DateHandler import displayer as _dd
|
2007-08-05 11:12:43 +05:30
|
|
|
from DateHandler import parser as _dp
|
2008-02-19 01:37:09 +05:30
|
|
|
from gen.proxy import PrivateProxyDb, LivingProxyDb
|
2007-10-16 17:39:20 +05:30
|
|
|
from gen.lib.eventroletype import EventRoleType
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# constants
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-06-05 09:15:14 +05:30
|
|
|
_INCLUDE_LIVING_VALUE = 99 # Arbitrary number
|
2008-07-15 19:07:17 +05:30
|
|
|
_NARRATIVESCREEN = "narrative-screen.css"
|
2008-03-06 18:37:37 +05:30
|
|
|
_NARRATIVEPRINT = "narrative-print.css"
|
2005-08-18 11:28:28 +05:30
|
|
|
_NAME_COL = 3
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
_MAX_IMG_WIDTH = 800 # resize images that are wider than this
|
|
|
|
_MAX_IMG_HEIGHT = 600 # resize images that are taller than this
|
|
|
|
_WIDTH = 160
|
|
|
|
_HEIGHT = 50
|
|
|
|
_VGAP = 10
|
|
|
|
_HGAP = 30
|
|
|
|
_SHADOW = 5
|
|
|
|
_XOFFSET = 5
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-12 03:41:42 +05:30
|
|
|
# This information defines the list of styles in the Narrative Web
|
|
|
|
# options dialog as well as the location of the corresponding SCREEN
|
|
|
|
# stylesheets.
|
2008-02-10 09:39:09 +05:30
|
|
|
_CSS_FILES = [
|
2008-03-12 03:41:42 +05:30
|
|
|
# First is used as default selection.
|
2008-07-16 13:29:29 +05:30
|
|
|
[_("Evergreen"), 'Web_Evergreen.css'],
|
|
|
|
[_("Nebraska"), 'Web_Nebraska.css'],
|
|
|
|
[_("Simply Red"), 'Web_Simply-Red.css'],
|
2008-03-08 17:00:59 +05:30
|
|
|
[_("No style sheet"), ''],
|
2005-08-18 11:28:28 +05:30
|
|
|
]
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
_CHARACTER_SETS = [
|
2008-03-12 03:41:42 +05:30
|
|
|
# First is used as default selection.
|
2005-08-18 11:28:28 +05:30
|
|
|
[_('Unicode (recommended)'), 'utf-8'],
|
|
|
|
['ISO-8859-1', 'iso-8859-1' ],
|
|
|
|
['ISO-8859-2', 'iso-8859-2' ],
|
|
|
|
['ISO-8859-3', 'iso-8859-3' ],
|
|
|
|
['ISO-8859-4', 'iso-8859-4' ],
|
|
|
|
['ISO-8859-5', 'iso-8859-5' ],
|
|
|
|
['ISO-8859-6', 'iso-8859-6' ],
|
|
|
|
['ISO-8859-7', 'iso-8859-7' ],
|
|
|
|
['ISO-8859-8', 'iso-8859-8' ],
|
|
|
|
['ISO-8859-9', 'iso-8859-9' ],
|
|
|
|
['ISO-8859-10', 'iso-8859-10' ],
|
|
|
|
['ISO-8859-13', 'iso-8859-13' ],
|
|
|
|
['ISO-8859-14', 'iso-8859-14' ],
|
|
|
|
['ISO-8859-15', 'iso-8859-15' ],
|
|
|
|
['koi8_r', 'koi8_r', ],
|
|
|
|
]
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
_CC = [
|
2008-03-18 02:39:16 +05:30
|
|
|
'',
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
'<a rel="license" href="http://creativecommons.org/licenses/by/2.5/">'
|
2008-03-08 22:10:19 +05:30
|
|
|
'<img alt="Creative Commons License - By attribution" '
|
|
|
|
'title="Creative Commons License - By attribution" '
|
2008-07-16 13:29:29 +05:30
|
|
|
'src="%(gif_fname)s" /></a>',
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
'<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" '
|
2008-07-16 13:29:29 +05:30
|
|
|
'src="%(gif_fname)s" /></a>',
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
'<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" '
|
2008-07-16 13:29:29 +05:30
|
|
|
'src="%(gif_fname)s" /></a>',
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
'<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" '
|
2008-07-16 13:29:29 +05:30
|
|
|
'src="%(gif_fname)s" /></a>',
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
'<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.5/">'
|
2008-03-08 22:10:19 +05:30
|
|
|
'<img alt="Creative Commons License - By attribution, Non-commercial, No derivations" '
|
|
|
|
'title="Creative Commons License - By attribution, Non-commercial, No derivations" '
|
2008-07-16 13:29:29 +05:30
|
|
|
'src="%(gif_fname)s" /></a>',
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
'<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/">'
|
2008-03-08 22:10:19 +05:30
|
|
|
'<img alt="Creative Commons License - By attribution, Non-commerical, Share-alike" '
|
|
|
|
'title="Creative Commons License - By attribution, Non-commerical, Share-alike" '
|
2008-07-16 13:29:29 +05:30
|
|
|
'src="%(gif_fname)s" /></a>'
|
2005-02-04 09:24:48 +05:30
|
|
|
]
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
_COPY_OPTIONS = [
|
|
|
|
_('Standard copyright'),
|
|
|
|
_('Creative Commons - By attribution'),
|
|
|
|
_('Creative Commons - By attribution, No derivations'),
|
|
|
|
_('Creative Commons - By attribution, Share-alike'),
|
|
|
|
_('Creative Commons - By attribution, Non-commercial'),
|
|
|
|
_('Creative Commons - By attribution, Non-commercial, No derivations'),
|
|
|
|
_('Creative Commons - By attribution, Non-commercial, Share-alike'),
|
|
|
|
_('No copyright notice'),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2007-01-08 09:18:49 +05:30
|
|
|
wrapper = TextWrapper()
|
|
|
|
wrapper.break_log_words = True
|
|
|
|
wrapper.width = 20
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-05-21 00:54:03 +05:30
|
|
|
|
|
|
|
_html_dbl_quotes = re.compile(r'([^"]*) " ([^"]*) " (.*)', re.VERBOSE)
|
|
|
|
_html_sng_quotes = re.compile(r"([^']*) ' ([^']*) ' (.*)", re.VERBOSE)
|
|
|
|
_html_replacement = {
|
2008-03-08 22:10:19 +05:30
|
|
|
"&" : "&",
|
2008-04-12 08:19:34 +05:30
|
|
|
">" : ">",
|
|
|
|
"<" : "<",
|
2008-03-06 18:37:37 +05:30
|
|
|
}
|
2008-03-08 22:10:19 +05:30
|
|
|
|
|
|
|
# This command then defines the 'html_escape' option for escaping
|
|
|
|
# special characters for presentation in HTML based on the above list.
|
2008-03-06 18:37:37 +05:30
|
|
|
def html_escape(text):
|
2008-03-10 01:42:56 +05:30
|
|
|
"""Convert the text and replace some characters with a &# variant."""
|
2008-05-21 00:54:03 +05:30
|
|
|
|
|
|
|
# First single characters, no quotes
|
|
|
|
text = ''.join([_html_replacement.get(c, c) for c in text])
|
|
|
|
|
|
|
|
# Deal with double quotes.
|
|
|
|
while 1:
|
|
|
|
m = _html_dbl_quotes.match(text)
|
|
|
|
if not m:
|
|
|
|
break
|
|
|
|
text = m.group(1) + '“' + m.group(2) + '”' + m.group(3)
|
|
|
|
# Replace remaining double quotes.
|
|
|
|
text = text.replace('"', '"')
|
|
|
|
|
|
|
|
# Deal with single quotes.
|
|
|
|
text = text.replace("'s ", '’s ')
|
|
|
|
while 1:
|
|
|
|
m = _html_sng_quotes.match(text)
|
|
|
|
if not m:
|
|
|
|
break
|
|
|
|
text = m.group(1) + '‘' + m.group(2) + '’' + m.group(3)
|
|
|
|
# Replace remaining single quotes.
|
|
|
|
text = text.replace("'", ''')
|
|
|
|
|
|
|
|
return text
|
2008-03-06 18:37:37 +05:30
|
|
|
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-04-01 01:20:37 +05:30
|
|
|
def name_to_md5(text):
|
|
|
|
"""This creates an MD5 hex string to be used as filename."""
|
|
|
|
return md5.new(text).hexdigest()
|
|
|
|
|
|
|
|
|
2005-02-10 07:14:05 +05:30
|
|
|
class BasePage:
|
2008-03-10 01:42:56 +05:30
|
|
|
"""
|
2008-07-06 14:10:47 +05:30
|
|
|
This is the base class to write certain HTML pages.
|
2008-03-10 01:42:56 +05:30
|
|
|
"""
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title, gid=None):
|
2008-03-10 01:42:56 +05:30
|
|
|
"""
|
2008-03-14 03:58:22 +05:30
|
|
|
report - instance of NavWebReport
|
2008-03-10 01:42:56 +05:30
|
|
|
title - text for the <title> tag
|
|
|
|
gid - Gramps ID
|
|
|
|
"""
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
self.report = report
|
2005-02-13 09:24:47 +05:30
|
|
|
self.title_str = title
|
2005-08-18 11:28:28 +05:30
|
|
|
self.gid = gid
|
2008-03-14 03:58:22 +05:30
|
|
|
self.src_list = {}
|
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
self.page_title = ""
|
|
|
|
|
2008-03-12 03:41:42 +05:30
|
|
|
self.author = get_researcher().get_name()
|
|
|
|
if self.author:
|
|
|
|
self.author = self.author.replace(',,,', '')
|
|
|
|
self.up = False
|
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
# TODO. All of these attributes are not necessary, because we have
|
2008-03-14 02:01:33 +05:30
|
|
|
# also the options in self.options. Besides, we need to check which
|
2008-03-10 01:42:56 +05:30
|
|
|
# are still required.
|
2008-03-14 03:58:22 +05:30
|
|
|
options = report.options
|
2008-02-10 09:39:09 +05:30
|
|
|
self.html_dir = options['target']
|
|
|
|
self.ext = options['ext']
|
|
|
|
self.noid = options['nogid']
|
|
|
|
self.linkhome = options['linkhome']
|
|
|
|
self.use_gallery = options['gallery']
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
def write_footer(self, of):
|
|
|
|
|
|
|
|
of.write('</div>\n') # Terminate div_content
|
2008-03-15 02:37:35 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
of.write('<div id="footer">\n')
|
2008-03-18 02:39:16 +05:30
|
|
|
footer = self.report.options['footernote']
|
|
|
|
if footer:
|
|
|
|
note = self.report.database.get_note_from_gramps_id(footer)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t<div id="user_footer">\n')
|
|
|
|
of.write('\t\t<p>')
|
2008-03-14 02:01:33 +05:30
|
|
|
of.write(note.get())
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('</p>\n')
|
|
|
|
of.write('\t</div>\n')
|
2008-03-15 02:37:35 +05:30
|
|
|
|
2008-07-16 13:29:29 +05:30
|
|
|
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:
|
2005-08-18 11:28:28 +05:30
|
|
|
if self.author:
|
2008-07-15 19:07:17 +05:30
|
|
|
year = time.localtime()[0]
|
2005-08-18 11:28:28 +05:30
|
|
|
cright = _('© %(year)d %(person)s') % {
|
|
|
|
'person' : self.author,
|
|
|
|
'year' : year }
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('%s' % cright)
|
2008-07-16 13:29:29 +05:30
|
|
|
elif 0 < copy_nr < 7:
|
|
|
|
text = _CC[copy_nr]
|
2008-07-17 17:24:33 +05:30
|
|
|
fname = self.build_url_fname("somerights20.gif", 'images', self.up)
|
2008-07-16 13:29:29 +05:30
|
|
|
text = text % {'gif_fname' : fname}
|
2005-08-18 11:28:28 +05:30
|
|
|
of.write(text)
|
2008-07-16 13:29:29 +05:30
|
|
|
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')
|
2008-03-15 02:37:35 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
of.write('\t\t<div class="fullclear"></div>\n')
|
|
|
|
of.write('</div>\n')
|
2005-02-21 04:57:55 +05:30
|
|
|
of.write('</body>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</html>')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
def write_header(self, of, title, content_divid=None):
|
2008-03-21 03:54:36 +05:30
|
|
|
"""
|
|
|
|
Note. 'title' is used as currentsection in the navigation links.
|
|
|
|
"""
|
2008-07-15 19:07:17 +05:30
|
|
|
|
|
|
|
of.write('<!DOCTYPE html PUBLIC \n')
|
|
|
|
of.write(' "-//W3C//DTD XHTML 1.0 Strict//EN" \n')
|
|
|
|
of.write(' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
of.write('<html xmlns="http://www.w3.org/1999/xhtml" ')
|
2005-12-13 07:37:16 +05:30
|
|
|
xmllang = Utils.xml_lang()
|
2008-07-15 19:07:17 +05:30
|
|
|
of.write('xml:lang="%s" lang="%s">\n' % (xmllang, xmllang))
|
2008-03-21 03:54:36 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('<head>\n')
|
2008-07-15 19:07:17 +05:30
|
|
|
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; ')
|
2008-03-21 03:54:36 +05:30
|
|
|
of.write('charset=%s" />\n' % self.report.encoding)
|
2008-07-16 13:29:29 +05:30
|
|
|
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)
|
2008-03-18 02:39:16 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
# Link to narrative.css
|
2008-07-16 13:29:29 +05:30
|
|
|
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)
|
2008-03-06 18:37:37 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
# Link to narrativePrint.css
|
2008-07-16 13:29:29 +05:30
|
|
|
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)
|
2008-03-08 17:00:59 +05:30
|
|
|
|
|
|
|
# Link to favicon.ico
|
2008-03-21 03:54:36 +05:30
|
|
|
url = self.report.build_url_image('favicon.ico', 'images', self.up)
|
2008-07-15 19:07:17 +05:30
|
|
|
of.write(' <link href="%s" rel="Shortcut Icon" />\n' % url)
|
|
|
|
of.write(' <!-- %sId%s -->\n' % ('$', '$'))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</head>\n\n')
|
|
|
|
|
2008-07-16 13:29:29 +05:30
|
|
|
of.write('<body id="NarrativeWeb">\n') # Terminated in write_footer()
|
|
|
|
of.write(' <div id="header">\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-07-16 13:29:29 +05:30
|
|
|
# FIXME. Do we want an empty GRAMPSinfo div below if no self.linkhome?
|
|
|
|
msg = ""
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
2007-07-19 12:15:25 +05:30
|
|
|
if self.linkhome:
|
2008-03-12 02:49:36 +05:30
|
|
|
home_person = db.get_default_person()
|
|
|
|
if home_person:
|
2008-03-21 03:54:36 +05:30
|
|
|
home_person_url = self.report.build_url_fname_html(home_person.handle, 'ppl', self.up)
|
2007-07-19 12:15:25 +05:30
|
|
|
home_person_name = home_person.get_primary_name().get_regular_name()
|
2008-07-16 13:29:29 +05:30
|
|
|
msg = _('Created for <a href="%s">%s</a>') % (home_person_url, home_person_name)
|
2008-03-06 18:37:37 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
of.write(' <div id="GRAMPSinfo">%s</div>\n' % msg)
|
|
|
|
of.write(' <h1 id="SiteTitle">%s</h1>\n' % html_escape(self.title_str))
|
2008-03-18 02:39:16 +05:30
|
|
|
header = self.report.options['headernote']
|
|
|
|
if header:
|
|
|
|
note = db.get_note_from_gramps_id(header)
|
2008-07-15 19:07:17 +05:30
|
|
|
of.write(' <p id="user_header">')
|
2008-03-14 02:01:33 +05:30
|
|
|
of.write(note.get())
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</p>\n')
|
2008-07-15 19:07:17 +05:30
|
|
|
of.write('\t</div>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
|
2008-07-16 13:29:29 +05:30
|
|
|
# Begin Navigation Menu
|
|
|
|
of.write(' <div id="navigation">\n')
|
|
|
|
of.write(' <ul>\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
self.display_nav_links(of, title)
|
2008-03-15 02:37:35 +05:30
|
|
|
|
2008-07-16 13:29:29 +05:30
|
|
|
of.write(' </ul>\n')
|
2008-07-15 19:07:17 +05:30
|
|
|
of.write(' </div>\n') # End Navigation Menu
|
2008-03-15 02:37:35 +05:30
|
|
|
|
2008-04-01 01:20:37 +05:30
|
|
|
divid = ''
|
|
|
|
if content_divid:
|
|
|
|
divid = ' id="%s"' % content_divid
|
|
|
|
of.write('<div%s class="content">\n' % divid)
|
2008-03-21 03:54:36 +05:30
|
|
|
|
|
|
|
def display_nav_links(self, of, currentsection):
|
|
|
|
navs = [
|
|
|
|
(self.report.index_fname, _('Home'), self.report.use_home),
|
|
|
|
(self.report.intro_fname, _('Introduction'), self.report.use_intro),
|
|
|
|
(self.report.surname_fname, _('Surnames'), True),
|
|
|
|
('individuals', _('Individuals'), True),
|
|
|
|
('places', _('Places'), True),
|
|
|
|
('gallery', _('Gallery'), self.use_gallery),
|
|
|
|
('download', _('Download'), self.report.inc_download),
|
|
|
|
('contact', _('Contact'), self.report.use_contact),
|
2008-07-15 19:07:17 +05:30
|
|
|
('sources', _('Sources'), True),
|
2008-03-21 03:54:36 +05:30
|
|
|
]
|
2008-07-15 19:07:17 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
for url_fname, nav_text, cond in navs:
|
|
|
|
if cond:
|
|
|
|
url = url_fname + self.ext
|
|
|
|
if self.up:
|
|
|
|
# TODO. Check if build_url_fname can be used.
|
|
|
|
url = '/'.join(['..']*3 + [url])
|
|
|
|
self.display_nav_link(of, url, nav_text, currentsection)
|
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
# TODO. Move this logic to a higher level (caller of write_header).
|
2008-03-08 17:00:59 +05:30
|
|
|
|
2008-03-18 02:39:16 +05:30
|
|
|
# Define 'currentsection' to correctly set navlink item CSS id
|
|
|
|
# 'CurrentSection' for Navigation styling.
|
|
|
|
# Use 'self.report.cur_fname' to determine 'CurrentSection' for individual
|
|
|
|
# elements for Navigation styling.
|
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
def display_nav_link(self, of, url, title, currentsection):
|
2008-03-08 17:00:59 +05:30
|
|
|
# Figure out if we need <li id="CurrentSection"> of just plain <li>
|
|
|
|
cs = False
|
2008-03-18 02:39:16 +05:30
|
|
|
if title == currentsection:
|
2008-03-08 17:00:59 +05:30
|
|
|
cs = True
|
2008-03-18 02:39:16 +05:30
|
|
|
elif title == _('Surnames'):
|
|
|
|
if "srn" in self.report.cur_fname:
|
2008-03-08 17:00:59 +05:30
|
|
|
cs = True
|
2008-03-18 02:39:16 +05:30
|
|
|
elif _('Surnames') in currentsection:
|
2008-03-08 17:00:59 +05:30
|
|
|
cs = True
|
2008-03-18 02:39:16 +05:30
|
|
|
elif title == _('Individuals'):
|
|
|
|
if "ppl" in self.report.cur_fname:
|
2008-03-08 17:00:59 +05:30
|
|
|
cs = True
|
2008-03-18 02:39:16 +05:30
|
|
|
elif title == _('Sources'):
|
|
|
|
if "src" in self.report.cur_fname:
|
2008-03-08 17:00:59 +05:30
|
|
|
cs = True
|
2008-03-18 02:39:16 +05:30
|
|
|
elif title == _('Places'):
|
|
|
|
if "plc" in self.report.cur_fname:
|
2008-03-08 17:00:59 +05:30
|
|
|
cs = True
|
2008-03-18 02:39:16 +05:30
|
|
|
elif title == _('Gallery'):
|
|
|
|
if "img" in self.report.cur_fname:
|
2008-03-08 17:00:59 +05:30
|
|
|
cs = True
|
|
|
|
|
|
|
|
cs = cs and ' id="CurrentSection"' or ''
|
2008-03-21 03:54:36 +05:30
|
|
|
of.write('\t\t<li%s><a href="%s">%s</a></li>\n' % (cs, url, title))
|
2008-03-06 18:37:37 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def display_first_image_as_thumbnail( self, of, photolist=None):
|
2005-12-06 12:08:09 +05:30
|
|
|
if not photolist or not self.use_gallery:
|
2005-08-18 11:28:28 +05:30
|
|
|
return
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
photo_handle = photolist[0].get_reference_handle()
|
2008-03-14 03:58:22 +05:30
|
|
|
photo = self.report.database.get_object_from_handle(photo_handle)
|
2005-12-06 12:08:09 +05:30
|
|
|
mime_type = photo.get_mime_type()
|
|
|
|
|
|
|
|
if mime_type:
|
2005-08-18 11:28:28 +05:30
|
|
|
try:
|
2008-03-21 03:54:36 +05:30
|
|
|
lnkref = (self.report.cur_fname, self.page_title, self.gid)
|
|
|
|
self.report.add_lnkref_to_photo(photo, lnkref)
|
2008-07-17 17:24:33 +05:30
|
|
|
real_path, newpath = self.report.prepare_copy_media(photo)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div class="snapshot">\n')
|
2008-03-21 03:54:36 +05:30
|
|
|
# TODO. Check if build_url_fname can be used.
|
|
|
|
newpath = '/'.join(['..']*3 + [newpath])
|
2008-03-10 01:42:56 +05:30
|
|
|
self.media_link(of, photo_handle, newpath, '', up=True)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t</div>\n\n')
|
2008-03-10 01:42:56 +05:30
|
|
|
except (IOError, OSError), msg:
|
|
|
|
WarningDialog(_("Could not add photo to page"), str(msg))
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div class="snapshot">\n')
|
2007-01-08 09:18:49 +05:30
|
|
|
descr = " ".join(wrapper.wrap(photo.get_description()))
|
|
|
|
self.doc_link(of, photo_handle, descr, up=True)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t</div>\n\n')
|
2008-03-10 01:42:56 +05:30
|
|
|
|
2008-03-18 02:39:16 +05:30
|
|
|
lnk = (self.report.cur_fname, self.page_title, self.gid)
|
2008-03-14 03:58:22 +05:30
|
|
|
# FIXME. Is it OK to add to the photo_list of report?
|
|
|
|
photo_list = self.report.photo_list
|
|
|
|
if photo_handle in photo_list:
|
|
|
|
if lnk not in photo_list[photo_handle]:
|
|
|
|
photo_list[photo_handle].append(lnk)
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2008-03-14 03:58:22 +05:30
|
|
|
photo_list[photo_handle] = [lnk]
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def display_additional_images_as_gallery( self, of, photolist=None):
|
2005-12-06 12:08:09 +05:30
|
|
|
if not photolist or not self.use_gallery:
|
2005-08-18 11:28:28 +05:30
|
|
|
return
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="indivgallery" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _('Gallery'))
|
2008-04-14 02:10:12 +05:30
|
|
|
displayed = []
|
2005-08-18 11:28:28 +05:30
|
|
|
for mediaref in photolist:
|
2008-04-01 01:20:37 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
photo_handle = mediaref.get_reference_handle()
|
|
|
|
photo = db.get_object_from_handle(photo_handle)
|
2008-04-14 02:10:12 +05:30
|
|
|
if photo_handle in displayed:
|
|
|
|
continue
|
2005-12-06 12:08:09 +05:30
|
|
|
mime_type = photo.get_mime_type()
|
2008-04-01 01:20:37 +05:30
|
|
|
|
2007-04-09 09:10:11 +05:30
|
|
|
title = photo.get_description()
|
|
|
|
if title == "":
|
|
|
|
title = "(untitled)"
|
2005-12-06 12:08:09 +05:30
|
|
|
if mime_type:
|
2005-08-18 11:28:28 +05:30
|
|
|
try:
|
2008-03-21 03:54:36 +05:30
|
|
|
lnkref = (self.report.cur_fname, self.page_title, self.gid)
|
|
|
|
self.report.add_lnkref_to_photo(photo, lnkref)
|
2008-07-17 17:24:33 +05:30
|
|
|
real_path, newpath = self.report.prepare_copy_media(photo)
|
2007-04-09 09:10:11 +05:30
|
|
|
descr = " ".join(wrapper.wrap(title))
|
2008-03-21 03:54:36 +05:30
|
|
|
# TODO. Check if build_url_fname can be used.
|
|
|
|
newpath = '/'.join(['..']*3 + [newpath])
|
2007-01-08 09:18:49 +05:30
|
|
|
self.media_link(of, photo_handle, newpath, descr, up=True)
|
2008-03-10 01:42:56 +05:30
|
|
|
except (IOError, OSError), msg:
|
|
|
|
WarningDialog(_("Could not add photo to page"), str(msg))
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
|
|
|
try:
|
2007-04-09 09:10:11 +05:30
|
|
|
descr = " ".join(wrapper.wrap(title))
|
2007-01-08 09:18:49 +05:30
|
|
|
self.doc_link(of, photo_handle, descr, up=True)
|
2008-03-10 01:42:56 +05:30
|
|
|
|
2008-03-18 02:39:16 +05:30
|
|
|
lnk = (self.report.cur_fname, self.page_title, self.gid)
|
2008-03-14 03:58:22 +05:30
|
|
|
# FIXME. Is it OK to add to the photo_list of report?
|
|
|
|
photo_list = self.report.photo_list
|
|
|
|
if photo_handle in photo_list:
|
|
|
|
if lnk not in photo_list[photo_handle]:
|
|
|
|
photo_list[photo_handle].append(lnk)
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2008-03-14 03:58:22 +05:30
|
|
|
photo_list[photo_handle] = [lnk]
|
2008-03-10 01:42:56 +05:30
|
|
|
except (IOError, OSError), msg:
|
|
|
|
WarningDialog(_("Could not add photo to page"), str(msg))
|
2008-04-14 02:10:12 +05:30
|
|
|
displayed.append(photo_handle)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t<div class="fullclear"></div>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def display_note_list(self, of, notelist=None):
|
2007-03-10 09:55:23 +05:30
|
|
|
if not notelist:
|
2005-08-18 11:28:28 +05:30
|
|
|
return
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
2007-03-10 09:55:23 +05:30
|
|
|
for notehandle in notelist:
|
2008-03-14 02:01:33 +05:30
|
|
|
note = db.get_note_from_handle(notehandle)
|
|
|
|
format = note.get_format()
|
|
|
|
text = note.get()
|
2007-03-10 09:55:23 +05:30
|
|
|
try:
|
|
|
|
text = unicode(text)
|
|
|
|
except UnicodeDecodeError:
|
2008-03-10 01:42:56 +05:30
|
|
|
text = unicode(str(text), errors='replace')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2007-03-10 09:55:23 +05:30
|
|
|
if text:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="narrative" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _('Narrative'))
|
2007-03-10 09:55:23 +05:30
|
|
|
if format:
|
|
|
|
text = u"<pre>%s</pre>" % text
|
|
|
|
else:
|
2008-05-04 12:35:42 +05:30
|
|
|
text = u"<br />".join(text.split("\n"))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t<p>%s</p>\n' % text)
|
|
|
|
of.write('\t</div>\n\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
def display_url_list(self, of, urllist=None):
|
2005-08-18 11:28:28 +05:30
|
|
|
if not urllist:
|
|
|
|
return
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="weblinks" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _('Weblinks'))
|
|
|
|
of.write('\t\t<ol>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
index = 1
|
|
|
|
for url in urllist:
|
|
|
|
uri = url.get_path()
|
|
|
|
descr = url.get_description()
|
2006-08-23 06:39:54 +05:30
|
|
|
if not descr:
|
|
|
|
descr = uri
|
2007-10-08 22:11:39 +05:30
|
|
|
if url.get_type() == gen.lib.UrlType.EMAIL and not uri.startswith("mailto:"):
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('\t\t\t<li><a href="mailto:%s">%s</a>' % (uri, descr))
|
2007-10-08 22:11:39 +05:30
|
|
|
elif url.get_type() == gen.lib.UrlType.WEB_HOME and not uri.startswith("http://"):
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('\t\t\t<li><a href="http://%s">%s</a>' % (uri, descr))
|
2007-10-08 22:11:39 +05:30
|
|
|
elif url.get_type() == gen.lib.UrlType.WEB_FTP and not uri.startswith("ftp://"):
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('\t\t\t<li><a href="ftp://%s">%s</a>' % (uri, descr))
|
2007-03-06 10:00:22 +05:30
|
|
|
else:
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('\t\t\t<li><a href="%s">%s</a>' % (uri, descr))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</li>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
index = index + 1
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</ol>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 04:05:26 +05:30
|
|
|
# Only used in IndividualPage.display_ind_sources
|
2008-03-14 02:01:33 +05:30
|
|
|
# and MediaPage.display_media_sources
|
2008-03-14 04:05:26 +05:30
|
|
|
def display_source_refs(self, of, bibli):
|
2008-03-01 10:13:58 +05:30
|
|
|
if bibli.get_citation_count() == 0:
|
2007-08-23 15:24:37 +05:30
|
|
|
return
|
2008-03-14 02:01:33 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="sourcerefs" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _('Source References'))
|
|
|
|
of.write('\t\t<ol>\n')
|
2007-08-23 15:24:37 +05:30
|
|
|
|
|
|
|
cindex = 0
|
2008-03-01 10:13:58 +05:30
|
|
|
for citation in bibli.get_citation_list():
|
2007-08-23 15:24:37 +05:30
|
|
|
cindex += 1
|
|
|
|
# Add this source to the global list of sources to be displayed
|
|
|
|
# on each source page.
|
2008-03-18 02:39:16 +05:30
|
|
|
lnk = (self.report.cur_fname, self.page_title, self.gid)
|
2007-08-23 15:24:37 +05:30
|
|
|
shandle = citation.get_source_handle()
|
2008-03-14 02:01:33 +05:30
|
|
|
if shandle in self.src_list:
|
2007-08-23 15:24:37 +05:30
|
|
|
if lnk not in self.src_list[shandle]:
|
|
|
|
self.src_list[shandle].append(lnk)
|
|
|
|
else:
|
|
|
|
self.src_list[shandle] = [lnk]
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2007-08-23 15:24:37 +05:30
|
|
|
# Add this source and its references to the page
|
2008-03-01 10:13:58 +05:30
|
|
|
source = db.get_source_from_handle(shandle)
|
2007-08-23 15:24:37 +05:30
|
|
|
title = source.get_title()
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<li><a name="sref%d"' % cindex)
|
2008-05-21 00:54:03 +05:30
|
|
|
# Note. The closing > is done in source_link()
|
2008-03-01 10:13:58 +05:30
|
|
|
self.source_link(of, source.handle, title, source.gramps_id, True)
|
2007-08-23 15:24:37 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\n')
|
|
|
|
of.write('\t\t\t\t<ol>\n')
|
2008-03-10 01:42:56 +05:30
|
|
|
for key, sref in citation.get_ref_list():
|
2007-08-23 15:24:37 +05:30
|
|
|
|
|
|
|
tmp = []
|
|
|
|
confidence = Utils.confidence.get(sref.confidence, _('Unknown'))
|
2007-11-17 11:36:43 +05:30
|
|
|
if confidence == _('Normal'):
|
|
|
|
confidence = None
|
2008-03-01 10:13:58 +05:30
|
|
|
for (label, data) in [(_('Date'), _dd.display(sref.date)),
|
|
|
|
(_('Page'), sref.page),
|
|
|
|
(_('Confidence'), confidence)]:
|
2007-08-23 15:24:37 +05:30
|
|
|
if data:
|
2008-03-01 10:13:58 +05:30
|
|
|
tmp.append("%s: %s" % (label, data))
|
2007-08-23 15:24:37 +05:30
|
|
|
notelist = sref.get_note_list()
|
|
|
|
for notehandle in notelist:
|
2008-03-01 10:13:58 +05:30
|
|
|
note = db.get_note_from_handle(notehandle)
|
2008-03-14 02:01:33 +05:30
|
|
|
tmp.append("%s: %s" % (_('Text'), note.get()))
|
2007-08-23 15:24:37 +05:30
|
|
|
if len(tmp) > 0:
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('\t\t\t\t\t<li><a name="sref%d%s">' % (cindex, key))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('; '.join(tmp))
|
|
|
|
of.write('</a></li>\n')
|
|
|
|
of.write('\t\t\t\t</ol>\n')
|
|
|
|
of.write('\t\t\t</li>\n')
|
|
|
|
of.write('\t\t</ol>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2007-08-23 15:24:37 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
def display_references(self, of, handlelist, up=False):
|
2005-08-18 11:28:28 +05:30
|
|
|
if not handlelist:
|
|
|
|
return
|
2008-03-14 02:01:33 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="references" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _('References'))
|
|
|
|
of.write('\t\t<ol>\n')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
|
|
|
sortlist = sorted(handlelist,
|
|
|
|
key = operator.itemgetter(1),
|
2007-10-04 09:26:41 +05:30
|
|
|
cmp = locale.strcoll)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
index = 1
|
2008-03-10 01:42:56 +05:30
|
|
|
for (path, name, gid) in sortlist:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<li>')
|
2008-03-21 03:54:36 +05:30
|
|
|
# Note. 'path' already has a filename extension
|
|
|
|
url = self.report.build_url_fname(path, None, self.up)
|
|
|
|
self.person_link(of, url, name, gid)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</li>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
index = index + 1
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</ol>\n')
|
|
|
|
of.write('\t</div>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
def person_link(self, of, url, name, gid=None):
|
|
|
|
of.write('<a href="%s">%s' % (url, name))
|
2008-03-14 03:58:22 +05:30
|
|
|
if not self.noid and gid:
|
2005-08-18 11:28:28 +05:30
|
|
|
of.write(' <span class="grampsid">[%s]</span>' % gid)
|
|
|
|
of.write('</a>')
|
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
# TODO. Check img_url of callers
|
|
|
|
def media_link(self, of, handle, img_url, name, up, usedescr=True):
|
2008-07-04 00:40:05 +05:30
|
|
|
url = self.report.build_url_fname_html(handle, 'img', up)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t<div class="thumbnail">\n')
|
2008-03-21 03:54:36 +05:30
|
|
|
of.write('\t\t\t<a href="%s">' % url)
|
|
|
|
of.write('<img src="%s" ' % img_url)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('alt="%s" /></a>\n' % name)
|
2005-08-18 11:28:28 +05:30
|
|
|
if usedescr:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<p>%s</p>\n' % html_escape(name))
|
|
|
|
of.write('\t\t</div>\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
def doc_link(self, of, handle, name, up, usedescr=True):
|
2008-03-21 03:54:36 +05:30
|
|
|
# TODO. Check extension of handle
|
|
|
|
url = self.report.build_url_fname(handle, 'img', up)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t<div class="thumbnail">\n')
|
2008-03-21 03:54:36 +05:30
|
|
|
of.write('\t\t\t<a href="%s">' % url)
|
|
|
|
url = self.report.build_url_image('document.png', 'images', up)
|
|
|
|
of.write('<img src="%s" ' % url)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('alt="%s" /></a>\n' % html_escape(name))
|
2005-12-06 12:08:09 +05:30
|
|
|
if usedescr:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<p>%s</p>\n' % html_escape(name))
|
|
|
|
of.write('\t\t</div>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
def source_link(self, of, handle, name, gid=None, up=False):
|
|
|
|
url = self.report.build_url_fname_html(handle, 'src', up)
|
|
|
|
of.write(' href="%s">%s' % (url, html_escape(name)))
|
|
|
|
if not self.noid and gid:
|
2005-08-18 11:28:28 +05:30
|
|
|
of.write(' <span class="grampsid">[%s]</span>' % gid)
|
|
|
|
of.write('</a>')
|
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
def place_link(self, of, handle, name, gid=None, up=False):
|
|
|
|
url = self.report.build_url_fname_html(handle, 'plc', up)
|
|
|
|
of.write('<a href="%s">%s' % (url, html_escape(name)))
|
|
|
|
if not self.noid and gid:
|
2005-08-18 11:28:28 +05:30
|
|
|
of.write(' <span class="grampsid">[%s]</span>' % gid)
|
|
|
|
of.write('</a>')
|
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
def place_link_str(self, handle, name, gid=None, up=False):
|
|
|
|
url = self.report.build_url_fname_html(handle, 'plc', up)
|
|
|
|
retval = '<a href="%s">%s' % (url, html_escape(name))
|
|
|
|
if not self.noid and gid:
|
2005-08-18 11:28:28 +05:30
|
|
|
retval = retval + ' <span class="grampsid">[%s]</span>' % gid
|
|
|
|
return retval + '</a>'
|
2005-02-10 07:14:05 +05:30
|
|
|
|
|
|
|
class IndividualListPage(BasePage):
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title, person_handle_list):
|
|
|
|
BasePage.__init__(self, report, title)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = report.database
|
2008-03-18 02:39:16 +05:30
|
|
|
of = self.report.create_file("individuals")
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, _('Individuals'), content_divid='Individuals')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
msg = _("This page contains an index of all the individuals in the "
|
2008-03-06 18:37:37 +05:30
|
|
|
"database, sorted by their last names. Selecting the person’s "
|
|
|
|
"name will take you to that person’s individual page.")
|
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
showbirth = report.options['showbirth']
|
|
|
|
showdeath = report.options['showdeath']
|
|
|
|
showspouse = report.options['showspouse']
|
|
|
|
showparents = report.options['showparents']
|
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<h2>%s</h2>\n' % _('Individuals'))
|
|
|
|
of.write('\t<p id="description">%s</p>\n' % msg)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t<table class="infolist individuallist">\n')
|
|
|
|
of.write('\t<thead>\n')
|
|
|
|
of.write('\t\t<tr>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnSurname">%s</th>\n' % _('Surname'))
|
|
|
|
of.write('\t\t\t<th class="ColumnName">%s</th>\n' % _('Name'))
|
2007-07-19 12:15:25 +05:30
|
|
|
column_count = 2
|
2008-03-21 03:54:36 +05:30
|
|
|
if showbirth:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnBirth">%s</th>\n' % _('Birth'))
|
2007-07-19 12:15:25 +05:30
|
|
|
column_count += 1
|
2008-03-21 03:54:36 +05:30
|
|
|
if showdeath:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnDeath">%s</th>\n' % _('Death'))
|
2007-07-19 12:15:25 +05:30
|
|
|
column_count += 1
|
2008-03-21 03:54:36 +05:30
|
|
|
if showspouse:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnPartner">%s</th>\n' % _('Partner'))
|
2007-07-19 12:15:25 +05:30
|
|
|
column_count += 1
|
2008-03-21 03:54:36 +05:30
|
|
|
if showparents:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnParents">%s</th>\n' % _('Parents'))
|
2007-07-19 12:15:25 +05:30
|
|
|
column_count += 1
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t</tr>\n')
|
|
|
|
of.write('\t</thead>\n')
|
|
|
|
of.write('\t<tbody>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
person_handle_list = sort_people(db, person_handle_list)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
for (surname, handle_list) in person_handle_list:
|
2005-08-18 11:28:28 +05:30
|
|
|
first = True
|
|
|
|
for person_handle in handle_list:
|
|
|
|
person = db.get_person_from_handle(person_handle)
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# surname column
|
2005-08-18 11:28:28 +05:30
|
|
|
if first:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t<tr class="BeginSurname">\n')
|
2008-04-01 01:20:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnSurname"><a name="%s">%s</a>' % (name_to_md5(surname), surname))
|
2005-08-18 11:28:28 +05:30
|
|
|
else:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t<td class="ColumnSurname"> ')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</td>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# firstname column
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnName">')
|
2008-03-21 03:54:36 +05:30
|
|
|
url = self.report.build_url_fname_html(person.handle, 'ppl')
|
|
|
|
self.person_link(of, url,
|
2008-03-14 02:01:33 +05:30
|
|
|
_nd.display_given(person), person.gramps_id)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</td>\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2007-07-19 12:15:25 +05:30
|
|
|
# birth column
|
2008-03-21 03:54:36 +05:30
|
|
|
if showbirth:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnBirth">')
|
2007-09-28 17:46:12 +05:30
|
|
|
birth = ReportUtils.get_birth_or_fallback(db, person)
|
|
|
|
if birth:
|
2007-10-08 22:11:39 +05:30
|
|
|
if birth.get_type() == gen.lib.EventType.BIRTH:
|
2007-09-28 17:46:12 +05:30
|
|
|
of.write(_dd.display(birth.get_date_object()))
|
|
|
|
else:
|
|
|
|
of.write('<em>')
|
|
|
|
of.write(_dd.display(birth.get_date_object()))
|
|
|
|
of.write('</em>')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</td>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# death column
|
2008-03-21 03:54:36 +05:30
|
|
|
if showdeath:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnDeath">')
|
2007-09-28 17:46:12 +05:30
|
|
|
death = ReportUtils.get_death_or_fallback(db, person)
|
|
|
|
if death:
|
2007-10-08 22:11:39 +05:30
|
|
|
if death.get_type() == gen.lib.EventType.DEATH:
|
2007-09-28 17:46:12 +05:30
|
|
|
of.write(_dd.display(death.get_date_object()))
|
|
|
|
else:
|
|
|
|
of.write('<em>')
|
|
|
|
of.write(_dd.display(death.get_date_object()))
|
|
|
|
of.write('</em>')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</td>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# spouse (partner) column
|
2008-03-21 03:54:36 +05:30
|
|
|
if showspouse:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnPartner">')
|
2007-08-27 01:49:18 +05:30
|
|
|
family_list = person.get_family_handle_list()
|
|
|
|
first_family = True
|
|
|
|
spouse_name = None
|
|
|
|
if family_list:
|
|
|
|
for family_handle in family_list:
|
|
|
|
family = db.get_family_from_handle(family_handle)
|
|
|
|
spouse_id = ReportUtils.find_spouse(person, family)
|
|
|
|
if spouse_id:
|
|
|
|
spouse = db.get_person_from_handle(spouse_id)
|
|
|
|
spouse_name = spouse.get_primary_name().get_regular_name()
|
|
|
|
if not first_family:
|
|
|
|
of.write(', ')
|
|
|
|
of.write('%s' % spouse_name)
|
|
|
|
first_family = False
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</td>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# parents column
|
2008-03-21 03:54:36 +05:30
|
|
|
if showparents:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnParents">')
|
2007-07-19 12:15:25 +05:30
|
|
|
parent_handle_list = person.get_parent_family_handle_list()
|
|
|
|
if parent_handle_list:
|
|
|
|
parent_handle = parent_handle_list[0]
|
|
|
|
family = db.get_family_from_handle(parent_handle)
|
|
|
|
father_name = ''
|
|
|
|
mother_name = ''
|
|
|
|
father_id = family.get_father_handle()
|
|
|
|
mother_id = family.get_mother_handle()
|
|
|
|
father = db.get_person_from_handle(father_id)
|
|
|
|
mother = db.get_person_from_handle(mother_id)
|
2007-08-12 08:12:22 +05:30
|
|
|
if father:
|
2007-07-19 12:15:25 +05:30
|
|
|
father_name = father.get_primary_name().get_regular_name()
|
2007-08-12 08:12:22 +05:30
|
|
|
if mother:
|
2007-07-19 12:15:25 +05:30
|
|
|
mother_name = mother.get_primary_name().get_regular_name()
|
|
|
|
if mother and father:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('<span class="father fatherNmother">%s</span> <span class="mother">%s</span>' % (father_name, mother_name))
|
2007-07-19 12:15:25 +05:30
|
|
|
elif mother:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('<span class="mother">%s</span>' % mother_name)
|
2007-07-19 12:15:25 +05:30
|
|
|
elif father:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('<span class="father">%s</span>' % father_name)
|
|
|
|
of.write('</td>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# finished writing all columns
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</tr>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
first = False
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t</tbody>\n')
|
|
|
|
of.write('\t</table>\n')
|
2008-03-14 03:58:22 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
class SurnamePage(BasePage):
|
|
|
|
|
2008-03-15 02:37:35 +05:30
|
|
|
def __init__(self, report, title, surname, person_handle_list):
|
2008-03-14 03:58:22 +05:30
|
|
|
BasePage.__init__(self, report, title)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = report.database
|
2008-04-01 01:20:37 +05:30
|
|
|
of = self.report.create_file(name_to_md5(surname), 'srn')
|
2008-03-12 03:41:42 +05:30
|
|
|
self.up = True
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, "%s - %s" % (_('Surname'), surname), content_divid='SurnameDetail')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
msg = _("This page contains an index of all the individuals in the "
|
2008-03-06 18:37:37 +05:30
|
|
|
"database with the surname of %s. Selecting the person’s name "
|
2008-03-15 02:37:35 +05:30
|
|
|
"will take you to that person’s individual page.") % surname
|
2008-03-06 18:37:37 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
showbirth = report.options['showbirth']
|
|
|
|
showdeath = report.options['showdeath']
|
|
|
|
showspouse = report.options['showspouse']
|
|
|
|
showparents = report.options['showparents']
|
|
|
|
|
2008-03-15 02:37:35 +05:30
|
|
|
of.write('\t<h2>%s:</h2>\n' % _('Surnames'))
|
|
|
|
of.write('\t<h3>%s</h3>\n' % html_escape(surname))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<p id="description">%s</p>\n' % msg)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t<table class="infolist surname">\n')
|
|
|
|
of.write('\t<thead>\n')
|
|
|
|
of.write('\t\t<tr>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnName">%s</th>\n' % _('Name'))
|
2008-03-21 03:54:36 +05:30
|
|
|
if showbirth:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnBirth">%s</th>\n' % _('Birth'))
|
2008-03-21 03:54:36 +05:30
|
|
|
if showdeath:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnDeath">%s</th>\n' % _('Death'))
|
2008-03-21 03:54:36 +05:30
|
|
|
if showspouse:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnPartner">%s</th>\n' % _('Partner'))
|
2008-03-21 03:54:36 +05:30
|
|
|
if showparents:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnParents">%s</th>\n' % _('Parents'))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t</tr>\n')
|
|
|
|
of.write('\t</thead>\n')
|
|
|
|
of.write('\t<tbody>\n')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
|
|
|
for person_handle in person_handle_list:
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# firstname column
|
2005-02-10 07:14:05 +05:30
|
|
|
person = db.get_person_from_handle(person_handle)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t<td class="ColumnName">')
|
2008-03-21 03:54:36 +05:30
|
|
|
url = self.report.build_url_fname_html(person.handle, 'ppl', True)
|
|
|
|
self.person_link(of, url,
|
2005-08-18 11:28:28 +05:30
|
|
|
person.get_primary_name().get_first_name(),
|
2008-03-14 02:01:33 +05:30
|
|
|
person.gramps_id)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</td>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# birth column
|
2008-03-21 03:54:36 +05:30
|
|
|
if showbirth:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnBirth">')
|
2007-09-28 17:46:12 +05:30
|
|
|
birth = ReportUtils.get_birth_or_fallback(db, person)
|
|
|
|
if birth:
|
2007-10-08 22:11:39 +05:30
|
|
|
if birth.get_type() == gen.lib.EventType.BIRTH:
|
2007-09-28 17:46:12 +05:30
|
|
|
of.write(_dd.display(birth.get_date_object()))
|
|
|
|
else:
|
|
|
|
of.write('<em>')
|
|
|
|
of.write(_dd.display(birth.get_date_object()))
|
|
|
|
of.write('</em>')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</td>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# death column
|
2008-03-21 03:54:36 +05:30
|
|
|
if showdeath:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnDeath">')
|
2007-09-28 17:46:12 +05:30
|
|
|
death = ReportUtils.get_death_or_fallback(db, person)
|
|
|
|
if death:
|
2007-10-08 22:11:39 +05:30
|
|
|
if death.get_type() == gen.lib.EventType.DEATH:
|
2007-09-28 17:46:12 +05:30
|
|
|
of.write(_dd.display(death.get_date_object()))
|
|
|
|
else:
|
|
|
|
of.write('<em>')
|
|
|
|
of.write(_dd.display(death.get_date_object()))
|
|
|
|
of.write('</em>')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</td>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# spouse (partner) column
|
2008-03-21 03:54:36 +05:30
|
|
|
if showspouse:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnPartner">')
|
2007-08-27 01:49:18 +05:30
|
|
|
family_list = person.get_family_handle_list()
|
|
|
|
first_family = True
|
|
|
|
spouse_name = None
|
|
|
|
if family_list:
|
|
|
|
for family_handle in family_list:
|
|
|
|
family = db.get_family_from_handle(family_handle)
|
|
|
|
spouse_id = ReportUtils.find_spouse(person, family)
|
|
|
|
if spouse_id:
|
|
|
|
spouse = db.get_person_from_handle(spouse_id)
|
|
|
|
spouse_name = spouse.get_primary_name().get_regular_name()
|
|
|
|
if not first_family:
|
|
|
|
of.write(', ')
|
|
|
|
of.write('%s' % spouse_name)
|
|
|
|
first_family = False
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</td>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# parents column
|
2008-03-21 03:54:36 +05:30
|
|
|
if showparents:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnParents">')
|
2007-07-19 12:15:25 +05:30
|
|
|
parent_handle_list = person.get_parent_family_handle_list()
|
|
|
|
if parent_handle_list:
|
|
|
|
parent_handle = parent_handle_list[0]
|
|
|
|
family = db.get_family_from_handle(parent_handle)
|
|
|
|
father_name = ''
|
|
|
|
mother_name = ''
|
|
|
|
father_id = family.get_father_handle()
|
|
|
|
mother_id = family.get_mother_handle()
|
|
|
|
father = db.get_person_from_handle(father_id)
|
|
|
|
mother = db.get_person_from_handle(mother_id)
|
2007-08-12 08:12:22 +05:30
|
|
|
if father:
|
2007-07-19 12:15:25 +05:30
|
|
|
father_name = father.get_primary_name().get_regular_name()
|
2007-08-12 08:12:22 +05:30
|
|
|
if mother:
|
2007-07-19 12:15:25 +05:30
|
|
|
mother_name = mother.get_primary_name().get_regular_name()
|
|
|
|
if mother and father:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('<span class="father fatherNmother">%s</span> <span class="mother">%s</span>' % (father_name, mother_name))
|
2007-07-19 12:15:25 +05:30
|
|
|
elif mother:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('<span class="mother">%s</span>' % mother_name)
|
2007-07-19 12:15:25 +05:30
|
|
|
elif father:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('<span class="father">%s</span>' % father_name)
|
|
|
|
of.write('</td>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# finished writing all columns
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</tr>\n')
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t</tbody>\n')
|
|
|
|
of.write('\t</table>\n')
|
2008-03-14 03:58:22 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2005-02-13 09:24:47 +05:30
|
|
|
class PlaceListPage(BasePage):
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title, place_handles, src_list):
|
|
|
|
BasePage.__init__(self, report, title)
|
|
|
|
self.src_list = src_list # TODO verify that this is correct
|
|
|
|
|
|
|
|
db = report.database
|
2008-03-18 02:39:16 +05:30
|
|
|
of = self.report.create_file("places")
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, _('Places'), content_divid='Places')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
msg = _("This page contains an index of all the places in the "
|
2008-03-06 18:37:37 +05:30
|
|
|
"database, sorted by their title. Clicking on a place’s "
|
|
|
|
"title will take you to that place’s page.")
|
2005-02-13 09:24:47 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<h2>%s</h2>\n' % _('Places'))
|
|
|
|
of.write('\t<p id="description">%s</p>\n' % msg )
|
2005-02-13 09:24:47 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t<table class="infolist placelist">\n')
|
|
|
|
of.write('\t<thead>\n')
|
|
|
|
of.write('\t\t<tr>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnLetter">%s</th>\n' % _('Letter'))
|
|
|
|
of.write('\t\t\t<th class="ColumnName">%s</th>\n' % _('Name'))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t</tr>\n')
|
|
|
|
of.write('\t</thead>\n')
|
|
|
|
of.write('\t<tbody>\n\n')
|
2005-02-13 09:24:47 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
sort = Sort.Sort(db)
|
2005-08-18 11:28:28 +05:30
|
|
|
handle_list = place_handles.keys()
|
2008-03-14 03:58:22 +05:30
|
|
|
handle_list.sort(sort.by_place_title)
|
2005-02-13 09:24:47 +05:30
|
|
|
last_letter = ''
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2005-02-13 09:24:47 +05:30
|
|
|
for handle in handle_list:
|
|
|
|
place = db.get_place_from_handle(handle)
|
2008-02-24 19:25:55 +05:30
|
|
|
n = ReportUtils.place_name(db, handle)
|
2005-02-13 09:24:47 +05:30
|
|
|
|
2008-05-21 00:54:03 +05:30
|
|
|
if not n:
|
2005-02-13 09:24:47 +05:30
|
|
|
continue
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
letter = normalize('NFD', n)[0].upper()
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2007-10-04 09:26:41 +05:30
|
|
|
if letter != last_letter:
|
|
|
|
last_letter = letter
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t<tr class="BeginLetter">\n')
|
|
|
|
of.write('\t\t\t<td class="ColumnLetter">%s</td>\n' % last_letter)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnName">')
|
2008-03-10 01:42:56 +05:30
|
|
|
self.place_link(of, place.handle, n, place.gramps_id)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('</td>\n')
|
|
|
|
of.write('\t\t</tr>\n')
|
2007-10-04 09:26:41 +05:30
|
|
|
else:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t<td class="ColumnLetter"> </td>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnName">')
|
2008-03-10 01:42:56 +05:30
|
|
|
self.place_link(of, place.handle, n, place.gramps_id)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('</td>\n')
|
|
|
|
of.write('\t\t</tr>\n')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t</tbody>\n')
|
|
|
|
of.write('\t</table>\n')
|
2008-03-14 03:58:22 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-02-13 09:24:47 +05:30
|
|
|
|
2005-07-09 01:54:54 +05:30
|
|
|
class PlacePage(BasePage):
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title, place_handle, src_list, place_list):
|
|
|
|
db = report.database
|
|
|
|
place = db.get_place_from_handle(place_handle)
|
|
|
|
BasePage.__init__(self, report, title, place.gramps_id)
|
|
|
|
self.src_list = src_list # TODO verify that this is correct
|
2008-03-12 03:41:42 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
of = self.report.create_file(place.get_handle(), 'plc')
|
2008-03-12 03:41:42 +05:30
|
|
|
self.up = True
|
2008-03-18 02:39:16 +05:30
|
|
|
self.page_title = ReportUtils.place_name(db, place_handle)
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, "%s - %s" % (_('Places'), self.page_title), content_divid='PlaceDetail')
|
2005-07-09 01:54:54 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
media_list = place.get_media_list()
|
2008-03-14 03:58:22 +05:30
|
|
|
self.display_first_image_as_thumbnail(of, media_list)
|
2005-07-09 01:54:54 +05:30
|
|
|
|
2008-07-17 17:40:17 +05:30
|
|
|
of.write('\t<h2>%s:</h2>\n' % _('Places'))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<h3>%s</h3>\n\n' % html_escape(self.page_title.strip()))
|
|
|
|
of.write('\t<div id="summaryarea">\n')
|
|
|
|
of.write('\t\t<table class="infolist place">\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
if not self.noid:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _('GRAMPS ID'))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % place.gramps_id)
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2005-07-09 01:54:54 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
if place.main_loc:
|
|
|
|
ml = place.main_loc
|
2008-03-10 01:42:56 +05:30
|
|
|
for val in [(_('Street'), ml.street),
|
|
|
|
(_('City'), ml.city),
|
|
|
|
(_('Church Parish'), ml.parish),
|
|
|
|
(_('County'), ml.county),
|
|
|
|
(_('State/Province'), ml.state),
|
|
|
|
(_('Postal Code'), ml.postal),
|
|
|
|
(_('Country'), ml.country)]:
|
2005-08-18 11:28:28 +05:30
|
|
|
if val[1]:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % val[0])
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % val[1])
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
if place.lat:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _('Latitude'))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % place.lat)
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2005-07-09 01:54:54 +05:30
|
|
|
|
2008-05-06 12:21:22 +05:30
|
|
|
if place.long:
|
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _('Longitude'))
|
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % place.long)
|
|
|
|
of.write('\t\t\t</tr>\n')
|
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</table>\n')
|
|
|
|
of.write('\t</div>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
if self.use_gallery:
|
2008-03-14 03:58:22 +05:30
|
|
|
self.display_additional_images_as_gallery(of, media_list)
|
|
|
|
self.display_note_list(of, place.get_note_list())
|
2007-08-12 08:12:22 +05:30
|
|
|
self.display_url_list(of, place.get_url_list())
|
2008-03-14 03:58:22 +05:30
|
|
|
self.display_references(of, place_list[place.handle])
|
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-07-09 01:54:54 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
class MediaPage(BasePage):
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title, handle, src_list, my_media_list, info):
|
2005-08-18 11:28:28 +05:30
|
|
|
(prev, next, page_number, total_pages) = info
|
2008-03-14 03:58:22 +05:30
|
|
|
db = report.database
|
2005-08-18 11:28:28 +05:30
|
|
|
photo = db.get_object_from_handle(handle)
|
2008-03-14 03:58:22 +05:30
|
|
|
# TODO. How do we pass my_media_list down for use in BasePage?
|
|
|
|
BasePage.__init__(self, report, title, photo.gramps_id)
|
2008-03-18 02:39:16 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
of = self.report.create_file(handle, 'img')
|
2008-03-18 02:39:16 +05:30
|
|
|
self.up = True
|
2007-11-03 11:13:12 +05:30
|
|
|
|
2007-11-05 12:46:10 +05:30
|
|
|
self.src_list = src_list
|
2008-03-14 03:58:22 +05:30
|
|
|
self.bibli = Bibliography()
|
2007-11-05 12:46:10 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
mime_type = photo.get_mime_type()
|
2007-11-03 11:13:12 +05:30
|
|
|
|
2007-04-09 09:10:11 +05:30
|
|
|
if mime_type:
|
|
|
|
note_only = False
|
2005-12-06 12:08:09 +05:30
|
|
|
newpath = self.copy_source_file(handle, photo)
|
2008-06-16 20:31:46 +05:30
|
|
|
target_exists = newpath is not None
|
2005-08-18 11:28:28 +05:30
|
|
|
else:
|
2007-04-09 09:10:11 +05:30
|
|
|
note_only = True
|
2005-12-06 12:08:09 +05:30
|
|
|
target_exists = False
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
self.copy_thumbnail(handle, photo)
|
2005-08-18 11:28:28 +05:30
|
|
|
self.page_title = photo.get_description()
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, "%s - %s" % (_('Gallery'), self.page_title), content_divid='GalleryDetail')
|
2007-11-03 11:13:12 +05:30
|
|
|
|
2008-03-12 03:41:42 +05:30
|
|
|
of.write('\t<h2>%s:</h2>\n' % _('Gallery'))
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
# gallery navigation
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t<div id="GalleryNav">\n')
|
|
|
|
of.write('\t\t')
|
2005-08-18 11:28:28 +05:30
|
|
|
if prev:
|
2008-07-04 01:16:50 +05:30
|
|
|
self.gallery_nav_link(of, prev, _('Previous'), True)
|
2008-03-06 18:37:37 +05:30
|
|
|
data = _('<strong id="GalleryCurrent">%(page_number)d</strong> of <strong id="GalleryTotal">%(total_pages)d</strong>' ) % {
|
2005-08-18 11:28:28 +05:30
|
|
|
'page_number' : page_number, 'total_pages' : total_pages }
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write(' <span id="GalleryPages">%s</span> ' % data)
|
2005-08-18 11:28:28 +05:30
|
|
|
if next:
|
2008-07-04 01:16:50 +05:30
|
|
|
self.gallery_nav_link(of, next, _('Next'), True)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="summaryarea">\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
if mime_type:
|
|
|
|
if mime_type.startswith("image/"):
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t<div id="GalleryDisplay">\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
if target_exists:
|
2007-11-04 08:59:58 +05:30
|
|
|
# if the image is spectacularly large, then force the client
|
|
|
|
# to resize it, and include a "<a href=" link to the actual
|
|
|
|
# image; most web browsers will dynamically resize an image
|
|
|
|
# and provide zoom-in/zoom-out functionality when the image
|
|
|
|
# is displayed directly
|
2008-02-18 19:36:41 +05:30
|
|
|
(width, height) = ImgManip.image_size(
|
2008-03-14 03:58:22 +05:30
|
|
|
Utils.media_path_full(db, photo.get_path()))
|
2007-11-04 08:59:58 +05:30
|
|
|
scale = 1.0
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t')
|
2008-03-21 03:54:36 +05:30
|
|
|
# TODO. Convert disk path to URL.
|
|
|
|
url = self.report.build_url_fname(newpath, None, self.up)
|
2008-02-10 09:39:09 +05:30
|
|
|
if width > _MAX_IMG_WIDTH or height > _MAX_IMG_HEIGHT:
|
2007-11-04 08:59:58 +05:30
|
|
|
# image is too large -- scale it down and link to the full image
|
2008-02-10 09:39:09 +05:30
|
|
|
scale = min(float(_MAX_IMG_WIDTH)/float(width), float(_MAX_IMG_HEIGHT)/float(height))
|
2007-11-04 08:59:58 +05:30
|
|
|
width = int(width * scale)
|
|
|
|
height = int(height * scale)
|
2008-03-21 03:54:36 +05:30
|
|
|
of.write('<a href="%s">' % url)
|
|
|
|
of.write('<img width="%d" height="%d" src="%s" alt="%s" />' % (width, height, url, html_escape(self.page_title)))
|
2008-03-10 01:42:56 +05:30
|
|
|
if scale != 1.0:
|
2008-03-14 03:58:22 +05:30
|
|
|
of.write('</a>')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\n')
|
2007-11-04 08:59:58 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<span class="MissingImage">(%s)</span>' % _("The file has been moved or deleted"))
|
|
|
|
of.write('\t\t</div>\n\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
|
|
|
import tempfile
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
dirname = tempfile.mkdtemp()
|
2008-03-10 01:42:56 +05:30
|
|
|
thmb_path = os.path.join(dirname, "temp.png")
|
2008-03-08 22:10:19 +05:30
|
|
|
if ThumbNails.run_thumbnailer(mime_type,
|
2008-03-14 03:58:22 +05:30
|
|
|
Utils.media_path_full(db,
|
2008-03-08 22:10:19 +05:30
|
|
|
photo.get_path()),
|
2008-02-18 19:36:41 +05:30
|
|
|
thmb_path, 320):
|
2005-12-06 12:08:09 +05:30
|
|
|
try:
|
2008-03-21 03:54:36 +05:30
|
|
|
path = self.report.build_path('preview', photo.handle)
|
2008-07-17 17:24:33 +05:30
|
|
|
self.report.copy_file(thmb_path, os.path.join(path, photo.handle) + '.png')
|
2005-12-06 12:08:09 +05:30
|
|
|
os.unlink(thmb_path)
|
|
|
|
except IOError:
|
2008-03-10 01:42:56 +05:30
|
|
|
path = os.path.join('images', 'document.png')
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2008-03-10 01:42:56 +05:30
|
|
|
path = os.path.join('images', 'document.png')
|
2005-12-06 12:08:09 +05:30
|
|
|
os.rmdir(dirname)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t<div id="GalleryDisplay">\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
if target_exists:
|
2008-03-21 03:54:36 +05:30
|
|
|
# TODO. Convert disk path to URL
|
|
|
|
url = self.report.build_url_fname(newpath, None, self.up)
|
|
|
|
of.write('\t\t\t<a href="%s" alt="%s" />\n' % (url, html_escape(self.page_title)))
|
|
|
|
# TODO. Mixup url and path
|
|
|
|
# path = convert_disk_path_to_url(path)
|
|
|
|
url = self.report.build_url_fname(path, None, self.up)
|
|
|
|
of.write('\t\t\t\t<img src="%s" alt="%s" />\n' % (url, html_escape(self.page_title)))
|
2005-12-06 12:08:09 +05:30
|
|
|
if target_exists:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t</a>\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<span class="MissingImage">(%s)</span>' % _("The file has been moved or deleted"))
|
|
|
|
of.write('\t\t</div>\n\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t<div id="GalleryDisplay">\n')
|
2008-03-21 03:54:36 +05:30
|
|
|
url = self.report.build_url_image('document.png', 'images', self.up)
|
|
|
|
of.write('\t\t\t<img src="%s" alt="%s" />\n' % (url, html_escape(self.page_title)))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</div>\n\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t<h3>%s</h3>\n' % html_escape(self.page_title.strip()))
|
|
|
|
of.write('\t\t<table class="infolist gallery">\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
if not self.noid:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _('GRAMPS ID'))
|
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % photo.gramps_id)
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2008-03-14 03:58:22 +05:30
|
|
|
|
2007-11-03 11:13:12 +05:30
|
|
|
if not note_only and not mime_type.startswith("image/"):
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _('File type'))
|
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % Mime.get_description(mime_type))
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2008-03-14 03:58:22 +05:30
|
|
|
|
2007-03-14 04:30:33 +05:30
|
|
|
date = _dd.display(photo.get_date_object())
|
2008-04-08 01:08:08 +05:30
|
|
|
if date:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _('Date'))
|
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % date)
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2008-03-14 03:58:22 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</table>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
self.display_note_list(of, photo.get_note_list())
|
2007-08-12 08:12:22 +05:30
|
|
|
self.display_attr_list(of, photo.get_attribute_list())
|
2008-03-14 03:58:22 +05:30
|
|
|
self.display_media_sources(of, photo)
|
2008-03-14 04:05:26 +05:30
|
|
|
self.display_references(of, my_media_list)
|
2008-03-14 03:58:22 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-07-04 01:16:50 +05:30
|
|
|
def gallery_nav_link(self, of, handle, name, up=False):
|
|
|
|
url = self.report.build_url_fname_html(handle, 'img', up)
|
2008-04-01 01:20:37 +05:30
|
|
|
of.write('<a id="%s" href="%s">%s</a>' % (html_escape(name), url, html_escape(name)))
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def display_media_sources(self, of, photo):
|
2007-08-23 15:24:37 +05:30
|
|
|
for sref in photo.get_source_references():
|
|
|
|
self.bibli.add_reference(sref)
|
2008-03-14 04:05:26 +05:30
|
|
|
self.display_source_refs(of, self.bibli)
|
2007-08-23 15:24:37 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
def display_attr_list(self, of, attrlist=None):
|
2007-04-05 17:43:33 +05:30
|
|
|
if not attrlist:
|
|
|
|
return
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="attributes">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _('Attributes'))
|
|
|
|
of.write('\t\t<table class="infolist">\n')
|
2007-04-05 17:43:33 +05:30
|
|
|
|
|
|
|
for attr in attrlist:
|
|
|
|
atType = str( attr.get_type() )
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % atType)
|
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % attr.get_value())
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</table>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2007-04-05 17:43:33 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
def copy_source_file(self, handle, photo):
|
2005-12-06 12:08:09 +05:30
|
|
|
ext = os.path.splitext(photo.get_path())[1]
|
2008-03-21 03:54:36 +05:30
|
|
|
to_dir = self.report.build_path('images', handle)
|
|
|
|
newpath = os.path.join(to_dir, handle) + ext
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
|
|
|
fullpath = Utils.media_path_full(db, photo.get_path())
|
2005-12-06 12:08:09 +05:30
|
|
|
try:
|
2008-03-14 03:58:22 +05:30
|
|
|
if self.report.archive:
|
|
|
|
self.report.archive.add(fullpath, str(newpath))
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2008-03-10 01:42:56 +05:30
|
|
|
to_dir = os.path.join(self.html_dir, to_dir)
|
2005-12-06 12:08:09 +05:30
|
|
|
if not os.path.isdir(to_dir):
|
|
|
|
os.makedirs(to_dir)
|
2008-02-18 19:36:41 +05:30
|
|
|
shutil.copyfile(fullpath,
|
2008-02-24 19:25:55 +05:30
|
|
|
os.path.join(self.html_dir, newpath))
|
2005-12-06 12:08:09 +05:30
|
|
|
return newpath
|
2008-03-10 01:42:56 +05:30
|
|
|
except (IOError, OSError), msg:
|
2007-04-09 09:10:11 +05:30
|
|
|
error = _("Missing media object:") + \
|
2008-03-10 01:42:56 +05:30
|
|
|
"%s (%s)" % (photo.get_description(), photo.get_gramps_id())
|
|
|
|
WarningDialog(error, str(msg))
|
2005-12-06 12:08:09 +05:30
|
|
|
return None
|
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
def copy_thumbnail(self, handle, photo):
|
2008-03-21 03:54:36 +05:30
|
|
|
to_dir = self.report.build_path('thumb', handle)
|
|
|
|
to_path = os.path.join(to_dir, handle) + '.png'
|
2005-12-06 12:08:09 +05:30
|
|
|
if photo.get_mime_type():
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
2008-02-18 19:36:41 +05:30
|
|
|
from_path = ThumbNails.get_thumbnail_path(Utils.media_path_full(
|
2008-03-14 03:58:22 +05:30
|
|
|
db,
|
2008-02-18 19:36:41 +05:30
|
|
|
photo.get_path()),
|
|
|
|
photo.get_mime_type())
|
2005-12-06 12:08:09 +05:30
|
|
|
if not os.path.isfile(from_path):
|
2008-03-10 01:42:56 +05:30
|
|
|
from_path = os.path.join(const.IMAGE_DIR, "document.png")
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2008-03-10 01:42:56 +05:30
|
|
|
from_path = os.path.join(const.IMAGE_DIR, "document.png")
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-07-17 17:24:33 +05:30
|
|
|
self.report.copy_file(from_path, to_path)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
class SurnameListPage(BasePage):
|
|
|
|
ORDER_BY_NAME = 0
|
|
|
|
ORDER_BY_COUNT = 1
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title, person_handle_list, order_by=ORDER_BY_NAME, filename="surnames"):
|
|
|
|
BasePage.__init__(self, report, title)
|
|
|
|
db = report.database
|
2005-08-18 11:28:28 +05:30
|
|
|
if order_by == self.ORDER_BY_NAME:
|
2008-03-18 02:39:16 +05:30
|
|
|
of = self.report.create_file(filename)
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, _('Surnames'), content_divid='Surnames')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<h2>%s</h2>\n' % _('Surnames'))
|
2005-08-18 11:28:28 +05:30
|
|
|
else:
|
2008-03-18 02:39:16 +05:30
|
|
|
of = self.report.create_file("surnames_count")
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, _('Surnames by person count'), content_divid='Surnames')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<h2>%s</h2>\n' % _('Surnames by person count'))
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<p id="description">%s</p>\n' % _(
|
2005-08-18 11:28:28 +05:30
|
|
|
'This page contains an index of all the '
|
|
|
|
'surnames in the database. Selecting a link '
|
|
|
|
'will lead to a list of individuals in the '
|
|
|
|
'database with this same surname.'))
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
if order_by == self.ORDER_BY_COUNT:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t<table id="SortByCount" class="infolist surnamelist">\n')
|
|
|
|
of.write('\t<thead>\n')
|
|
|
|
of.write('\t\t<tr>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
else:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t<table id="SortByName" class="infolist surnamelist">\n')
|
|
|
|
of.write('\t<thead>\n')
|
|
|
|
of.write('\t\t<tr>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnLetter">%s</th>\n' % _('Letter'))
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-18 02:39:16 +05:30
|
|
|
fname = self.report.surname_fname + self.ext
|
|
|
|
of.write('\t\t\t<th class="ColumnSurname"><a href="%s">%s</a></th>\n' % (fname, _('Surname')))
|
|
|
|
fname = "surnames_count" + self.ext
|
|
|
|
of.write('\t\t\t<th class="ColumnQuantity"><a href="%s">%s</a></th>\n' % (fname, _('Number of people')))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t</tr>\n')
|
|
|
|
of.write('\t</thead>\n')
|
|
|
|
of.write('\t<tbody>\n')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
person_handle_list = sort_people(db, person_handle_list)
|
2005-08-18 11:28:28 +05:30
|
|
|
if order_by == self.ORDER_BY_COUNT:
|
|
|
|
temp_list = {}
|
2008-03-10 01:42:56 +05:30
|
|
|
for (surname, data_list) in person_handle_list:
|
|
|
|
index_val = "%90d_%s" % (999999999-len(data_list), surname)
|
|
|
|
temp_list[index_val] = (surname, data_list)
|
2005-08-18 11:28:28 +05:30
|
|
|
temp_keys = temp_list.keys()
|
|
|
|
temp_keys.sort()
|
|
|
|
person_handle_list = []
|
|
|
|
for key in temp_keys:
|
|
|
|
person_handle_list.append(temp_list[key])
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2005-02-10 07:14:05 +05:30
|
|
|
last_letter = ''
|
2005-08-18 11:28:28 +05:30
|
|
|
last_surname = ''
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
for (surname, data_list) in person_handle_list:
|
2005-08-18 11:28:28 +05:30
|
|
|
if len(surname) == 0:
|
2005-02-10 07:14:05 +05:30
|
|
|
continue
|
2008-03-08 22:10:19 +05:30
|
|
|
|
|
|
|
# Get a capital normalized version of the first letter of
|
2007-10-04 09:26:41 +05:30
|
|
|
# the surname
|
2008-03-10 01:42:56 +05:30
|
|
|
letter = normalize('NFD', surname)[0].upper()
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2007-10-04 09:26:41 +05:30
|
|
|
if letter != last_letter:
|
|
|
|
last_letter = letter
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t<tr class="BeginLetter">\n')
|
|
|
|
of.write('\t\t\t<td class="ColumnLetter">%s</td>\n' % last_letter)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnSurname">')
|
2008-04-01 01:20:37 +05:30
|
|
|
self.surname_link(of, name_to_md5(surname), surname)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</td>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
elif surname != last_surname:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t<td class="ColumnLetter"> </td>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnSurname">')
|
2008-04-01 01:20:37 +05:30
|
|
|
self.surname_link(of, name_to_md5(surname), surname)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</td>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
last_surname = surname
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnQuantity">%d</td>\n' % len(data_list))
|
|
|
|
of.write('\t\t</tr>\n')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t</tbody>\n')
|
|
|
|
of.write('\t</table>\n')
|
2008-03-14 03:58:22 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-04-01 01:20:37 +05:30
|
|
|
def surname_link(self, of, fname, name, opt_val=None, up=False):
|
|
|
|
url = self.report.build_url_fname_html(fname, 'srn', up)
|
|
|
|
of.write('<a href="%s">%s' % (url, name))
|
2008-06-16 20:31:46 +05:30
|
|
|
if opt_val is not None:
|
2008-04-01 01:20:37 +05:30
|
|
|
of.write(' (%d)' % opt_val)
|
|
|
|
of.write('</a>')
|
|
|
|
|
2005-02-10 07:14:05 +05:30
|
|
|
class IntroductionPage(BasePage):
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title):
|
|
|
|
BasePage.__init__(self, report, title)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = report.database
|
2008-03-18 02:39:16 +05:30
|
|
|
of = self.report.create_file(report.intro_fname)
|
2008-04-01 01:20:37 +05:30
|
|
|
# Note. In old NarrativeWeb.py the content_divid depended on filename.
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, _('Introduction'), content_divid='Introduction')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<h2>%s</h2>\n' % _('Introduction'))
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
report.add_image(of, 'introimg')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
note_id = report.options['intronote']
|
2007-11-27 03:23:58 +05:30
|
|
|
if note_id:
|
2008-02-10 09:39:09 +05:30
|
|
|
note_obj = db.get_note_from_gramps_id(note_id)
|
2008-03-14 02:01:33 +05:30
|
|
|
text = note_obj.get()
|
2007-11-27 03:23:58 +05:30
|
|
|
if note_obj.get_format():
|
2008-05-04 12:35:42 +05:30
|
|
|
of.write(u'\t<pre>%s</pre>\n' % text)
|
2007-11-27 03:23:58 +05:30
|
|
|
else:
|
2008-05-04 12:35:42 +05:30
|
|
|
of.write(u'<br />'.join(text.split("\n")))
|
2005-02-28 05:13:20 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
|
|
|
class HomePage(BasePage):
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title):
|
|
|
|
BasePage.__init__(self, report, title)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = report.database
|
2008-03-18 02:39:16 +05:30
|
|
|
of = self.report.create_file("index")
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, _('Home'), content_divid='Home')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<h2>%s</h2>\n' % _('Home'))
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
report.add_image(of, 'homeimg')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
note_id = report.options['homenote']
|
2007-11-26 00:37:50 +05:30
|
|
|
if note_id:
|
2008-02-10 09:39:09 +05:30
|
|
|
note_obj = db.get_note_from_gramps_id(note_id)
|
2008-03-14 02:01:33 +05:30
|
|
|
text = note_obj.get()
|
2007-11-26 00:37:50 +05:30
|
|
|
if note_obj.get_format():
|
2008-05-04 12:35:42 +05:30
|
|
|
of.write(u'\t<pre>%s</pre>' % text)
|
2007-11-26 00:37:50 +05:30
|
|
|
else:
|
2008-05-04 12:35:42 +05:30
|
|
|
of.write(u'<br />'.join(text.split("\n")))
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
|
|
|
class SourcesPage(BasePage):
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title, handle_set):
|
|
|
|
BasePage.__init__(self, report, title)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = report.database
|
2008-03-18 02:39:16 +05:30
|
|
|
of = self.report.create_file("sources")
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, _('Sources'), content_divid='Sources')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2005-02-16 11:11:33 +05:30
|
|
|
handle_list = list(handle_set)
|
2007-03-07 08:45:45 +05:30
|
|
|
source_dict = {}
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2007-03-07 08:45:45 +05:30
|
|
|
#Sort the sources
|
|
|
|
for handle in handle_list:
|
|
|
|
source = db.get_source_from_handle(handle)
|
|
|
|
key = source.get_title() + str(source.get_gramps_id())
|
|
|
|
source_dict[key] = (source, handle)
|
|
|
|
keys = source_dict.keys()
|
2007-10-04 09:26:41 +05:30
|
|
|
keys.sort(locale.strcoll)
|
2005-02-16 11:11:33 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
msg = _("This page contains an index of all the sources in the "
|
2008-03-06 18:37:37 +05:30
|
|
|
"database, sorted by their title. Clicking on a source’s "
|
|
|
|
"title will take you to that source’s page.")
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t<h2>%s</h2>\n' % _('Sources'))
|
|
|
|
of.write('\t<p id="description">')
|
2005-08-18 11:28:28 +05:30
|
|
|
of.write(msg)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('</p>\n')
|
|
|
|
of.write('\t<table class="infolist sourcelist">\n')
|
|
|
|
of.write('\t<thead>\n')
|
|
|
|
of.write('\t\t<tr>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnLabel"> </th>\n')
|
2008-07-17 17:40:17 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnName">%s</th>\n' % _('Name'))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t</tr>\n')
|
|
|
|
of.write('\t</thead>\n')
|
|
|
|
of.write('\t<tbody>\n')
|
2005-02-16 11:11:33 +05:30
|
|
|
index = 1
|
2007-03-07 08:45:45 +05:30
|
|
|
for key in keys:
|
|
|
|
(source, handle) = source_dict[key]
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t<td class="ColumnRowLabel">%d.</td>\n' % index)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnName"><a ')
|
2008-03-10 01:42:56 +05:30
|
|
|
self.source_link(of, handle, source.get_title(), source.gramps_id)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('</td>\n')
|
|
|
|
of.write('\t\t</tr>\n')
|
2005-07-09 01:54:54 +05:30
|
|
|
index += 1
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t</tbody>\n')
|
|
|
|
of.write('\t</table>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
class SourcePage(BasePage):
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title, handle, src_list):
|
|
|
|
db = report.database
|
2008-05-21 00:54:03 +05:30
|
|
|
source = db.get_source_from_handle(handle)
|
2008-03-14 03:58:22 +05:30
|
|
|
BasePage.__init__(self, report, title, source.gramps_id)
|
2008-03-12 03:41:42 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
of = self.report.create_file(source.get_handle(), 'src')
|
2008-03-12 03:41:42 +05:30
|
|
|
self.up = True
|
2008-03-18 02:39:16 +05:30
|
|
|
self.page_title = source.get_title()
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, "%s - %s" % (_('Sources'), self.page_title), content_divid='SourceDetail')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
media_list = source.get_media_list()
|
2008-03-14 03:58:22 +05:30
|
|
|
self.display_first_image_as_thumbnail(of, media_list)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-12 03:41:42 +05:30
|
|
|
of.write('\t<h2>%s:</h2>\n' % _('Sources'))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<h3>%s</h3>\n\n' % html_escape(self.page_title.strip()))
|
|
|
|
of.write('\t<div id="summaryarea">\n')
|
|
|
|
of.write('\t\t<table class="infolist source">\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2007-03-14 08:45:47 +05:30
|
|
|
grampsid = None
|
|
|
|
if not self.noid:
|
|
|
|
grampsid = source.gramps_id
|
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
for (label, val) in [(_('GRAMPS ID'), grampsid),
|
|
|
|
(_('Author'), source.author),
|
|
|
|
(_('Publication information'), source.pubinfo),
|
|
|
|
(_('Abbreviation'), source.abbrev)]:
|
2005-08-18 11:28:28 +05:30
|
|
|
if val:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % label)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % val)
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t</table>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
self.display_additional_images_as_gallery(of, media_list)
|
|
|
|
self.display_note_list(of, source.get_note_list())
|
|
|
|
self.display_references(of, src_list[source.handle])
|
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
class GalleryPage(BasePage):
|
|
|
|
|
2008-05-21 00:54:03 +05:30
|
|
|
def __init__(self, report, title):
|
2008-03-14 03:58:22 +05:30
|
|
|
BasePage.__init__(self, report, title)
|
|
|
|
|
|
|
|
db = report.database
|
2008-03-18 02:39:16 +05:30
|
|
|
of = self.report.create_file("gallery")
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, _('Gallery'), content_divid='Gallery')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t<h2>%s</h2>\n\n' % _('Gallery'))
|
|
|
|
of.write('\t<p id="description">')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
of.write(_("This page contains an index of all the media objects "
|
|
|
|
"in the database, sorted by their title. Clicking on "
|
2008-03-06 18:37:37 +05:30
|
|
|
"the title will take you to that media object’s page."))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('</p>\n\n')
|
|
|
|
of.write('\t<table class="infolist gallerylist">\n')
|
|
|
|
of.write('\t<thead>\n')
|
|
|
|
of.write('\t\t<tr>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnRowLabel"> </th>\n')
|
2008-07-17 17:40:17 +05:30
|
|
|
of.write('\t\t\t<th class="ColumnName">%s</th>\n' % _('Name'))
|
|
|
|
of.write('\t\t\t<th class="ColumnDate">%s</th>\n' % _('Date'))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t</tr>\n')
|
|
|
|
of.write('\t</thead>\n')
|
|
|
|
of.write('\t<tbody>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
index = 1
|
2008-03-14 03:58:22 +05:30
|
|
|
mlist = self.report.photo_list.keys()
|
|
|
|
sort = Sort.Sort(db)
|
2007-10-12 17:46:49 +05:30
|
|
|
mlist.sort(sort.by_media_title)
|
2005-08-18 11:28:28 +05:30
|
|
|
for handle in mlist:
|
|
|
|
media = db.get_object_from_handle(handle)
|
2007-03-14 04:30:33 +05:30
|
|
|
date = _dd.display(media.get_date_object())
|
2007-04-09 09:10:11 +05:30
|
|
|
title = media.get_description()
|
|
|
|
if title == "":
|
|
|
|
title = "untitled"
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t<tr>\n')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnRowLabel">%d.</td>\n' % index)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnName">')
|
2008-03-10 01:42:56 +05:30
|
|
|
self.media_ref_link(of, handle, title)
|
2007-03-14 04:30:33 +05:30
|
|
|
of.write('</td>\n')
|
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<td class="ColumnDate">%s</td>\n' % date)
|
2007-03-14 04:30:33 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</tr>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
index += 1
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t</tbody>\n')
|
|
|
|
of.write('\t</table>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-04-01 01:20:37 +05:30
|
|
|
def media_ref_link(self, of, handle, name, up=False):
|
2008-07-04 00:40:05 +05:30
|
|
|
url = self.report.build_url_fname_html(handle, 'img', up)
|
2008-04-01 01:20:37 +05:30
|
|
|
of.write('<a href="%s">%s</a>' % (url, html_escape(name)))
|
|
|
|
|
2005-02-10 07:14:05 +05:30
|
|
|
class DownloadPage(BasePage):
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title):
|
|
|
|
BasePage.__init__(self, report, title)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-18 02:39:16 +05:30
|
|
|
of = self.report.create_file("download")
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, _('Download'), content_divid='Download')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-07-01 14:04:08 +05:30
|
|
|
of.write('\t<h2>%s</h2>\n\n' % _('Download'))
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
|
|
|
class ContactPage(BasePage):
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title):
|
|
|
|
BasePage.__init__(self, report, title)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = report.database
|
2008-03-18 02:39:16 +05:30
|
|
|
of = self.report.create_file("contact")
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, _('Contact'), content_divid='Contact')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<h2>%s</h2>\n\n' % _('Contact'))
|
|
|
|
of.write('\t<div id="summaryarea">\n')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
report.add_image(of, 'contactimg', 200)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
r = get_researcher()
|
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t<div id="researcher">\n')
|
2005-12-06 12:08:09 +05:30
|
|
|
if r.name:
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('\t\t\t<h3>%s</h3>\n' % r.name.replace(',,,', ''))
|
2005-12-06 12:08:09 +05:30
|
|
|
if r.addr:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<span id="streetaddress">%s</span>\n' % r.addr)
|
2008-03-10 01:42:56 +05:30
|
|
|
text = "".join([r.city, r.state, r.postal])
|
2005-12-06 12:08:09 +05:30
|
|
|
if text:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<span id="city">%s</span>\n' % r.city)
|
|
|
|
of.write('\t\t\t<span id="state">%s</span>\n' % r.state)
|
|
|
|
of.write('\t\t\t<span id="postalcode">%s</span>\n' % r.postal)
|
2005-12-06 12:08:09 +05:30
|
|
|
if r.country:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<span id="country">%s</span>\n' % r.country)
|
2005-12-06 12:08:09 +05:30
|
|
|
if r.email:
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('\t\t\t<span id="email"><a href="mailto:%s?subject=from GRAMPS Web Site">%s</a></span>\n' % (r.email, r.email))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</div>\n')
|
|
|
|
of.write('\t\t<div class="fullclear"></div>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
note_id = report.options['contactnote']
|
2007-11-27 03:23:58 +05:30
|
|
|
if note_id:
|
2008-02-10 09:39:09 +05:30
|
|
|
note_obj = db.get_note_from_gramps_id(note_id)
|
2008-03-14 02:01:33 +05:30
|
|
|
text = note_obj.get()
|
2007-11-27 03:23:58 +05:30
|
|
|
if note_obj.get_format():
|
2008-03-06 18:37:37 +05:30
|
|
|
text = u"\t\t<pre>%s</pre>" % text
|
2007-11-27 03:23:58 +05:30
|
|
|
else:
|
2008-03-06 18:37:37 +05:30
|
|
|
text = u"<br />".join(text.split("\n"))
|
|
|
|
of.write('\t\t<p>%s</p>\n' % text)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t</div>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
|
|
|
class IndividualPage(BasePage):
|
2008-03-10 01:42:56 +05:30
|
|
|
"""
|
|
|
|
This class is used to write HTML for an individual.
|
|
|
|
"""
|
2005-02-01 09:16:29 +05:30
|
|
|
|
|
|
|
gender_map = {
|
2007-10-08 22:11:39 +05:30
|
|
|
gen.lib.Person.MALE : _('male'),
|
|
|
|
gen.lib.Person.FEMALE : _('female'),
|
|
|
|
gen.lib.Person.UNKNOWN : _('unknown'),
|
2005-02-01 09:16:29 +05:30
|
|
|
}
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def __init__(self, report, title, person, ind_list, place_list, src_list):
|
|
|
|
BasePage.__init__(self, report, title, person.gramps_id)
|
2005-02-01 09:16:29 +05:30
|
|
|
self.person = person
|
|
|
|
self.ind_list = ind_list
|
2008-03-14 03:58:22 +05:30
|
|
|
self.src_list = src_list # Used by get_citation_links()
|
2007-07-23 17:52:03 +05:30
|
|
|
self.bibli = Bibliography()
|
2005-02-16 11:11:33 +05:30
|
|
|
self.place_list = place_list
|
2007-08-12 08:12:22 +05:30
|
|
|
self.sort_name = _nd.sorted(self.person)
|
|
|
|
self.name = _nd.sorted(self.person)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = report.database
|
2008-03-21 03:54:36 +05:30
|
|
|
of = self.report.create_file(person.handle, 'ppl')
|
2008-03-12 03:41:42 +05:30
|
|
|
self.up = True
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_header(of, self.sort_name, content_divid='IndividualDetail')
|
2008-03-12 03:41:42 +05:30
|
|
|
|
2005-02-21 04:57:55 +05:30
|
|
|
self.display_ind_general(of)
|
|
|
|
self.display_ind_events(of)
|
2005-08-18 11:28:28 +05:30
|
|
|
self.display_attr_list(of, self.person.get_attribute_list())
|
|
|
|
self.display_ind_parents(of)
|
2005-02-21 04:57:55 +05:30
|
|
|
self.display_ind_relationships(of)
|
2007-01-18 10:01:08 +05:30
|
|
|
self.display_addresses(of)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2007-08-27 01:49:18 +05:30
|
|
|
media_list = []
|
2008-03-14 03:58:22 +05:30
|
|
|
photo_list = self.person.get_media_list()
|
|
|
|
if len(photo_list) > 1:
|
|
|
|
media_list = photo_list[1:]
|
2007-08-27 01:49:18 +05:30
|
|
|
for handle in self.person.get_family_handle_list():
|
2008-03-14 03:58:22 +05:30
|
|
|
family = db.get_family_from_handle(handle)
|
2007-08-27 01:49:18 +05:30
|
|
|
media_list += family.get_media_list()
|
|
|
|
for evt_ref in family.get_event_ref_list():
|
2008-03-14 03:58:22 +05:30
|
|
|
event = db.get_event_from_handle(evt_ref.ref)
|
2008-01-06 01:40:26 +05:30
|
|
|
media_list += event.get_media_list()
|
2007-08-27 01:49:18 +05:30
|
|
|
for evt_ref in self.person.get_primary_event_ref_list():
|
2008-03-14 03:58:22 +05:30
|
|
|
event = db.get_event_from_handle(evt_ref.ref)
|
2007-08-27 01:49:18 +05:30
|
|
|
if event:
|
|
|
|
media_list += event.get_media_list()
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
self.display_additional_images_as_gallery(of, media_list)
|
|
|
|
self.display_note_list(of, self.person.get_note_list())
|
2007-08-27 01:49:18 +05:30
|
|
|
self.display_url_list(of, self.person.get_url_list())
|
|
|
|
self.display_ind_sources(of)
|
2005-02-21 04:57:55 +05:30
|
|
|
self.display_ind_pedigree(of)
|
2008-03-21 03:54:36 +05:30
|
|
|
if report.options['graph']:
|
2005-12-06 12:08:09 +05:30
|
|
|
self.display_tree(of)
|
2008-03-14 03:58:22 +05:30
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.write_footer(of)
|
2008-03-18 02:39:16 +05:30
|
|
|
self.report.close_file(of)
|
2005-02-21 04:57:55 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
def display_attr_list(self, of, attrlist=None):
|
2007-04-05 17:43:33 +05:30
|
|
|
if not attrlist:
|
|
|
|
return
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="attributes" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _('Attributes'))
|
|
|
|
of.write('\t\t<table class="infolist">\n')
|
2007-04-05 17:43:33 +05:30
|
|
|
|
|
|
|
for attr in attrlist:
|
|
|
|
atType = str( attr.get_type() )
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % atType)
|
2007-04-05 17:43:33 +05:30
|
|
|
value = attr.get_value()
|
|
|
|
value += self.get_citation_links( attr.get_source_references() )
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % value)
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</table>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2007-04-05 17:43:33 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
def draw_box(self, of, center, col, person):
|
2008-02-10 09:39:09 +05:30
|
|
|
top = center - _HEIGHT/2
|
|
|
|
xoff = _XOFFSET+col*(_WIDTH+_HGAP)
|
2008-07-16 13:29:29 +05:30
|
|
|
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))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<div class="box">')
|
2008-03-10 01:42:56 +05:30
|
|
|
if person.handle in self.ind_list:
|
2007-08-12 08:12:22 +05:30
|
|
|
person_name = _nd.display(person)
|
2008-03-21 03:54:36 +05:30
|
|
|
url = self.report.build_url_fname_html(person.handle, 'ppl', True)
|
|
|
|
self.person_link(of, url, person_name)
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
2007-08-12 08:12:22 +05:30
|
|
|
of.write(_nd.display(person))
|
2005-12-06 12:08:09 +05:30
|
|
|
of.write('</div>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t</div>\n')
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('\t\t\t<div class="shadow" style="top: %dpx; left: %dpx;"></div>\n' % (top+_SHADOW, xoff+_SHADOW))
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
def extend_line(self, of, y0, x0):
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<div class="bvline" style="top: %dpx; left: %dpx; width: %dpx;"></div>\n' %
|
2008-03-10 01:42:56 +05:30
|
|
|
(y0, x0, _HGAP/2))
|
2008-03-08 22:10:19 +05:30
|
|
|
of.write('\t\t\t<div class="gvline" style="top: %dpx; left: %dpx; width: %dpx;"></div>\n' %
|
2008-03-10 01:42:56 +05:30
|
|
|
(y0+_SHADOW, x0, _HGAP/2+_SHADOW))
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
def connect_line(self, of, y0, y1, col):
|
2005-12-06 12:08:09 +05:30
|
|
|
if y0 < y1:
|
|
|
|
y = y0
|
|
|
|
else:
|
|
|
|
y = y1
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
x0 = _XOFFSET + col * _WIDTH + (col-1)*_HGAP + _HGAP/2
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<div class="bvline" style="top: %dpx; left: %dpx; width: %dpx;"></div>\n' %
|
2008-03-10 01:42:56 +05:30
|
|
|
(y1, x0, _HGAP/2))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<div class="gvline" style="top: %dpx; left: %dpx; width: %dpx;"></div>\n' %
|
2008-03-10 01:42:56 +05:30
|
|
|
(y1+_SHADOW, x0+_SHADOW, _HGAP/2+_SHADOW))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<div class="bhline" style="top: %dpx; left: %dpx; height: %dpx;"></div>\n' %
|
2008-03-10 01:42:56 +05:30
|
|
|
(y, x0, abs(y0-y1)))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<div class="ghline" style="top: %dpx; left: %dpx; height: %dpx;"></div>\n' %
|
2008-03-10 01:42:56 +05:30
|
|
|
(y+_SHADOW, x0+_SHADOW, abs(y0-y1)))
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
def draw_connected_box(self, of, center1, center2, col, handle):
|
2005-12-06 12:08:09 +05:30
|
|
|
if not handle:
|
|
|
|
return None
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
|
|
|
person = db.get_person_from_handle(handle)
|
2008-03-10 01:42:56 +05:30
|
|
|
self.draw_box(of, center2, col, person)
|
|
|
|
self.connect_line(of, center1, center2, col)
|
2005-12-06 12:08:09 +05:30
|
|
|
return person
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def display_tree(self, of):
|
2006-05-14 11:21:46 +05:30
|
|
|
if not self.person.get_main_parents_family_handle():
|
2005-12-06 12:08:09 +05:30
|
|
|
return
|
|
|
|
|
2008-03-18 02:39:16 +05:30
|
|
|
generations = self.report.options['graphgens']
|
2008-03-10 01:42:56 +05:30
|
|
|
max_in_col = 1 << (generations-1)
|
2008-02-10 09:39:09 +05:30
|
|
|
max_size = _HEIGHT*max_in_col + _VGAP*(max_in_col+1)
|
2006-05-14 11:21:46 +05:30
|
|
|
center = int(max_size/2)
|
2008-03-06 18:37:37 +05:30
|
|
|
|
|
|
|
of.write('\t<div id="tree" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _('Ancestors'))
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('\t\t<div id="treeContainer" style="width:%dpx; height:%dpx;">\n' % (_XOFFSET+(generations)*_WIDTH+(generations-1)*_HGAP, max_size))
|
2008-03-06 18:37:37 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
self.draw_tree(of, 1, generations, max_size, 0, center, self.person.handle)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</div>\n')
|
|
|
|
of.write('\t</div>\n')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-15 02:37:35 +05:30
|
|
|
def draw_tree(self, of, gen_nr, maxgen, max_size, old_center, new_center, phandle):
|
|
|
|
if gen_nr > maxgen:
|
2006-05-14 11:21:46 +05:30
|
|
|
return
|
2008-03-15 02:37:35 +05:30
|
|
|
gen_offset = int(max_size / pow(2, gen_nr+1))
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
|
|
|
person = db.get_person_from_handle(phandle)
|
2006-05-14 11:21:46 +05:30
|
|
|
if not person:
|
|
|
|
return
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-15 02:37:35 +05:30
|
|
|
if gen_nr == 1:
|
2008-03-10 01:42:56 +05:30
|
|
|
self.draw_box(of, new_center, 0, person)
|
2006-05-14 11:21:46 +05:30
|
|
|
else:
|
2008-03-15 02:37:35 +05:30
|
|
|
self.draw_connected_box(of, old_center, new_center, gen_nr-1, phandle)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-15 02:37:35 +05:30
|
|
|
if gen_nr == maxgen:
|
2006-05-14 11:21:46 +05:30
|
|
|
return
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2006-05-14 11:21:46 +05:30
|
|
|
family_handle = person.get_main_parents_family_handle()
|
|
|
|
if family_handle:
|
2008-03-15 02:37:35 +05:30
|
|
|
line_offset = _XOFFSET + gen_nr*_WIDTH + (gen_nr-1)*_HGAP
|
2008-03-10 01:42:56 +05:30
|
|
|
self.extend_line(of, new_center, line_offset)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
family = db.get_family_from_handle(family_handle)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2006-05-14 11:21:46 +05:30
|
|
|
f_center = new_center-gen_offset
|
|
|
|
f_handle = family.get_father_handle()
|
2008-03-21 03:54:36 +05:30
|
|
|
self.draw_tree(of, gen_nr+1, maxgen, max_size, new_center, f_center, f_handle)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2006-05-14 11:21:46 +05:30
|
|
|
m_center = new_center+gen_offset
|
|
|
|
m_handle = family.get_mother_handle()
|
2008-03-21 03:54:36 +05:30
|
|
|
self.draw_tree(of, gen_nr+1, maxgen, max_size, new_center, m_center, m_handle)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def display_ind_sources(self, of):
|
2007-07-23 17:52:03 +05:30
|
|
|
for sref in self.person.get_source_references():
|
|
|
|
self.bibli.add_reference(sref)
|
2008-03-14 04:05:26 +05:30
|
|
|
self.display_source_refs(of, self.bibli)
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def display_ind_pedigree(self, of):
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
2005-02-04 09:24:48 +05:30
|
|
|
parent_handle_list = self.person.get_parent_family_handle_list()
|
|
|
|
if parent_handle_list:
|
2006-04-23 08:28:53 +05:30
|
|
|
parent_handle = parent_handle_list[0]
|
2008-03-14 03:58:22 +05:30
|
|
|
family = db.get_family_from_handle(parent_handle)
|
2005-02-04 09:24:48 +05:30
|
|
|
father_id = family.get_father_handle()
|
|
|
|
mother_id = family.get_mother_handle()
|
2008-03-14 03:58:22 +05:30
|
|
|
mother = db.get_person_from_handle(mother_id)
|
|
|
|
father = db.get_person_from_handle(father_id)
|
2005-02-04 09:24:48 +05:30
|
|
|
else:
|
|
|
|
family = None
|
|
|
|
father = None
|
|
|
|
mother = None
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="pedigree" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _('Pedigree'))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t<ol class="pedigreegen">\n')
|
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
if father and mother:
|
2008-04-08 01:08:08 +05:30
|
|
|
of.write('\t\t\t<li>')
|
2008-03-10 01:42:56 +05:30
|
|
|
self.pedigree_person(of, father)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\n')
|
|
|
|
of.write('\t\t\t\t<ol>\n')
|
|
|
|
of.write('\t\t\t\t\t')
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('<li class="spouse">')
|
|
|
|
self.pedigree_person(of, mother)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\n')
|
|
|
|
of.write('\t\t\t\t\t\t<ol>\n')
|
|
|
|
elif father:
|
2008-04-08 01:08:08 +05:30
|
|
|
of.write('\t\t\t<li>')
|
2008-03-10 01:42:56 +05:30
|
|
|
self.pedigree_person(of, father)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\n')
|
|
|
|
of.write('\t\t\t\t<ol>\n')
|
|
|
|
elif mother:
|
2008-04-08 01:08:08 +05:30
|
|
|
of.write('\t\t\t<li class="spouse">')
|
2008-03-10 01:42:56 +05:30
|
|
|
self.pedigree_person(of, mother)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\n')
|
|
|
|
of.write('\t\t\t\t<ol>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
|
2005-02-04 09:24:48 +05:30
|
|
|
if family:
|
2007-08-12 08:12:22 +05:30
|
|
|
for child_ref in family.get_child_ref_list():
|
2006-04-23 08:28:53 +05:30
|
|
|
child_handle = child_ref.ref
|
2005-02-04 09:24:48 +05:30
|
|
|
if child_handle == self.person.handle:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t\t\t\t<li class="thisperson">%s\n' % self.name)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t\t\t\t\t<ol class="spouselist">\n')
|
|
|
|
of.write('\t\t\t\t\t\t\t\t\t')
|
2005-02-21 04:57:55 +05:30
|
|
|
self.pedigree_family(of)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t\t\t\t\t</ol>\n')
|
|
|
|
of.write('\t\t\t\t\t\t\t</li>\n')
|
2005-02-04 09:24:48 +05:30
|
|
|
else:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t\t\t\t')
|
2008-03-14 03:58:22 +05:30
|
|
|
child = db.get_person_from_handle(child_handle)
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('<li>')
|
|
|
|
self.pedigree_person(of, child)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</li>\n')
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t\t\t</ol>\n')
|
|
|
|
of.write('\t\t\t\t\t</li>\n')
|
2005-02-04 09:24:48 +05:30
|
|
|
else:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('<li class="thisperson">%s\n' % self.name)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t<ol class="spouselist">\n')
|
|
|
|
of.write('\t\t\t\t\t\t')
|
2005-02-21 04:57:55 +05:30
|
|
|
self.pedigree_family(of)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t</ol>\n')
|
2008-04-08 01:08:08 +05:30
|
|
|
if father or mother:
|
|
|
|
of.write('\t\t\t</li>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</ol>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def display_ind_general(self, of):
|
2005-08-18 11:28:28 +05:30
|
|
|
self.page_title = self.sort_name
|
2008-04-01 01:20:37 +05:30
|
|
|
self.display_first_image_as_thumbnail(of, self.person.get_media_list())
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2008-07-17 17:40:17 +05:30
|
|
|
of.write('\t<h2>%s:</h2>\n' % _('Individuals'))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<h3>%s</h3>\n' % self.sort_name.strip())
|
|
|
|
of.write('\t<div id="summaryarea">\n')
|
|
|
|
of.write('\t\t<table class="infolist">\n')
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
# GRAMPS ID
|
|
|
|
if not self.noid:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _('GRAMPS ID'))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % self.person.gramps_id)
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
# Names [and their sources]
|
2008-03-10 01:42:56 +05:30
|
|
|
for name in [self.person.get_primary_name()] + self.person.get_alternate_names():
|
2007-08-12 08:12:22 +05:30
|
|
|
pname = _nd.display_name(name)
|
2007-07-23 17:52:03 +05:30
|
|
|
pname += self.get_citation_links( name.get_source_references() )
|
2008-03-15 02:37:35 +05:30
|
|
|
type_ = str( name.get_type() )
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
2008-03-15 02:37:35 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % type_)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s' % pname)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('</td>\n')
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2006-03-01 01:24:35 +05:30
|
|
|
# Gender
|
|
|
|
nick = self.person.get_nick_name()
|
|
|
|
if nick:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _('Nickname'))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % nick)
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2006-03-01 01:24:35 +05:30
|
|
|
|
2005-02-01 09:16:29 +05:30
|
|
|
# Gender
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _('Gender'))
|
2005-02-04 09:24:48 +05:30
|
|
|
gender = self.gender_map[self.person.gender]
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % gender)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t</tr>\n')
|
|
|
|
of.write('\t\t</table>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def display_ind_events(self, of):
|
2007-10-16 17:39:20 +05:30
|
|
|
evt_ref_list = self.person.get_event_ref_list()
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2007-03-07 08:45:45 +05:30
|
|
|
if not evt_ref_list:
|
2006-03-31 11:07:41 +05:30
|
|
|
return
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-05-21 00:54:03 +05:30
|
|
|
db = self.report.database
|
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="events" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _('Events'))
|
|
|
|
of.write('\t\t<table class="infolist">\n')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-05-21 00:54:03 +05:30
|
|
|
# table head
|
|
|
|
of.write('\t\t\t<thead>\n')
|
|
|
|
for h in (_('event|Type'), _('Date'), _('Place'), _('Description'), _('Notes')):
|
|
|
|
of.write('\t\t\t\t<th>%s</th>' % h)
|
|
|
|
of.write('\t\t\t</thead>\n')
|
|
|
|
of.write('\t\t\t<tbody>\n')
|
|
|
|
|
2006-03-31 11:07:41 +05:30
|
|
|
for event_ref in evt_ref_list:
|
2008-03-14 03:58:22 +05:30
|
|
|
event = db.get_event_from_handle(event_ref.ref)
|
2007-03-07 08:45:45 +05:30
|
|
|
if event:
|
2008-05-21 01:15:29 +05:30
|
|
|
self.display_event_row(of, db, event, event_ref)
|
2007-10-16 17:39:20 +05:30
|
|
|
|
2008-05-21 00:54:03 +05:30
|
|
|
of.write('\t\t\t</tbody>\n')
|
|
|
|
of.write('\t\t\t<tfoot />\n')
|
2007-10-16 17:39:20 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</table>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-05-21 01:15:29 +05:30
|
|
|
def display_event_row(self, of, db, event, event_ref):
|
2008-05-21 00:54:03 +05:30
|
|
|
evt_name = str(event.get_type())
|
|
|
|
|
|
|
|
of.write('\t\t\t\t<tr>\n')
|
|
|
|
|
|
|
|
# Type
|
|
|
|
if event_ref.get_role() == EventRoleType.PRIMARY:
|
|
|
|
txt = u"%(evt_name)s" % locals()
|
|
|
|
else:
|
2008-06-19 20:11:04 +05:30
|
|
|
evt_role = event_ref.get_role()
|
2008-05-21 00:54:03 +05:30
|
|
|
txt = u"%(evt_name)s (%(evt_role)s)" % locals()
|
|
|
|
txt = txt or ' '
|
|
|
|
of.write('\t\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % txt)
|
|
|
|
|
|
|
|
# Date
|
|
|
|
txt = _dd.display(event.get_date_object())
|
|
|
|
txt = txt or ' '
|
|
|
|
of.write('\t\t\t\t\t<td class="ColumnValue Date">%s</td>\n' % txt)
|
|
|
|
|
|
|
|
# Place
|
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
# TODO. Figure out what this is for.
|
2008-07-17 23:40:32 +05:30
|
|
|
#if place_handle in self.place_list:
|
2008-05-21 00:54:03 +05:30
|
|
|
# if lnk not in self.place_list[place_handle]:
|
|
|
|
# self.place_list[place_handle].append(lnk)
|
|
|
|
#else:
|
|
|
|
# self.place_list[place_handle] = [lnk]
|
|
|
|
|
|
|
|
place = self.place_link_str(place_handle,
|
|
|
|
ReportUtils.place_name(self.report.database, place_handle),
|
|
|
|
up=True)
|
|
|
|
else:
|
|
|
|
place = None
|
|
|
|
txt = place or ' '
|
|
|
|
of.write('\t\t\t\t\t<td class="ColumnValue Place">%s</td>\n' % txt)
|
|
|
|
|
|
|
|
# Description
|
|
|
|
txt = event.get_description()
|
|
|
|
txt = txt or ' '
|
|
|
|
of.write('\t\t\t\t\t<td class="ColumnValue Description">%s</td>\n' % txt)
|
|
|
|
|
|
|
|
# Attributes
|
|
|
|
# TODO. See format_event
|
|
|
|
|
|
|
|
# Notes. Deal with list of notes.
|
|
|
|
of.write('\t\t\t\t\t<td class="ColumnValue Notes">\n')
|
|
|
|
done_first_note = False
|
|
|
|
notelist = event.get_note_list()
|
|
|
|
notelist.extend(event_ref.get_note_list())
|
|
|
|
for notehandle in notelist:
|
|
|
|
note = db.get_note_from_handle(notehandle)
|
|
|
|
if note:
|
|
|
|
note_text = note.get()
|
|
|
|
if note_text:
|
|
|
|
if note.get_format():
|
|
|
|
txt = u"<pre>%s</pre>" % note_text
|
|
|
|
else:
|
|
|
|
# TODO. Decide what to do with multiline notes.
|
|
|
|
txt = u" ".join(note_text.split("\n"))
|
|
|
|
if not done_first_note:
|
|
|
|
of.write('\t\t\t\t\t\t<ol>\n')
|
|
|
|
txt = txt or ' '
|
|
|
|
of.write('\t\t\t\t\t\t\t<li>%s</li>\n' % txt)
|
|
|
|
if done_first_note:
|
|
|
|
of.write('\t\t\t\t\t\t</ol>\n')
|
|
|
|
of.write('\t\t\t\t\t</td>\n')
|
|
|
|
|
|
|
|
of.write('\t\t\t\t</tr>\n')
|
|
|
|
|
2008-03-08 22:10:19 +05:30
|
|
|
def display_addresses(self, of):
|
2007-01-18 10:01:08 +05:30
|
|
|
alist = self.person.get_address_list()
|
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
if not alist:
|
2007-01-18 10:01:08 +05:30
|
|
|
return
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="addresses" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _('Addresses'))
|
|
|
|
of.write('\t\t<table class="infolist">\n')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2007-01-18 10:01:08 +05:30
|
|
|
for addr in alist:
|
2007-01-23 07:21:33 +05:30
|
|
|
location = ReportUtils.get_address_str(addr)
|
2007-01-18 10:01:08 +05:30
|
|
|
location += self.get_citation_links( addr.get_source_references() )
|
|
|
|
date = _dd.display(addr.get_date_object())
|
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % date)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % location)
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2007-01-18 10:01:08 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</table>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
def display_child_link(self, of, child_handle):
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
|
|
|
child = db.get_person_from_handle(child_handle)
|
2005-08-18 11:28:28 +05:30
|
|
|
gid = child.get_gramps_id()
|
2008-04-08 01:08:08 +05:30
|
|
|
of.write("\t\t\t\t\t\t<li>")
|
2008-03-10 01:42:56 +05:30
|
|
|
if child_handle in self.ind_list:
|
2007-08-12 08:12:22 +05:30
|
|
|
child_name = _nd.display(child)
|
2008-03-21 03:54:36 +05:30
|
|
|
url = self.report.build_url_fname_html(child_handle, 'ppl', True)
|
|
|
|
self.person_link(of, url, child_name, gid)
|
2005-08-18 11:28:28 +05:30
|
|
|
else:
|
2007-08-12 08:12:22 +05:30
|
|
|
of.write(_nd.display(child))
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write(u"</li>\n")
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
def display_parent(self, of, handle, title, rel):
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
|
|
|
person = db.get_person_from_handle(handle)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % title)
|
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">')
|
2008-03-12 02:49:36 +05:30
|
|
|
gid = person.gramps_id
|
2008-03-10 01:42:56 +05:30
|
|
|
if handle in self.ind_list:
|
2008-03-21 03:54:36 +05:30
|
|
|
url = self.report.build_url_fname_html(handle, 'ppl', True)
|
|
|
|
self.person_link(of, url, _nd.display(person), gid)
|
2005-08-18 11:28:28 +05:30
|
|
|
else:
|
2007-08-12 08:12:22 +05:30
|
|
|
of.write(_nd.display(person))
|
2008-06-18 10:36:25 +05:30
|
|
|
if rel and rel != gen.lib.ChildRefType(gen.lib.ChildRefType.BIRTH):
|
2006-04-23 08:28:53 +05:30
|
|
|
of.write(' (%s)' % str(rel))
|
2005-02-21 04:57:55 +05:30
|
|
|
of.write('</td>\n')
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def display_ind_parents(self, of):
|
2005-02-04 09:24:48 +05:30
|
|
|
parent_list = self.person.get_parent_family_handle_list()
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
if not parent_list:
|
2005-02-01 09:16:29 +05:30
|
|
|
return
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="parents" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _("Parents"))
|
|
|
|
of.write('\t\t<table class="infolist">\n')
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
2005-08-18 11:28:28 +05:30
|
|
|
first = True
|
2005-02-01 09:16:29 +05:30
|
|
|
if parent_list:
|
2006-04-23 08:28:53 +05:30
|
|
|
for family_handle in parent_list:
|
2008-03-14 03:58:22 +05:30
|
|
|
family = db.get_family_from_handle(family_handle)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2006-04-23 08:28:53 +05:30
|
|
|
# Get the mother and father relationships
|
2008-05-12 00:55:39 +05:30
|
|
|
frel = None
|
|
|
|
mrel = None
|
2007-07-19 12:15:25 +05:30
|
|
|
sibling = set()
|
2006-04-23 08:28:53 +05:30
|
|
|
child_handle = self.person.get_handle()
|
2007-08-12 08:12:22 +05:30
|
|
|
child_ref_list = family.get_child_ref_list()
|
2006-04-23 08:28:53 +05:30
|
|
|
for child_ref in child_ref_list:
|
|
|
|
if child_ref.ref == child_handle:
|
2008-05-12 00:55:39 +05:30
|
|
|
frel = child_ref.get_father_relation()
|
|
|
|
mrel = child_ref.get_mother_relation()
|
2008-06-18 10:36:25 +05:30
|
|
|
break
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
if not first:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td colspan="2"> </td>\n')
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
else:
|
|
|
|
first = False
|
2005-02-01 09:16:29 +05:30
|
|
|
|
|
|
|
father_handle = family.get_father_handle()
|
|
|
|
if father_handle:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
2008-03-10 01:42:56 +05:30
|
|
|
self.display_parent(of, father_handle, _('Father'), frel)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t</tr>\n')
|
2005-02-01 09:16:29 +05:30
|
|
|
mother_handle = family.get_mother_handle()
|
|
|
|
if mother_handle:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
2008-03-10 01:42:56 +05:30
|
|
|
self.display_parent(of, mother_handle, _('Mother'), mrel)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t</tr>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
2005-02-04 19:24:02 +05:30
|
|
|
first = False
|
2007-04-16 00:42:57 +05:30
|
|
|
if len(child_ref_list) > 1:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _("Siblings"))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">\n')
|
|
|
|
of.write('\t\t\t\t\t<ol>\n')
|
2008-04-08 01:08:08 +05:30
|
|
|
childlist = [child_ref.ref for child_ref in child_ref_list]
|
|
|
|
for child_handle in childlist:
|
2007-07-19 12:15:25 +05:30
|
|
|
sibling.add(child_handle) # remember that we've already "seen" this child
|
2005-08-18 11:28:28 +05:30
|
|
|
if child_handle != self.person.handle:
|
2008-03-10 01:42:56 +05:30
|
|
|
self.display_child_link(of, child_handle)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t\t</ol>\n')
|
|
|
|
of.write('\t\t\t\t</td>\n')
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# Also try to identify half-siblings
|
2008-07-06 14:10:47 +05:30
|
|
|
half_siblings = set()
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# if we have a known father...
|
2008-07-06 14:10:47 +05:30
|
|
|
showallsiblings = self.report.options['showhalfsiblings']
|
|
|
|
if father_handle and showallsiblings:
|
2007-07-19 12:15:25 +05:30
|
|
|
# 1) get all of the families in which this father is involved
|
|
|
|
# 2) get all of the children from those families
|
|
|
|
# 3) if the children are not already listed as siblings...
|
|
|
|
# 4) then remember those children since we're going to list them
|
2008-03-14 03:58:22 +05:30
|
|
|
father = db.get_person_from_handle(father_handle)
|
2007-07-19 12:15:25 +05:30
|
|
|
for family_handle in father.get_family_handle_list():
|
2008-03-14 03:58:22 +05:30
|
|
|
family = db.get_family_from_handle(family_handle)
|
2008-07-06 14:10:47 +05:30
|
|
|
for half_child_ref in family.get_child_ref_list():
|
|
|
|
half_child_handle = half_child_ref.ref
|
|
|
|
if half_child_handle not in sibling:
|
|
|
|
if half_child_handle != self.person.handle:
|
2007-07-19 12:15:25 +05:30
|
|
|
# we have a new step/half sibling
|
2008-07-06 14:10:47 +05:30
|
|
|
half_siblings.add(half_child_handle)
|
2007-07-19 12:15:25 +05:30
|
|
|
|
|
|
|
# do the same thing with the mother (see "father" just above):
|
2008-07-06 14:10:47 +05:30
|
|
|
if mother_handle and showallsiblings:
|
2008-03-14 03:58:22 +05:30
|
|
|
mother = db.get_person_from_handle(mother_handle)
|
2007-07-19 12:15:25 +05:30
|
|
|
for family_handle in mother.get_family_handle_list():
|
2008-03-14 03:58:22 +05:30
|
|
|
family = db.get_family_from_handle(family_handle)
|
2008-07-06 14:10:47 +05:30
|
|
|
for half_child_ref in family.get_child_ref_list():
|
|
|
|
half_child_handle = half_child_ref.ref
|
|
|
|
if half_child_handle not in sibling:
|
|
|
|
if half_child_handle != self.person.handle:
|
|
|
|
# we have a new half sibling
|
|
|
|
half_siblings.add(half_child_handle)
|
|
|
|
|
|
|
|
# now that we have all of the half-siblings, print them out
|
|
|
|
if len(half_siblings) > 0:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _("Half Siblings"))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">\n')
|
|
|
|
of.write('\t\t\t\t\t<ol>\n')
|
2008-07-06 14:10:47 +05:30
|
|
|
for child_handle in half_siblings:
|
|
|
|
self.display_child_link(of, child_handle)
|
|
|
|
of.write('\t\t\t\t\t</ol>\n')
|
|
|
|
of.write('\t\t\t\t</td>\n')
|
|
|
|
of.write('\t\t\t</tr>\n')
|
|
|
|
|
|
|
|
# get step-siblings
|
|
|
|
step_siblings = set()
|
|
|
|
if showallsiblings:
|
|
|
|
|
|
|
|
# to find the step-siblings, we need to identify
|
|
|
|
# all of the families that can be linked back to
|
|
|
|
# the current person, and then extract the children
|
|
|
|
# from those families
|
|
|
|
all_family_handles = set()
|
|
|
|
all_parent_handles = set()
|
|
|
|
tmp_parent_handles = set()
|
|
|
|
|
|
|
|
# first we queue up the parents we know about
|
|
|
|
if mother_handle:
|
|
|
|
tmp_parent_handles.add(mother_handle)
|
|
|
|
if father_handle:
|
|
|
|
tmp_parent_handles.add(father_handle)
|
|
|
|
|
|
|
|
while len(tmp_parent_handles) > 0:
|
|
|
|
# pop the next parent from the set
|
|
|
|
parent_handle = tmp_parent_handles.pop()
|
|
|
|
|
|
|
|
# add this parent to our official list
|
|
|
|
all_parent_handles.add(parent_handle)
|
|
|
|
|
|
|
|
# get all families with this parent
|
|
|
|
parent = db.get_person_from_handle(parent_handle)
|
|
|
|
for family_handle in parent.get_family_handle_list():
|
|
|
|
|
|
|
|
all_family_handles.add(family_handle)
|
|
|
|
|
|
|
|
# we already have 1 parent from this family
|
|
|
|
# (see "parent" above) so now see if we need
|
|
|
|
# to queue up the other parent
|
|
|
|
family = db.get_family_from_handle(family_handle)
|
|
|
|
tmp_mother_handle = family.get_mother_handle()
|
|
|
|
if tmp_mother_handle and \
|
|
|
|
tmp_mother_handle != parent and \
|
|
|
|
tmp_mother_handle not in tmp_parent_handles and \
|
|
|
|
tmp_mother_handle not in all_parent_handles:
|
|
|
|
tmp_parent_handles.add(tmp_mother_handle)
|
|
|
|
tmp_father_handle = family.get_father_handle()
|
|
|
|
if tmp_father_handle and \
|
|
|
|
tmp_father_handle != parent and \
|
|
|
|
tmp_father_handle not in tmp_parent_handles and \
|
|
|
|
tmp_father_handle not in all_parent_handles:
|
|
|
|
tmp_parent_handles.add(tmp_father_handle)
|
|
|
|
|
|
|
|
# once we get here, we have all of the families
|
|
|
|
# that could result in step-siblings; note that
|
|
|
|
# we can only have step-siblings if the number
|
|
|
|
# of families involved is > 1
|
|
|
|
|
|
|
|
if len(all_family_handles) > 1:
|
|
|
|
while len(all_family_handles) > 0:
|
|
|
|
# pop the next family from the set
|
|
|
|
family_handle = all_family_handles.pop()
|
|
|
|
# look in this family for children we haven't yet seen
|
|
|
|
family = db.get_family_from_handle(family_handle)
|
|
|
|
for step_child_ref in family.get_child_ref_list():
|
|
|
|
step_child_handle = step_child_ref.ref
|
2008-07-17 17:24:33 +05:30
|
|
|
if step_child_handle not in sibling and \
|
|
|
|
step_child_handle not in half_siblings and \
|
|
|
|
step_child_handle != self.person.handle:
|
|
|
|
# we have a new step sibling
|
|
|
|
step_siblings.add(step_child_handle)
|
2008-07-06 14:10:47 +05:30
|
|
|
|
|
|
|
# now that we have all of the step-siblings, print them out
|
|
|
|
if len(step_siblings) > 0:
|
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _("Step Siblings"))
|
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">\n')
|
|
|
|
of.write('\t\t\t\t\t<ol>\n')
|
|
|
|
for child_handle in step_siblings:
|
2007-07-19 12:15:25 +05:30
|
|
|
self.display_child_link(of, child_handle)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t\t</ol>\n')
|
|
|
|
of.write('\t\t\t\t</td>\n')
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2008-07-06 14:10:47 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</table>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def display_ind_relationships(self, of):
|
2005-08-18 11:28:28 +05:30
|
|
|
family_list = self.person.get_family_handle_list()
|
|
|
|
if not family_list:
|
|
|
|
return
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t<div id="families" class="subsection">\n')
|
|
|
|
of.write('\t\t<h4>%s</h4>\n' % _("Families"))
|
|
|
|
of.write('\t\t<table class="infolist">\n')
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
2005-08-18 11:28:28 +05:30
|
|
|
for family_handle in family_list:
|
2008-03-14 03:58:22 +05:30
|
|
|
family = db.get_family_from_handle(family_handle)
|
2008-03-21 03:54:36 +05:30
|
|
|
self.display_spouse(of, family)
|
2007-08-12 08:12:22 +05:30
|
|
|
childlist = family.get_child_ref_list()
|
2005-08-18 11:28:28 +05:30
|
|
|
if childlist:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnType"> </td>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _("Children"))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">\n')
|
|
|
|
of.write('\t\t\t\t\t<ol>\n')
|
2008-04-08 01:08:08 +05:30
|
|
|
childlist = [child_ref.ref for child_ref in childlist]
|
2008-04-08 22:41:48 +05:30
|
|
|
# TODO. Optionally sort on birthdate
|
2008-04-08 01:08:08 +05:30
|
|
|
for child_handle in childlist:
|
|
|
|
self.display_child_link(of, child_handle)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t\t</ol>\n')
|
|
|
|
of.write('\t\t\t\t</td>\n')
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t</table>\n')
|
|
|
|
of.write('\t</div>\n\n')
|
2005-02-10 07:14:05 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
def display_spouse(self, of, family):
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
2005-02-01 09:16:29 +05:30
|
|
|
gender = self.person.get_gender()
|
|
|
|
reltype = family.get_relationship()
|
|
|
|
|
2007-10-08 22:11:39 +05:30
|
|
|
if reltype == gen.lib.FamilyRelType.MARRIED:
|
|
|
|
if gender == gen.lib.Person.FEMALE:
|
2005-02-01 09:16:29 +05:30
|
|
|
relstr = _("Husband")
|
2007-10-08 22:11:39 +05:30
|
|
|
elif gender == gen.lib.Person.MALE:
|
2005-02-01 09:16:29 +05:30
|
|
|
relstr = _("Wife")
|
|
|
|
else:
|
|
|
|
relstr = _("Partner")
|
|
|
|
else:
|
|
|
|
relstr = _("Partner")
|
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
spouse_id = ReportUtils.find_spouse(self.person, family)
|
2005-02-01 09:16:29 +05:30
|
|
|
if spouse_id:
|
2008-03-14 03:58:22 +05:30
|
|
|
spouse = db.get_person_from_handle(spouse_id)
|
2007-08-12 08:12:22 +05:30
|
|
|
name = _nd.display(spouse)
|
2005-02-01 09:16:29 +05:30
|
|
|
else:
|
|
|
|
name = _("unknown")
|
2006-04-23 08:28:53 +05:30
|
|
|
rtype = str(family.get_relationship())
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr class="BeginFamily">\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnType">%s</td>\n' % rtype)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % relstr)
|
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">')
|
2005-08-18 11:28:28 +05:30
|
|
|
if spouse_id:
|
|
|
|
gid = spouse.get_gramps_id()
|
2008-03-10 01:42:56 +05:30
|
|
|
if spouse_id in self.ind_list:
|
2007-08-12 08:12:22 +05:30
|
|
|
spouse_name = _nd.display(spouse)
|
2008-03-21 03:54:36 +05:30
|
|
|
url = self.report.build_url_fname_html(spouse.handle, 'ppl', True)
|
|
|
|
self.person_link(of, url, spouse_name, gid)
|
2005-08-18 11:28:28 +05:30
|
|
|
else:
|
|
|
|
of.write(name)
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('</td>\n')
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2006-04-01 23:08:34 +05:30
|
|
|
for event_ref in family.get_event_ref_list():
|
2008-03-14 03:58:22 +05:30
|
|
|
event = db.get_event_from_handle(event_ref.ref)
|
2006-04-23 08:28:53 +05:30
|
|
|
evtType = str(event.get_type())
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnType"> </td>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % evtType)
|
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">')
|
2007-10-21 02:56:43 +05:30
|
|
|
of.write(self.format_event(event, event_ref))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('</td>\n')
|
|
|
|
of.write('\t\t\t</tr>\n')
|
2008-04-08 01:08:08 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
for attr in family.get_attribute_list():
|
2006-04-23 08:28:53 +05:30
|
|
|
attrType = str(attr.get_type())
|
2008-04-08 01:08:08 +05:30
|
|
|
if attrType:
|
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnType"> </td>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>' % attrType)
|
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">%s</td>\n' % attr.get_value())
|
|
|
|
of.write('\t\t\t</tr>\n')
|
|
|
|
|
2007-03-10 09:55:23 +05:30
|
|
|
notelist = family.get_note_list()
|
|
|
|
for notehandle in notelist:
|
2008-03-14 03:58:22 +05:30
|
|
|
note = db.get_note_from_handle(notehandle)
|
2008-03-14 02:01:33 +05:30
|
|
|
if note:
|
|
|
|
text = note.get()
|
|
|
|
format = note.get_format()
|
2007-03-10 09:55:23 +05:30
|
|
|
if text:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t<tr>\n')
|
|
|
|
of.write('\t\t\t\t<td class="ColumnType"> </td>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnAttribute">%s</td>\n' % _('Narrative'))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\t\t\t\t<td class="ColumnValue">\n')
|
|
|
|
of.write('\t\t\t\t\t<p>')
|
2007-03-10 09:55:23 +05:30
|
|
|
if format:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write(u"<pre>%s</pre>" % text )
|
2007-03-10 09:55:23 +05:30
|
|
|
else:
|
2008-05-04 12:35:42 +05:30
|
|
|
of.write(u"<br />".join(text.split("\n")))
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('</p>\n')
|
|
|
|
of.write('\t\t\t\t</td>\n')
|
|
|
|
of.write('\t\t\t</tr>\n')
|
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
def pedigree_person(self, of, person):
|
2008-03-08 17:00:59 +05:30
|
|
|
person_name = _nd.display(person)
|
2008-03-14 02:01:33 +05:30
|
|
|
if person.handle in self.ind_list:
|
2008-03-21 03:54:36 +05:30
|
|
|
url = self.report.build_url_fname_html(person.handle, 'ppl', True)
|
|
|
|
self.person_link(of, url, person_name)
|
2005-08-18 11:28:28 +05:30
|
|
|
else:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write(person_name)
|
2005-02-04 09:24:48 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def pedigree_family(self, of):
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
2005-02-04 09:24:48 +05:30
|
|
|
for family_handle in self.person.get_family_handle_list():
|
2008-03-14 03:58:22 +05:30
|
|
|
rel_family = db.get_family_from_handle(family_handle)
|
2008-03-10 01:42:56 +05:30
|
|
|
spouse_handle = ReportUtils.find_spouse(self.person, rel_family)
|
2005-02-04 09:24:48 +05:30
|
|
|
if spouse_handle:
|
2008-03-14 03:58:22 +05:30
|
|
|
spouse = db.get_person_from_handle(spouse_handle)
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('<li class="spouse">')
|
|
|
|
self.pedigree_person(of, spouse)
|
2007-08-12 08:12:22 +05:30
|
|
|
childlist = rel_family.get_child_ref_list()
|
2005-02-04 09:24:48 +05:30
|
|
|
if childlist:
|
2008-03-08 17:00:59 +05:30
|
|
|
of.write('\n')
|
|
|
|
of.write('\t\t\t\t\t\t\t\t\t\t<ol>\n')
|
2006-04-23 08:28:53 +05:30
|
|
|
for child_ref in childlist:
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('\t\t\t\t\t\t\t\t\t\t\t')
|
2008-03-14 03:58:22 +05:30
|
|
|
child = db.get_person_from_handle(child_ref.ref)
|
2008-03-10 01:42:56 +05:30
|
|
|
of.write('<li>')
|
|
|
|
self.pedigree_person(of, child)
|
2008-03-06 18:37:37 +05:30
|
|
|
of.write('</li>\n')
|
2008-05-21 00:54:03 +05:30
|
|
|
of.write('\t\t\t\t\t\t\t\t\t\t</ol>\n')
|
|
|
|
of.write('\t\t\t\t\t\t\t\t\t</li>\n')
|
2008-03-06 18:37:37 +05:30
|
|
|
else:
|
|
|
|
of.write('</li>\n')
|
2005-02-04 09:24:48 +05:30
|
|
|
|
2008-05-21 00:54:03 +05:30
|
|
|
# TODO. This function must be converted similar to display_ind_events and display_event_row
|
2008-03-10 01:42:56 +05:30
|
|
|
def format_event(self, event, event_ref):
|
2008-03-14 03:58:22 +05:30
|
|
|
db = self.report.database
|
2008-03-18 02:39:16 +05:30
|
|
|
lnk = (self.report.cur_fname, self.page_title, self.gid)
|
2005-02-01 09:16:29 +05:30
|
|
|
descr = event.get_description()
|
2005-02-16 11:11:33 +05:30
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
2008-07-17 23:40:32 +05:30
|
|
|
if place_handle in self.place_list:
|
2005-08-18 11:28:28 +05:30
|
|
|
if lnk not in self.place_list[place_handle]:
|
|
|
|
self.place_list[place_handle].append(lnk)
|
|
|
|
else:
|
|
|
|
self.place_list[place_handle] = [lnk]
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
place = self.place_link_str(place_handle,
|
2008-03-14 03:58:22 +05:30
|
|
|
ReportUtils.place_name(db, place_handle),
|
2005-08-18 11:28:28 +05:30
|
|
|
up=True)
|
|
|
|
else:
|
|
|
|
place = u""
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2005-02-16 11:11:33 +05:30
|
|
|
date = _dd.display(event.get_date_object())
|
2008-03-21 03:54:36 +05:30
|
|
|
|
2008-04-16 20:16:48 +05:30
|
|
|
if date and place:
|
2008-05-21 00:54:03 +05:30
|
|
|
text = _("%(date)s at %(place)s") % { 'date': date, 'place': place }
|
2008-04-16 20:16:48 +05:30
|
|
|
elif place:
|
2008-05-21 00:54:03 +05:30
|
|
|
text = _("at %(place)s") % { 'place': place }
|
2008-04-16 20:16:48 +05:30
|
|
|
elif date:
|
|
|
|
text = date
|
|
|
|
else:
|
|
|
|
text = ''
|
2008-03-21 03:54:36 +05:30
|
|
|
if descr:
|
|
|
|
if text:
|
2008-04-16 20:16:48 +05:30
|
|
|
text += "<br />"
|
|
|
|
text += descr
|
2008-03-21 03:54:36 +05:30
|
|
|
|
|
|
|
text += self.get_citation_links(event.get_source_references())
|
2007-07-19 12:15:25 +05:30
|
|
|
|
2007-10-21 02:56:43 +05:30
|
|
|
# if the event or event reference has a attributes attached to it,
|
|
|
|
# get the text and format it correctly
|
|
|
|
attr_list = event.get_attribute_list()
|
|
|
|
attr_list.extend(event_ref.get_attribute_list())
|
|
|
|
for attr in attr_list:
|
2008-03-06 18:37:37 +05:30
|
|
|
text += _("<br />%(type)s: %(value)s") % {
|
2007-10-21 02:56:43 +05:30
|
|
|
'type' : attr.get_type(),
|
|
|
|
'value' : attr.get_value() }
|
|
|
|
|
|
|
|
# if the event or event reference has a note attached to it,
|
|
|
|
# get the text and format it correctly
|
2007-07-19 12:15:25 +05:30
|
|
|
notelist = event.get_note_list()
|
2007-10-21 02:56:43 +05:30
|
|
|
notelist.extend(event_ref.get_note_list())
|
2007-07-19 12:15:25 +05:30
|
|
|
for notehandle in notelist:
|
2008-03-14 03:58:22 +05:30
|
|
|
note = db.get_note_from_handle(notehandle)
|
2008-03-14 02:01:33 +05:30
|
|
|
if note:
|
|
|
|
note_text = note.get()
|
|
|
|
format = note.get_format()
|
2007-07-19 12:15:25 +05:30
|
|
|
if note_text:
|
2008-06-21 14:12:31 +05:30
|
|
|
text += u'\n\t\t\t\t\t<p class="EventNote">\n\t\t\t\t\t'
|
2007-07-19 12:15:25 +05:30
|
|
|
if format:
|
|
|
|
text += u"<pre>%s</pre>" % note_text
|
|
|
|
else:
|
2008-05-12 00:49:38 +05:30
|
|
|
text += "<br />"
|
2008-03-06 18:37:37 +05:30
|
|
|
text += u"<br />".join(note_text.split("\n"))
|
2008-06-21 14:12:31 +05:30
|
|
|
text += u'\n\t\t\t\t\t</p>\n\t\t\t\t'
|
2007-01-18 10:01:08 +05:30
|
|
|
return text
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2007-01-18 10:01:08 +05:30
|
|
|
def get_citation_links(self, source_ref_list):
|
|
|
|
gid_list = []
|
2008-03-18 02:39:16 +05:30
|
|
|
lnk = (self.report.cur_fname, self.page_title, self.gid)
|
2007-01-18 10:01:08 +05:30
|
|
|
|
|
|
|
for sref in source_ref_list:
|
|
|
|
handle = sref.get_reference_handle()
|
|
|
|
gid_list.append(sref)
|
|
|
|
|
2008-07-17 23:40:32 +05:30
|
|
|
if handle in self.src_list:
|
2007-01-18 10:01:08 +05:30
|
|
|
if lnk not in self.src_list[handle]:
|
|
|
|
self.src_list[handle].append(lnk)
|
|
|
|
else:
|
|
|
|
self.src_list[handle] = [lnk]
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
text = ""
|
2005-08-18 11:28:28 +05:30
|
|
|
if len(gid_list) > 0:
|
|
|
|
text = text + " <sup>"
|
|
|
|
for ref in gid_list:
|
2008-03-10 01:42:56 +05:30
|
|
|
index, key = self.bibli.add_reference(ref)
|
2008-03-15 02:37:35 +05:30
|
|
|
id_ = "%d%s" % (index+1, key)
|
|
|
|
text = text + ' <a href="#sref%s">%s</a>' % (id_, id_)
|
2005-08-18 11:28:28 +05:30
|
|
|
text = text + "</sup>"
|
2007-01-18 10:01:08 +05:30
|
|
|
|
2005-02-01 09:16:29 +05:30
|
|
|
return text
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
class NavWebReport(Report):
|
2008-03-14 03:58:22 +05:30
|
|
|
|
2008-02-20 10:22:10 +05:30
|
|
|
def __init__(self, database, options):
|
2005-02-01 09:16:29 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create WebReport object that produces the report.
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2005-02-01 09:16:29 +05:30
|
|
|
The arguments are:
|
|
|
|
|
|
|
|
database - the GRAMPS database instance
|
2008-02-10 09:39:09 +05:30
|
|
|
options - instance of the Options class for this report
|
2005-02-01 09:16:29 +05:30
|
|
|
"""
|
2008-02-20 10:22:10 +05:30
|
|
|
Report.__init__(self, database, options)
|
2008-02-10 09:39:09 +05:30
|
|
|
menu = options.menu
|
2008-03-14 03:58:22 +05:30
|
|
|
self.options = {}
|
2008-02-10 09:39:09 +05:30
|
|
|
|
|
|
|
for optname in menu.get_all_option_names():
|
|
|
|
menuopt = menu.get_option_by_name(optname)
|
2008-03-14 03:58:22 +05:30
|
|
|
self.options[optname] = menuopt.get_value()
|
2007-08-12 08:12:22 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
if not self.options['incpriv']:
|
2007-08-12 08:12:22 +05:30
|
|
|
self.database = PrivateProxyDb(database)
|
|
|
|
else:
|
|
|
|
self.database = database
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
livinginfo = self.options['living']
|
|
|
|
yearsafterdeath = self.options['yearsafterdeath']
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-06-05 09:15:14 +05:30
|
|
|
if livinginfo != _INCLUDE_LIVING_VALUE:
|
2007-08-27 01:49:18 +05:30
|
|
|
self.database = LivingProxyDb(self.database,
|
2008-06-05 09:15:14 +05:30
|
|
|
livinginfo,
|
2007-08-27 01:49:18 +05:30
|
|
|
None,
|
|
|
|
yearsafterdeath)
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
filters_option = menu.get_option_by_name('filter')
|
|
|
|
self.filter = filters_option.get_filter()
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
self.copyright = self.options['cright']
|
2008-03-18 02:39:16 +05:30
|
|
|
self.target_path = self.options['target']
|
|
|
|
self.ext = self.options['ext']
|
2008-03-14 03:58:22 +05:30
|
|
|
self.css = self.options['css']
|
2008-03-18 02:39:16 +05:30
|
|
|
self.encoding = self.options['encoding']
|
2008-03-14 03:58:22 +05:30
|
|
|
self.title = self.options['title']
|
|
|
|
self.inc_gallery = self.options['gallery']
|
2008-03-18 02:39:16 +05:30
|
|
|
self.inc_contact = self.options['contactnote'] or \
|
|
|
|
self.options['contactimg']
|
2008-03-14 03:58:22 +05:30
|
|
|
self.inc_download = self.options['incdownload']
|
|
|
|
self.use_archive = self.options['archive']
|
2008-03-18 02:39:16 +05:30
|
|
|
self.use_intro = self.options['intronote'] or \
|
|
|
|
self.options['introimg']
|
|
|
|
self.use_home = self.options['homenote'] or \
|
|
|
|
self.options['homeimg']
|
|
|
|
self.use_contact = self.options['contactnote'] or \
|
|
|
|
self.options['contactimg']
|
|
|
|
|
|
|
|
if self.use_home:
|
|
|
|
self.index_fname = "index"
|
|
|
|
self.surname_fname = "surnames"
|
|
|
|
self.intro_fname = "introduction"
|
|
|
|
elif self.use_intro:
|
|
|
|
self.index_fname = None
|
|
|
|
self.surname_fname = "surnames"
|
|
|
|
self.intro_fname = "index"
|
|
|
|
else:
|
|
|
|
self.index_fname = None
|
|
|
|
self.surname_fname = "index"
|
|
|
|
self.intro_fname = None
|
2008-03-14 03:58:22 +05:30
|
|
|
|
|
|
|
self.archive = None
|
|
|
|
self.cur_fname = None # Internal use. The name of the output file, to be used for the tar archive.
|
2008-03-21 03:54:36 +05:30
|
|
|
self.string_io = None
|
2008-03-14 03:58:22 +05:30
|
|
|
if self.use_archive:
|
|
|
|
self.html_dir = None
|
|
|
|
else:
|
|
|
|
self.html_dir = self.target_path
|
|
|
|
self.warn_dir = True # Only give warning once.
|
2008-03-15 02:37:35 +05:30
|
|
|
self.photo_list = {}
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2005-02-01 09:16:29 +05:30
|
|
|
def write_report(self):
|
2005-08-18 11:28:28 +05:30
|
|
|
if not self.use_archive:
|
|
|
|
dir_name = self.target_path
|
2008-06-16 20:31:46 +05:30
|
|
|
if dir_name is None:
|
2005-08-18 11:28:28 +05:30
|
|
|
dir_name = os.getcwd()
|
|
|
|
elif not os.path.isdir(dir_name):
|
|
|
|
parent_dir = os.path.dirname(dir_name)
|
|
|
|
if not os.path.isdir(parent_dir):
|
|
|
|
ErrorDialog(_("Neither %s nor %s are directories") % \
|
2008-03-10 01:42:56 +05:30
|
|
|
(dir_name, parent_dir))
|
2005-02-01 09:16:29 +05:30
|
|
|
return
|
2005-08-18 11:28:28 +05:30
|
|
|
else:
|
|
|
|
try:
|
|
|
|
os.mkdir(dir_name)
|
|
|
|
except IOError, value:
|
|
|
|
ErrorDialog(_("Could not create the directory: %s") % \
|
|
|
|
dir_name + "\n" + value[1])
|
|
|
|
return
|
|
|
|
except:
|
|
|
|
ErrorDialog(_("Could not create the directory: %s") % \
|
|
|
|
dir_name)
|
|
|
|
return
|
2005-02-01 09:16:29 +05:30
|
|
|
|
|
|
|
try:
|
2005-08-18 11:28:28 +05:30
|
|
|
image_dir_name = os.path.join(dir_name, 'images')
|
|
|
|
if not os.path.isdir(image_dir_name):
|
|
|
|
os.mkdir(image_dir_name)
|
|
|
|
|
|
|
|
image_dir_name = os.path.join(dir_name, 'thumb')
|
|
|
|
if not os.path.isdir(image_dir_name):
|
|
|
|
os.mkdir(image_dir_name)
|
2005-02-01 09:16:29 +05:30
|
|
|
except IOError, value:
|
|
|
|
ErrorDialog(_("Could not create the directory: %s") % \
|
2005-02-13 09:24:47 +05:30
|
|
|
image_dir_name + "\n" + value[1])
|
2005-02-01 09:16:29 +05:30
|
|
|
return
|
|
|
|
except:
|
|
|
|
ErrorDialog(_("Could not create the directory: %s") % \
|
2005-02-13 09:24:47 +05:30
|
|
|
image_dir_name)
|
2005-02-01 09:16:29 +05:30
|
|
|
return
|
2005-12-06 12:08:09 +05:30
|
|
|
else:
|
|
|
|
if os.path.isdir(self.target_path):
|
|
|
|
ErrorDialog(_('Invalid file name'),
|
|
|
|
_('The archive file must be a file, not a directory'))
|
|
|
|
return
|
|
|
|
try:
|
2008-03-14 03:58:22 +05:30
|
|
|
self.archive = tarfile.open(self.target_path, "w:gz")
|
2008-03-10 01:42:56 +05:30
|
|
|
except (OSError, IOError), value:
|
2005-12-06 12:08:09 +05:30
|
|
|
ErrorDialog(_("Could not create %s") % self.target_path,
|
|
|
|
value)
|
|
|
|
return
|
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
self.progress = Utils.ProgressMeter(_("Generate XHTML Reports"), '')
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
# Build the person list
|
2007-08-27 01:49:18 +05:30
|
|
|
ind_list = self.build_person_list()
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
# Generate the CSS file if requested
|
2008-07-16 13:29:29 +05:30
|
|
|
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"]
|
|
|
|
|
2008-07-15 19:07:17 +05:30
|
|
|
# Copy the Creative Commons icon if the Creative Commons
|
2005-12-06 12:08:09 +05:30
|
|
|
# license is requested
|
2006-03-01 01:24:35 +05:30
|
|
|
if 0 < self.copyright < 7:
|
2008-03-08 17:00:59 +05:30
|
|
|
imgs += ["somerights20.gif"]
|
|
|
|
|
2008-07-16 13:29:29 +05:30
|
|
|
imgs += ["favicon.ico"]
|
|
|
|
|
2008-03-08 17:00:59 +05:30
|
|
|
for f in imgs:
|
|
|
|
from_path = os.path.join(const.IMAGE_DIR, f)
|
2008-07-17 17:24:33 +05:30
|
|
|
self.copy_file(from_path, f, "images")
|
2008-03-06 18:37:37 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
place_list = {}
|
|
|
|
source_list = {}
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
self.base_pages()
|
|
|
|
self.person_pages(ind_list, place_list, source_list)
|
|
|
|
self.surname_pages(ind_list)
|
|
|
|
self.place_pages(place_list, source_list)
|
2005-12-06 12:08:09 +05:30
|
|
|
if self.inc_gallery:
|
2008-03-14 03:58:22 +05:30
|
|
|
self.gallery_pages(source_list)
|
2008-03-15 05:20:54 +05:30
|
|
|
self.source_pages(source_list)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
if self.archive:
|
|
|
|
self.archive.close()
|
2005-12-06 12:08:09 +05:30
|
|
|
self.progress.close()
|
2005-02-28 05:13:20 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
def build_person_list(self):
|
|
|
|
"""
|
|
|
|
Builds the person list. Gets all the handles from the database
|
2008-03-14 03:58:22 +05:30
|
|
|
and then applies the chosen filter:
|
2005-12-06 12:08:09 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
# gets the person list and applies the requested filter
|
2005-02-28 05:13:20 +05:30
|
|
|
ind_list = self.database.get_person_handles(sort_handles=False)
|
2008-03-10 01:42:56 +05:30
|
|
|
self.progress.set_pass(_('Filtering'), 1)
|
|
|
|
ind_list = self.filter.apply(self.database, ind_list)
|
2007-08-27 01:49:18 +05:30
|
|
|
return ind_list
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-07-16 13:29:29 +05:30
|
|
|
def copy_css(self, css_file):
|
2005-12-06 12:08:09 +05:30
|
|
|
"""
|
2008-07-16 13:29:29 +05:30
|
|
|
Copy the CSS files to the target directory.
|
2005-12-06 12:08:09 +05:30
|
|
|
"""
|
2008-03-14 03:58:22 +05:30
|
|
|
|
2008-07-17 17:24:33 +05:30
|
|
|
fname = os.path.join(const.DATA_DIR, css_file)
|
|
|
|
self.copy_file(fname, _NARRATIVESCREEN, "styles")
|
|
|
|
fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css")
|
|
|
|
self.copy_file(fname, _NARRATIVEPRINT, "styles")
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def person_pages(self, ind_list, place_list, source_list):
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
self.progress.set_pass(_('Creating individual pages'), len(ind_list) + 1)
|
2007-07-19 12:15:25 +05:30
|
|
|
self.progress.step() # otherwise the progress indicator sits at 100%
|
|
|
|
# for a short while from the last step we did,
|
|
|
|
# which was to apply the privacy filter
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
IndividualListPage(self, self.title, ind_list)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2005-02-01 09:16:29 +05:30
|
|
|
for person_handle in ind_list:
|
2005-12-06 12:08:09 +05:30
|
|
|
self.progress.step()
|
2005-02-01 09:16:29 +05:30
|
|
|
person = self.database.get_person_from_handle(person_handle)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
IndividualPage(self, self.title, person, ind_list, place_list, source_list)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def surname_pages(self, ind_list):
|
2005-12-06 12:08:09 +05:30
|
|
|
"""
|
|
|
|
Generates the surname related pages from list of individual
|
|
|
|
people.
|
|
|
|
"""
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
local_list = sort_people(self.database, ind_list)
|
|
|
|
self.progress.set_pass(_("Creating surname pages"), len(local_list))
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-18 02:39:16 +05:30
|
|
|
SurnameListPage(self, self.title, ind_list, SurnameListPage.ORDER_BY_NAME, self.surname_fname)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
SurnameListPage(self, self.title, ind_list, SurnameListPage.ORDER_BY_COUNT, "surnames_count")
|
2005-02-13 09:24:47 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
for (surname, handle_list) in local_list:
|
2008-03-15 02:37:35 +05:30
|
|
|
SurnamePage(self, self.title, surname, handle_list)
|
2005-12-06 12:08:09 +05:30
|
|
|
self.progress.step()
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def source_pages(self, source_list):
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
self.progress.set_pass(_("Creating source pages"), len(source_list))
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
SourcesPage(self, self.title, source_list.keys())
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-05-21 00:54:03 +05:30
|
|
|
for key in source_list:
|
2008-03-14 03:58:22 +05:30
|
|
|
SourcePage(self, self.title, key, source_list)
|
2005-12-06 12:08:09 +05:30
|
|
|
self.progress.step()
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def place_pages(self, place_list, source_list):
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-10 01:42:56 +05:30
|
|
|
self.progress.set_pass(_("Creating place pages"), len(place_list))
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
PlaceListPage(self, self.title, place_list, source_list)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
for place in place_list.keys():
|
2008-03-14 03:58:22 +05:30
|
|
|
PlacePage(self, self.title, place, source_list, place_list)
|
2005-12-06 12:08:09 +05:30
|
|
|
self.progress.step()
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def gallery_pages(self, source_list):
|
2007-04-09 01:49:14 +05:30
|
|
|
import gc
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
self.progress.set_pass(_("Creating media pages"), len(self.photo_list))
|
|
|
|
|
2008-05-21 00:54:03 +05:30
|
|
|
GalleryPage(self, self.title)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
prev = None
|
2005-12-06 12:08:09 +05:30
|
|
|
total = len(self.photo_list)
|
|
|
|
photo_keys = self.photo_list.keys()
|
2007-10-12 17:46:49 +05:30
|
|
|
sort = Sort.Sort(self.database)
|
|
|
|
photo_keys.sort(sort.by_media_title)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-07-04 00:40:05 +05:30
|
|
|
index = 1
|
2005-08-18 11:28:28 +05:30
|
|
|
for photo_handle in photo_keys:
|
2007-04-09 01:49:14 +05:30
|
|
|
gc.collect() # Reduce memory usage when there are many images.
|
2005-08-18 11:28:28 +05:30
|
|
|
if index == total:
|
|
|
|
next = None
|
|
|
|
else:
|
|
|
|
next = photo_keys[index]
|
2008-03-14 03:58:22 +05:30
|
|
|
# Notice. Here self.photo_list[photo_handle] is used not self.photo_list
|
|
|
|
MediaPage(self, self.title, photo_handle, source_list, self.photo_list[photo_handle],
|
2005-12-06 12:08:09 +05:30
|
|
|
(prev, next, index, total))
|
|
|
|
self.progress.step()
|
2005-08-18 11:28:28 +05:30
|
|
|
prev = photo_handle
|
|
|
|
index += 1
|
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
def base_pages(self):
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
if self.use_home:
|
2008-03-14 03:58:22 +05:30
|
|
|
HomePage(self, self.title)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
if self.inc_contact:
|
2008-03-14 03:58:22 +05:30
|
|
|
ContactPage(self, self.title)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
if self.inc_download:
|
2008-03-14 03:58:22 +05:30
|
|
|
DownloadPage(self, self.title)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
if self.use_intro:
|
2008-03-14 03:58:22 +05:30
|
|
|
IntroductionPage(self, self.title)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
def add_image(self, of, option_name, height=0):
|
|
|
|
pic_id = self.options[option_name]
|
|
|
|
if pic_id:
|
|
|
|
db = self.database
|
|
|
|
obj = db.get_object_from_gramps_id(pic_id)
|
|
|
|
mime_type = obj.get_mime_type()
|
|
|
|
if mime_type and mime_type.startswith("image"):
|
|
|
|
try:
|
2008-07-17 17:24:33 +05:30
|
|
|
newpath, thumb_path = self.prepare_copy_media(obj)
|
|
|
|
self.copy_file(Utils.media_path_full(db, obj.get_path()),
|
2008-03-21 03:54:36 +05:30
|
|
|
newpath)
|
|
|
|
of.write('\t<img')
|
|
|
|
if height:
|
|
|
|
of.write(' height="%d"' % height)
|
|
|
|
of.write(' src="%s"' % newpath)
|
|
|
|
of.write(' alt="%s"' % obj.get_description())
|
|
|
|
of.write(' />\n')
|
|
|
|
except (IOError, OSError), msg:
|
|
|
|
WarningDialog(_("Could not add photo to page"), str(msg))
|
2008-03-18 02:39:16 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
def build_subdirs(self, subdir, fname, up=False):
|
|
|
|
"""
|
|
|
|
If subdir is given, then two extra levels of subdirectory are inserted
|
|
|
|
between 'subdir' and the filename. The reason is to prevent directories with
|
|
|
|
too many entries.
|
2008-03-18 02:39:16 +05:30
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
For example, this may return "8/1/aec934857df74d36618"
|
2008-03-18 02:39:16 +05:30
|
|
|
"""
|
2008-03-21 03:54:36 +05:30
|
|
|
subdirs = []
|
|
|
|
if subdir:
|
|
|
|
subdirs.append(subdir)
|
|
|
|
subdirs.append(fname[-1].lower())
|
|
|
|
subdirs.append(fname[-2].lower())
|
|
|
|
if up:
|
|
|
|
subdirs = ['..']*3 + subdirs
|
|
|
|
return subdirs
|
|
|
|
|
|
|
|
def build_path(self, subdir, fname, up=False):
|
|
|
|
"""
|
|
|
|
Return the name of the subdirectory.
|
|
|
|
|
|
|
|
Notice that we DO use os.path.join() here.
|
|
|
|
"""
|
|
|
|
return os.path.join(*self.build_subdirs(subdir, fname, up))
|
|
|
|
|
|
|
|
def build_url_image(self, fname, subdir=None, up=False):
|
|
|
|
subdirs = []
|
|
|
|
if subdir:
|
|
|
|
subdirs.append(subdir)
|
|
|
|
if up:
|
|
|
|
subdirs = ['..']*3 + subdirs
|
|
|
|
return '/'.join(subdirs + [fname])
|
|
|
|
|
|
|
|
def build_url_fname_html(self, fname, subdir=None, up=False):
|
|
|
|
return self.build_url_fname(fname, subdir, up) + self.ext
|
|
|
|
|
|
|
|
def build_url_fname(self, fname, subdir=None, up=False):
|
|
|
|
"""
|
|
|
|
Create part of the URL given the filename and optionally the subdirectory.
|
|
|
|
If the subdirectory is given, then two extra levels of subdirectory are inserted
|
|
|
|
between 'subdir' and the filename. The reason is to prevent directories with
|
|
|
|
too many entries.
|
|
|
|
If 'up' is True, then "../../../" is inserted in front of the result.
|
|
|
|
|
|
|
|
The extension is added to the filename as well.
|
|
|
|
|
|
|
|
Notice that we do NOT use os.path.join() because we're creating a URL.
|
|
|
|
Imagine we run gramps on Windows (heaven forbits), we don't want to
|
|
|
|
see backslashes in the URL.
|
2008-03-18 02:39:16 +05:30
|
|
|
"""
|
2008-03-21 03:54:36 +05:30
|
|
|
subdirs = self.build_subdirs(subdir, fname, up)
|
|
|
|
return '/'.join(subdirs + [fname])
|
|
|
|
|
|
|
|
def create_file(self, fname, subdir=None):
|
|
|
|
if subdir:
|
|
|
|
subdir = self.build_path(subdir, fname)
|
|
|
|
self.cur_fname = os.path.join(subdir, fname) + self.ext
|
|
|
|
else:
|
|
|
|
self.cur_fname = fname + self.ext
|
2008-03-18 02:39:16 +05:30
|
|
|
if self.archive:
|
|
|
|
self.string_io = StringIO()
|
|
|
|
of = codecs.EncodedFile(self.string_io, 'utf-8',
|
|
|
|
self.encoding, 'xmlcharrefreplace')
|
|
|
|
else:
|
2008-03-21 03:54:36 +05:30
|
|
|
if subdir:
|
|
|
|
subdir = os.path.join(self.html_dir, subdir)
|
|
|
|
if not os.path.isdir(subdir):
|
|
|
|
os.makedirs(subdir)
|
|
|
|
fname = os.path.join(self.html_dir, self.cur_fname)
|
|
|
|
of = codecs.EncodedFile(open(fname, "w"), 'utf-8',
|
2008-03-18 02:39:16 +05:30
|
|
|
self.encoding, 'xmlcharrefreplace')
|
|
|
|
return of
|
|
|
|
|
|
|
|
def close_file(self, of):
|
|
|
|
if self.archive:
|
|
|
|
tarinfo = tarfile.TarInfo(self.cur_fname)
|
|
|
|
tarinfo.size = len(self.string_io.getvalue())
|
|
|
|
tarinfo.mtime = time.time()
|
|
|
|
if os.sys.platform != "win32":
|
|
|
|
tarinfo.uid = os.getuid()
|
|
|
|
tarinfo.gid = os.getgid()
|
|
|
|
self.string_io.seek(0)
|
|
|
|
self.archive.addfile(tarinfo, self.string_io)
|
2008-03-21 03:54:36 +05:30
|
|
|
self.string_io = None
|
2008-03-18 02:39:16 +05:30
|
|
|
of.close()
|
|
|
|
else:
|
|
|
|
of.close()
|
|
|
|
self.cur_fname = None
|
|
|
|
|
2008-03-21 03:54:36 +05:30
|
|
|
def add_lnkref_to_photo(self, photo, lnkref):
|
|
|
|
handle = photo.get_handle()
|
|
|
|
# FIXME. Is it OK to add to the photo_list of report?
|
|
|
|
photo_list = self.photo_list
|
|
|
|
if handle in photo_list:
|
|
|
|
if lnkref not in photo_list[handle]:
|
|
|
|
photo_list[handle].append(lnkref)
|
|
|
|
else:
|
|
|
|
photo_list[handle] = [lnkref]
|
|
|
|
|
2008-07-17 17:24:33 +05:30
|
|
|
def prepare_copy_media(self, photo):
|
2008-03-21 03:54:36 +05:30
|
|
|
handle = photo.get_handle()
|
|
|
|
ext = os.path.splitext(photo.get_path())[1]
|
|
|
|
real_path = os.path.join(self.build_path('images', handle), handle + ext)
|
|
|
|
thumb_path = os.path.join(self.build_path('thumb', handle), handle + '.png')
|
2008-07-17 17:24:33 +05:30
|
|
|
return real_path, thumb_path
|
2008-03-21 03:54:36 +05:30
|
|
|
|
2008-04-01 01:20:37 +05:30
|
|
|
def copy_file(self, from_fname, to_fname, to_dir=''):
|
|
|
|
"""
|
|
|
|
Copy a file from a source to a (report) destination.
|
|
|
|
If to_dir is not present and if the target is not an archive,
|
|
|
|
then the destination directory will be created.
|
2008-07-17 17:24:33 +05:30
|
|
|
|
|
|
|
Normally 'to_fname' will be just a filename, without directory path.
|
|
|
|
|
|
|
|
'to_dir' is the relative path name in the destination root. It will
|
|
|
|
be prepended before 'to_fname'.
|
2008-04-01 01:20:37 +05:30
|
|
|
"""
|
|
|
|
if self.archive:
|
|
|
|
dest = os.path.join(to_dir, to_fname)
|
|
|
|
self.archive.add(from_fname, dest)
|
|
|
|
else:
|
2008-07-17 17:24:33 +05:30
|
|
|
dest = os.path.join(self.html_dir, to_dir, to_fname)
|
2008-04-01 01:20:37 +05:30
|
|
|
|
2008-07-17 17:24:33 +05:30
|
|
|
destdir = os.path.dirname(dest)
|
|
|
|
if not os.path.isdir(destdir):
|
|
|
|
os.makedirs(destdir)
|
|
|
|
|
|
|
|
if from_fname != dest:
|
|
|
|
shutil.copyfile(from_fname, dest)
|
2008-03-14 03:58:22 +05:30
|
|
|
elif self.warn_dir:
|
|
|
|
WarningDialog(
|
|
|
|
_("Possible destination error") + "\n" +
|
|
|
|
_("You appear to have set your target directory "
|
|
|
|
"to a directory used for data storage. This "
|
|
|
|
"could create problems with file management. "
|
|
|
|
"It is recommended that you consider using "
|
|
|
|
"a different directory to store your generated "
|
|
|
|
"web pages."))
|
|
|
|
self.warn_dir = False
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
class NavWebOptions(MenuReportOptions):
|
2005-02-01 09:16:29 +05:30
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
2008-02-10 09:39:09 +05:30
|
|
|
|
2008-02-20 10:22:10 +05:30
|
|
|
def __init__(self, name, dbase):
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__db = dbase
|
|
|
|
self.__archive = None
|
|
|
|
self.__target = None
|
|
|
|
self.__pid = None
|
|
|
|
self.__filter = None
|
|
|
|
self.__graph = None
|
|
|
|
self.__graphgens = None
|
|
|
|
self.__living = None
|
|
|
|
self.__yearsafterdeath = None
|
2008-02-20 10:22:10 +05:30
|
|
|
MenuReportOptions.__init__(self, name, dbase)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
def add_menu_options(self, menu):
|
|
|
|
"""
|
|
|
|
Add options to the menu for the web calendar.
|
|
|
|
"""
|
|
|
|
self.__add_report_options(menu)
|
|
|
|
self.__add_page_generation_options(menu)
|
|
|
|
self.__add_privacy_options(menu)
|
|
|
|
self.__add_advanced_options(menu)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
def __add_report_options(self, menu):
|
|
|
|
"""
|
|
|
|
Options on the "Report Options" tab.
|
|
|
|
"""
|
|
|
|
category_name = _("Report Options")
|
2008-03-08 22:10:19 +05:30
|
|
|
|
|
|
|
self.__archive = BooleanOption(_('Store web pages in .tar.gz archive'),
|
2008-02-10 09:39:09 +05:30
|
|
|
False)
|
|
|
|
self.__archive.set_help(_('Whether to store the web pages in an '
|
|
|
|
'archive file'))
|
|
|
|
menu.add_option(category_name, 'archive', self.__archive)
|
|
|
|
self.__archive.connect('value-changed', self.__archive_changed)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
|
|
|
self.__target = DestinationOption(_("Destination"),
|
2008-03-10 01:42:56 +05:30
|
|
|
os.path.join(const.USER_HOME, "NAVWEB"))
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__target.set_help( _("The destination directory for the web "
|
|
|
|
"files"))
|
|
|
|
menu.add_option(category_name, "target", self.__target)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__archive_changed()
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-07-16 13:29:29 +05:30
|
|
|
title = StringOption(_("Web site title"), _('My Family Tree'))
|
|
|
|
title.set_help(_("The title of the web site"))
|
|
|
|
menu.add_option(category_name, "title", title)
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__filter = FilterOption(_("Filter"), 0)
|
|
|
|
self.__filter.set_help(
|
|
|
|
_("Select filter to restrict people that appear on calendar"))
|
|
|
|
menu.add_option(category_name, "filter", self.__filter)
|
|
|
|
self.__filter.connect('value-changed', self.__filter_changed)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__pid = PersonOption(_("Filter Person"))
|
|
|
|
self.__pid.set_help(_("The center person for the filter"))
|
|
|
|
menu.add_option(category_name, "pid", self.__pid)
|
|
|
|
self.__pid.connect('value-changed', self.__update_filters)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__update_filters()
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
ext = EnumeratedListOption(_("File extension"), ".html" )
|
|
|
|
for etype in ['.html', '.htm', '.shtml', '.php', '.php3', '.cgi']:
|
|
|
|
ext.add_item(etype, etype)
|
|
|
|
ext.set_help( _("The extension to be used for the web files"))
|
|
|
|
menu.add_option(category_name, "ext", ext)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
cright = EnumeratedListOption(_('Copyright'), 0 )
|
|
|
|
index = 0
|
|
|
|
for copt in _COPY_OPTIONS:
|
|
|
|
cright.add_item(index, copt)
|
|
|
|
index += 1
|
|
|
|
cright.set_help( _("The copyright to be used for the web files"))
|
|
|
|
menu.add_option(category_name, "cright", cright)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-03-12 03:41:42 +05:30
|
|
|
encoding = EnumeratedListOption(_('Character set encoding'), _CHARACTER_SETS[0][1] )
|
2008-02-10 09:39:09 +05:30
|
|
|
for eopt in _CHARACTER_SETS:
|
|
|
|
encoding.add_item(eopt[1], eopt[0])
|
|
|
|
encoding.set_help( _("The encoding to be used for the web files"))
|
|
|
|
menu.add_option(category_name, "encoding", encoding)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-07-16 13:29:29 +05:30
|
|
|
css = EnumeratedListOption(_('StyleSheet'), _CSS_FILES[0][1])
|
2008-02-10 09:39:09 +05:30
|
|
|
for style in _CSS_FILES:
|
|
|
|
css.add_item(style[1], style[0])
|
2008-07-15 19:07:17 +05:30
|
|
|
css.set_help( _('The stylesheet to be used for the web page'))
|
2008-02-10 09:39:09 +05:30
|
|
|
menu.add_option(category_name, "css", css)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__graph = BooleanOption(_("Include ancestor graph"), True)
|
|
|
|
self.__graph.set_help(_('Whether to include an ancestor graph '
|
|
|
|
'on each individual page'))
|
|
|
|
menu.add_option(category_name, 'graph', self.__graph)
|
|
|
|
self.__graph.connect('value-changed', self.__graph_changed)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__graphgens = EnumeratedListOption(_('Graph generations'), 4)
|
|
|
|
self.__graphgens.add_item(2, "2")
|
|
|
|
self.__graphgens.add_item(3, "3")
|
|
|
|
self.__graphgens.add_item(4, "4")
|
|
|
|
self.__graphgens.add_item(5, "5")
|
|
|
|
self.__graphgens.set_help( _("The number of generations to include in "
|
|
|
|
"the ancestor graph"))
|
|
|
|
menu.add_option(category_name, "graphgens", self.__graphgens)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__graph_changed()
|
2007-11-27 03:23:58 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
def __add_page_generation_options(self, menu):
|
|
|
|
"""
|
|
|
|
Options on the "Page Generation" tab.
|
|
|
|
"""
|
|
|
|
category_name = _("Page Generation")
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
homenote = NoteOption(_('Home page note'))
|
|
|
|
homenote.set_help( _("A note to be used on the home page"))
|
|
|
|
menu.add_option(category_name, "homenote", homenote)
|
2007-11-27 03:23:58 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
homeimg = MediaOption(_('Home page image'))
|
|
|
|
homeimg.set_help( _("An image to be used on the home page"))
|
|
|
|
menu.add_option(category_name, "homeimg", homeimg)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
intronote = NoteOption(_('Introduction note'))
|
|
|
|
intronote.set_help( _("A note to be used as the introduction"))
|
|
|
|
menu.add_option(category_name, "intronote", intronote)
|
2007-11-27 03:23:58 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
introimg = MediaOption(_('Introduction image'))
|
|
|
|
introimg.set_help( _("An image to be used as the introduction"))
|
|
|
|
menu.add_option(category_name, "introimg", introimg)
|
2007-11-27 03:23:58 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
contactnote = NoteOption(_("Publisher contact note"))
|
|
|
|
contactnote.set_help( _("A note to be used as the publisher contact"))
|
|
|
|
menu.add_option(category_name, "contactnote", contactnote)
|
2007-11-27 03:23:58 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
contactimg = MediaOption(_("Publisher contact image"))
|
|
|
|
contactimg.set_help( _("An image to be used as the publisher contact"))
|
|
|
|
menu.add_option(category_name, "contactimg", contactimg)
|
2007-11-27 03:23:58 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
headernote = NoteOption(_('HTML user header'))
|
|
|
|
headernote.set_help( _("A note to be used as the page header"))
|
|
|
|
menu.add_option(category_name, "headernote", headernote)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
footernote = NoteOption(_('HTML user footer'))
|
|
|
|
footernote.set_help( _("A note to be used as the page footer"))
|
|
|
|
menu.add_option(category_name, "footernote", footernote)
|
2007-11-27 03:23:58 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
gallery = BooleanOption(_("Include images and media objects"), True)
|
|
|
|
gallery.set_help(_('Whether to include a gallery of media objects'))
|
|
|
|
menu.add_option(category_name, 'gallery', gallery)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
incdownload = BooleanOption(_("Include download page"), False)
|
|
|
|
incdownload.set_help(_('Whether to include a database download option'))
|
|
|
|
menu.add_option(category_name, 'incdownload', incdownload)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
nogid = BooleanOption(_('Suppress GRAMPS ID'), False)
|
|
|
|
nogid.set_help(_('Whether to include the Gramps ID of objects'))
|
|
|
|
menu.add_option(category_name, 'nogid', nogid)
|
2007-11-27 03:23:58 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
def __add_privacy_options(self, menu):
|
|
|
|
"""
|
|
|
|
Options on the "Privacy" tab.
|
|
|
|
"""
|
|
|
|
category_name = _("Privacy")
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
incpriv = BooleanOption(_("Include records marked private"), False)
|
|
|
|
incpriv.set_help(_('Whether to include private objects'))
|
|
|
|
menu.add_option(category_name, 'incpriv', incpriv)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
|
|
|
self.__living = EnumeratedListOption(_("Living People"),
|
2008-06-05 09:15:14 +05:30
|
|
|
_INCLUDE_LIVING_VALUE )
|
|
|
|
self.__living.add_item(LivingProxyDb.MODE_EXCLUDE_ALL,
|
|
|
|
_("Exclude"))
|
|
|
|
self.__living.add_item(LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY,
|
|
|
|
_("Include Last Name Only"))
|
|
|
|
self.__living.add_item(LivingProxyDb.MODE_INCLUDE_FULL_NAME_ONLY,
|
|
|
|
_("Include Full Name Only"))
|
|
|
|
self.__living.add_item(_INCLUDE_LIVING_VALUE,
|
|
|
|
_("Include"))
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__living.set_help(_("How to handle living people"))
|
|
|
|
menu.add_option(category_name, "living", self.__living)
|
|
|
|
self.__living.connect('value-changed', self.__living_changed)
|
|
|
|
|
|
|
|
self.__yearsafterdeath = NumberOption(_("Years from death to consider "
|
|
|
|
"living"), 30, 0, 100)
|
|
|
|
self.__yearsafterdeath.set_help(_("This allows you to restrict "
|
|
|
|
"information on people who have not "
|
|
|
|
"been dead for very long"))
|
2008-03-08 22:10:19 +05:30
|
|
|
menu.add_option(category_name, 'yearsafterdeath',
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__yearsafterdeath)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__living_changed()
|
2007-11-26 00:37:50 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
def __add_advanced_options(self, menu):
|
|
|
|
"""
|
|
|
|
Options on the "Advanced" tab.
|
|
|
|
"""
|
|
|
|
category_name = _("Advanced")
|
|
|
|
|
|
|
|
linkhome = BooleanOption(_('Include link to home person on every '
|
|
|
|
'page'), False)
|
|
|
|
linkhome.set_help(_('Whether to include a link to the home person'))
|
|
|
|
menu.add_option(category_name, 'linkhome', linkhome)
|
|
|
|
|
|
|
|
showbirth = BooleanOption(_("Include a column for birth dates on the "
|
|
|
|
"index pages"), True)
|
|
|
|
showbirth.set_help(_('Whether to include a birth column'))
|
|
|
|
menu.add_option(category_name, 'showbirth', showbirth)
|
|
|
|
|
|
|
|
showdeath = BooleanOption(_("Include a column for death dates on the "
|
|
|
|
"index pages"), False)
|
|
|
|
showdeath.set_help(_('Whether to include a death column'))
|
|
|
|
menu.add_option(category_name, 'showdeath', showdeath)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
showspouse = BooleanOption(_("Include a column for partners on the "
|
|
|
|
"index pages"), False)
|
|
|
|
showspouse.set_help(_('Whether to include a partners column'))
|
|
|
|
menu.add_option(category_name, 'showspouse', showspouse)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
showparents = BooleanOption(_("Include a column for parents on the "
|
|
|
|
"index pages"), False)
|
|
|
|
showparents.set_help(_('Whether to include a parents column'))
|
|
|
|
menu.add_option(category_name, 'showparents', showparents)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-07-06 14:10:47 +05:30
|
|
|
showallsiblings = BooleanOption(_("Include half-siblings and "
|
|
|
|
"step-siblings on the individual "
|
|
|
|
"pages"), False)
|
|
|
|
showallsiblings.set_help(_( "Whether to include half-siblings and "
|
|
|
|
"step-siblings with the parents and "
|
|
|
|
"siblings"))
|
|
|
|
menu.add_option(category_name, 'showhalfsiblings', showallsiblings)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
def __archive_changed(self):
|
|
|
|
"""
|
|
|
|
Update the change of storage: archive or directory
|
|
|
|
"""
|
|
|
|
if self.__archive.get_value() == True:
|
|
|
|
self.__target.set_extension(".tar.gz")
|
|
|
|
self.__target.set_directory_entry(False)
|
2005-08-18 11:28:28 +05:30
|
|
|
else:
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__target.set_directory_entry(True)
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
def __update_filters(self):
|
|
|
|
"""
|
|
|
|
Update the filter list based on the selected person
|
|
|
|
"""
|
|
|
|
gid = self.__pid.get_value()
|
|
|
|
person = self.__db.get_person_from_gramps_id(gid)
|
|
|
|
filter_list = ReportUtils.get_person_filters(person, False)
|
|
|
|
self.__filter.set_filters(filter_list)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
def __filter_changed(self):
|
|
|
|
"""
|
|
|
|
Handle filter change. If the filter is not specific to a person,
|
|
|
|
disable the person option
|
|
|
|
"""
|
|
|
|
filter_value = self.__filter.get_value()
|
|
|
|
if filter_value in [1, 2, 3, 4]:
|
|
|
|
# Filters 1, 2, 3 and 4 rely on the center person
|
|
|
|
self.__pid.set_available(True)
|
2005-08-18 11:28:28 +05:30
|
|
|
else:
|
2008-02-10 09:39:09 +05:30
|
|
|
# The rest don't
|
|
|
|
self.__pid.set_available(False)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
def __graph_changed(self):
|
|
|
|
"""
|
|
|
|
Handle enabling or disabling the ancestor graph
|
|
|
|
"""
|
|
|
|
self.__graphgens.set_available(self.__graph.get_value())
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
def __living_changed(self):
|
|
|
|
"""
|
|
|
|
Handle a change in the living option
|
|
|
|
"""
|
2008-06-05 09:15:14 +05:30
|
|
|
if self.__living.get_value() == _INCLUDE_LIVING_VALUE:
|
2008-02-10 09:39:09 +05:30
|
|
|
self.__yearsafterdeath.set_available(False)
|
|
|
|
else:
|
2008-03-08 22:10:19 +05:30
|
|
|
self.__yearsafterdeath.set_available(True)
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
def make_default_style(self, default_style):
|
|
|
|
"""Make the default output style for the Web Pages Report."""
|
2005-02-01 09:16:29 +05:30
|
|
|
pass
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2005-02-01 09:16:29 +05:30
|
|
|
|
2008-03-14 03:58:22 +05:30
|
|
|
# FIXME. Why do we need our own sorting? Why not use Sort.Sort?
|
2008-02-24 19:25:55 +05:30
|
|
|
def sort_people(db, handle_list):
|
2005-08-18 11:28:28 +05:30
|
|
|
sname_sub = {}
|
|
|
|
sortnames = {}
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2007-08-12 08:12:22 +05:30
|
|
|
for person_handle in handle_list:
|
|
|
|
person = db.get_person_from_handle(person_handle)
|
|
|
|
primary_name = person.get_primary_name()
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2007-08-12 08:12:22 +05:30
|
|
|
if primary_name.group_as:
|
|
|
|
surname = primary_name.group_as
|
|
|
|
else:
|
|
|
|
surname = db.get_name_group_mapping(primary_name.surname)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2007-08-12 08:12:22 +05:30
|
|
|
sortnames[person_handle] = _nd.sort_string(primary_name)
|
2008-03-08 22:10:19 +05:30
|
|
|
|
2008-07-17 23:40:32 +05:30
|
|
|
if surname in sname_sub:
|
2007-08-12 08:12:22 +05:30
|
|
|
sname_sub[surname].append(person_handle)
|
|
|
|
else:
|
|
|
|
sname_sub[surname] = [person_handle]
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
sorted_lists = []
|
|
|
|
temp_list = sname_sub.keys()
|
2007-10-04 09:26:41 +05:30
|
|
|
temp_list.sort(locale.strcoll)
|
2005-08-18 11:28:28 +05:30
|
|
|
for name in temp_list:
|
2008-07-04 22:57:51 +05:30
|
|
|
slist = [(sortnames[x], x) for x in sname_sub[name]]
|
2008-03-10 01:42:56 +05:30
|
|
|
slist.sort(lambda x, y: locale.strcoll(x[0], y[0]))
|
2008-07-04 22:57:51 +05:30
|
|
|
entries = [x[1] for x in slist]
|
2008-03-10 01:42:56 +05:30
|
|
|
sorted_lists.append((name, entries))
|
2005-08-18 11:28:28 +05:30
|
|
|
return sorted_lists
|
|
|
|
|
2008-05-19 00:54:28 +05:30
|
|
|
pmgr = PluginManager.get_instance()
|
|
|
|
pmgr.register_report(
|
2005-02-04 19:24:02 +05:30
|
|
|
name = 'navwebpage',
|
2006-06-01 10:09:40 +05:30
|
|
|
category = CATEGORY_WEB,
|
2008-02-10 09:39:09 +05:30
|
|
|
report_class = NavWebReport,
|
|
|
|
options_class = NavWebOptions,
|
2006-06-01 10:09:40 +05:30
|
|
|
modes = MODE_GUI | MODE_CLI,
|
2008-03-02 04:17:48 +05:30
|
|
|
translated_name = _("Narrated Web Site"),
|
2005-12-06 12:08:09 +05:30
|
|
|
status = _("Stable"),
|
2008-02-10 09:39:09 +05:30
|
|
|
author_name = "Donald N. Allingham",
|
|
|
|
author_email = "don@gramps-project.org",
|
2008-03-02 04:17:48 +05:30
|
|
|
description = _("Produces web (HTML) pages for individuals, or a set of "
|
|
|
|
"individuals"),
|
2005-02-01 09:16:29 +05:30
|
|
|
)
|