2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-01-12 09:46:22 +05:30
|
|
|
# Copyright (C) 2000-2005 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Pubilc License as published by
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2003-11-14 00:48:09 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"Web Site/Generate Web Site"
|
|
|
|
|
2003-01-15 10:55:50 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
import os
|
|
|
|
import shutil
|
2005-06-05 09:31:56 +05:30
|
|
|
import locale
|
2005-01-07 10:23:43 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-01-15 10:55:50 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/gtk
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
import gtk
|
2004-02-15 08:54:12 +05:30
|
|
|
import gnome.ui
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-01-15 10:55:50 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS module
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import RelLib
|
|
|
|
import HtmlDoc
|
2003-09-02 06:17:09 +05:30
|
|
|
import BaseDoc
|
2003-01-15 10:55:50 +05:30
|
|
|
import const
|
2005-01-06 22:58:31 +05:30
|
|
|
import GrampsKeys
|
2003-01-15 10:55:50 +05:30
|
|
|
import GenericFilter
|
2004-10-03 04:37:43 +05:30
|
|
|
import DateHandler
|
2004-05-07 07:50:39 +05:30
|
|
|
import Sort
|
2003-01-15 10:55:50 +05:30
|
|
|
import Report
|
2003-06-12 07:34:42 +05:30
|
|
|
import Errors
|
2004-10-26 08:50:38 +05:30
|
|
|
import Utils
|
2003-01-15 10:55:50 +05:30
|
|
|
from QuestionDialog import ErrorDialog
|
2005-01-07 10:23:43 +05:30
|
|
|
import ReportOptions
|
2005-06-05 09:31:56 +05:30
|
|
|
from NameDisplay import displayer as _nd
|
2003-01-15 10:55:50 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# constants
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
_month = [
|
|
|
|
"", "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
|
|
|
|
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ]
|
|
|
|
|
2003-07-21 05:44:27 +05:30
|
|
|
_hline = " " # Everything is underlined, so use blank
|
2004-03-17 08:34:10 +05:30
|
|
|
_BORN = _('b.')
|
2003-07-21 05:44:27 +05:30
|
|
|
|
2005-01-12 09:46:22 +05:30
|
|
|
_ext = ['.html','.htm','.php','.php3','.cgi']
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2003-03-23 09:46:29 +05:30
|
|
|
# HtmlLinkDoc
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-01-15 10:55:50 +05:30
|
|
|
class HtmlLinkDoc(HtmlDoc.HtmlDoc):
|
|
|
|
"""
|
2003-08-05 09:30:55 +05:30
|
|
|
Version of the HtmlDoc class that provides the ability to create a link
|
2003-01-15 10:55:50 +05:30
|
|
|
"""
|
2003-06-27 20:06:24 +05:30
|
|
|
def write_linktarget(self,path):
|
|
|
|
self.f.write('<A NAME="%s"></A>' % path)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def start_link(self,path):
|
|
|
|
self.f.write('<A HREF="%s">' % path)
|
|
|
|
|
|
|
|
def end_link(self):
|
|
|
|
self.f.write('</A>')
|
|
|
|
|
|
|
|
def newline(self):
|
|
|
|
self.f.write('<BR>\n')
|
|
|
|
|
2002-12-25 04:06:46 +05:30
|
|
|
def write_raw(self,text):
|
|
|
|
self.f.write(text)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class IndividualPage:
|
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
def __init__(self,db,person,photos,restrict,private,uc,link,places,mini_tree,map,
|
2004-03-11 05:10:13 +05:30
|
|
|
dir_name,imgdir,doc,id,idlink,ext,depth):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.person = person
|
2004-02-14 11:10:30 +05:30
|
|
|
self.db = db
|
2002-10-20 19:55:16 +05:30
|
|
|
self.ext = ext
|
|
|
|
self.doc = doc
|
|
|
|
self.use_id = id
|
|
|
|
self.id_link = idlink
|
2003-11-14 00:48:09 +05:30
|
|
|
self.list = map
|
2002-10-20 19:55:16 +05:30
|
|
|
self.private = private
|
2004-10-08 09:29:55 +05:30
|
|
|
self.alive = Utils.probably_alive(person,db) and restrict
|
2002-10-20 19:55:16 +05:30
|
|
|
self.photos = (photos == 2) or (photos == 1 and not self.alive)
|
|
|
|
self.usecomments = not uc
|
|
|
|
self.dir = dir_name
|
|
|
|
self.link = link
|
2004-08-25 08:32:25 +05:30
|
|
|
self.places = places
|
2003-07-21 05:44:27 +05:30
|
|
|
self.mini_tree = mini_tree
|
2002-10-20 19:55:16 +05:30
|
|
|
self.slist = []
|
|
|
|
self.scnt = 1
|
|
|
|
self.image_dir = imgdir
|
2004-03-11 05:10:13 +05:30
|
|
|
self.depth = depth
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
name = person.get_primary_name().get_regular_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.set_title(_("Summary of %s") % name)
|
2003-10-12 07:59:24 +05:30
|
|
|
self.doc.fix_title()
|
2004-05-07 07:50:39 +05:30
|
|
|
self.sort = Sort.Sort(self.db)
|
2003-10-12 07:59:24 +05:30
|
|
|
|
2004-03-11 09:54:03 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2004-08-25 08:32:25 +05:30
|
|
|
def write_flexible_row(self,label,data,sreflist=None):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.start_row()
|
|
|
|
self.doc.start_cell("NormalCell")
|
|
|
|
self.doc.start_paragraph("Label")
|
|
|
|
self.doc.write_text(label)
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
|
|
|
|
self.doc.start_cell("NormalCell")
|
|
|
|
self.doc.start_paragraph("Data")
|
2004-08-25 08:32:25 +05:30
|
|
|
if len(data) > 0:
|
|
|
|
for part in data:
|
|
|
|
if part[1] != "":
|
|
|
|
self.doc.start_link(part[1])
|
|
|
|
self.doc.write_text(part[0])
|
|
|
|
self.doc.end_link()
|
|
|
|
else:
|
|
|
|
self.doc.write_text(part[0])
|
2002-10-20 19:55:16 +05:30
|
|
|
if sreflist:
|
2003-11-14 00:48:09 +05:30
|
|
|
first = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
for sref in sreflist:
|
2002-12-25 04:06:46 +05:30
|
|
|
self.doc.write_raw('<SUP>')
|
2003-11-14 00:48:09 +05:30
|
|
|
if first:
|
|
|
|
first = 0
|
|
|
|
else:
|
|
|
|
self.doc.write_text(', ')
|
|
|
|
self.doc.start_link("#s%d" % self.scnt)
|
2002-12-25 04:06:46 +05:30
|
|
|
self.doc.write_text('%d' % self.scnt)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_link()
|
2003-11-14 00:48:09 +05:30
|
|
|
self.doc.write_raw('</SUP>')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.scnt = self.scnt + 1
|
|
|
|
self.slist.append(sref)
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
|
2003-10-07 08:42:05 +05:30
|
|
|
#--------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------
|
2004-08-25 08:32:25 +05:30
|
|
|
def write_normal_row(self,label,data,sreflist):
|
|
|
|
val = []
|
|
|
|
val.append((data,""))
|
|
|
|
self.write_flexible_row(label,val,sreflist)
|
2003-10-07 08:42:05 +05:30
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
#--------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
def write_id_row(self,label,data):
|
|
|
|
val = []
|
|
|
|
val.append((data,""))
|
|
|
|
self.write_flexible_row(label,val)
|
2003-10-07 08:42:05 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#--------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
def write_marriage_row(self,list):
|
2004-08-25 08:32:25 +05:30
|
|
|
val = []
|
|
|
|
val.append((list[1],""))
|
|
|
|
self.write_flexible_row(list[0],val)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------
|
2004-07-28 07:59:07 +05:30
|
|
|
def write_link_row(self,title,person_handle):
|
2004-08-25 08:32:25 +05:30
|
|
|
val = []
|
2004-07-28 07:59:07 +05:30
|
|
|
if person_handle:
|
2004-08-07 10:46:57 +05:30
|
|
|
person = self.db.get_person_from_handle(person_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.list.has_key(person_handle):
|
2004-08-25 08:32:25 +05:30
|
|
|
val.append((person.get_primary_name().get_regular_name(),"%s.%s" % (person.get_gramps_id(),self.ext)))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-08-25 08:32:25 +05:30
|
|
|
val.append((person.get_primary_name().get_regular_name(),""))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
self.write_flexible_row(title,val)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def write_sources(self):
|
|
|
|
self.doc.start_paragraph("SourcesTitle")
|
|
|
|
self.doc.write_text(_("Sources"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
index = 1
|
|
|
|
for sref in self.slist:
|
|
|
|
self.doc.start_paragraph("SourceParagraph")
|
2003-06-27 20:06:24 +05:30
|
|
|
self.doc.write_linktarget("s%d" % index)
|
2002-12-25 04:06:46 +05:30
|
|
|
self.doc.write_text('%d. ' % index)
|
2002-10-20 19:55:16 +05:30
|
|
|
index = index + 1
|
2004-07-28 07:59:07 +05:30
|
|
|
base_handle = sref.get_base_handle()
|
2004-08-07 10:46:57 +05:30
|
|
|
base = self.db.get_source_from_handle(base_handle)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_info(base.get_title())
|
|
|
|
self.write_info(base.get_author())
|
|
|
|
self.write_info(base.get_publication_info())
|
2005-03-23 05:29:51 +05:30
|
|
|
self.write_info(DateHandler.displayer.display(sref.get_date_object()))
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_info(sref.get_page())
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.usecomments:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_info(sref.get_text())
|
2005-03-28 10:28:28 +05:30
|
|
|
self.write_info(sref.get_note())
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
def write_info(self,info):
|
|
|
|
"""Writes a line of text, after stripping leading and trailing
|
|
|
|
spaces. If the last character is not a period, the period is
|
|
|
|
appended to produce a sentance"""
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
info = info.strip()
|
2002-10-20 19:55:16 +05:30
|
|
|
if info != "":
|
|
|
|
if info[-1] == '.':
|
|
|
|
self.doc.write_text("%s " % info)
|
|
|
|
else:
|
|
|
|
self.doc.write_text("%s. " % info)
|
|
|
|
|
2003-12-28 04:43:54 +05:30
|
|
|
def write_tree(self,ind_list):
|
2004-07-28 07:59:07 +05:30
|
|
|
if not self.mini_tree or not self.person.get_main_parents_family_handle():
|
2003-12-28 04:43:54 +05:30
|
|
|
return
|
2003-07-21 05:44:27 +05:30
|
|
|
self.doc.start_paragraph("FamilyTitle")
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
self.doc.start_paragraph("Data")
|
|
|
|
self.doc.write_raw('<PRE>\n')
|
2004-03-11 05:10:13 +05:30
|
|
|
tree = MiniTree(self.db,self.person,self.doc,ind_list,self.depth)
|
2003-07-21 05:44:27 +05:30
|
|
|
for line in tree.lines:
|
|
|
|
if line: self.doc.write_raw(line + '\n')
|
|
|
|
self.doc.write_raw('</PRE>\n')
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
2003-12-28 04:43:54 +05:30
|
|
|
def create_page(self,ind_list):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Generate the HTML page for the specific person"""
|
|
|
|
|
2004-08-24 00:10:25 +05:30
|
|
|
filebase = "%s.%s" % (self.person.get_gramps_id(),self.ext)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.open("%s/%s" % (self.dir,filebase))
|
|
|
|
|
2004-02-21 11:41:59 +05:30
|
|
|
media_list = self.person.get_media_list()
|
2004-02-14 11:10:30 +05:30
|
|
|
name_obj = self.person.get_primary_name()
|
|
|
|
name = name_obj.get_regular_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
# Write out the title line.
|
|
|
|
|
|
|
|
self.doc.start_paragraph("Title")
|
|
|
|
self.doc.write_text(_("Summary of %s") % name)
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
# blank line for spacing
|
|
|
|
|
|
|
|
self.doc.start_paragraph("Data")
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
# look for the primary media object if photos have been requested.
|
|
|
|
# make sure that the media object is an image. If so, insert it
|
|
|
|
# into the document.
|
|
|
|
|
2004-02-21 11:41:59 +05:30
|
|
|
if self.photos and len(media_list) > 0:
|
2004-07-28 07:59:07 +05:30
|
|
|
object_handle = media_list[0].get_reference_handle()
|
2004-08-07 10:46:57 +05:30
|
|
|
object = self.db.get_object_from_handle(object_handle)
|
2005-05-24 18:38:06 +05:30
|
|
|
mime_type = object.get_mime_type()
|
|
|
|
if mime_type and mime_type.startswith("image"):
|
2004-03-11 05:10:13 +05:30
|
|
|
src = object.get_path()
|
|
|
|
junk,ext = os.path.splitext(src)
|
2004-08-24 00:10:25 +05:30
|
|
|
base = '%s%s' % (object.get_gramps_id(),ext)
|
2004-03-11 05:10:13 +05:30
|
|
|
|
|
|
|
if os.path.isfile(src):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.start_paragraph("Data")
|
2004-03-11 05:10:13 +05:30
|
|
|
if self.image_dir:
|
|
|
|
self.doc.start_link("%s/%s" % (self.image_dir,base))
|
|
|
|
else:
|
|
|
|
self.doc.start_link("%s" % base)
|
|
|
|
description = object.get_description()
|
|
|
|
self.doc.add_media_object(src,"row",4.0,4.0,description)
|
|
|
|
self.doc.end_link()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
# Start the first table, which consists of basic information, including
|
|
|
|
# name, gender, and parents
|
|
|
|
|
|
|
|
self.doc.start_table("one","IndTable")
|
2004-02-14 11:10:30 +05:30
|
|
|
self.write_normal_row("%s:" % _("Name"), name, name_obj.get_source_references())
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.use_id:
|
|
|
|
if self.id_link:
|
2004-08-24 00:10:25 +05:30
|
|
|
val = '<a href="%s">%s</a>' % (self.id_link,self.person.get_gramps_id())
|
|
|
|
val = val.replace('*',self.person.get_gramps_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-08-24 00:10:25 +05:30
|
|
|
val = self.person.get_gramps_id()
|
2003-10-07 08:42:05 +05:30
|
|
|
self.write_id_row("%s:" % _("ID Number"),val)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-02-01 09:16:29 +05:30
|
|
|
if self.person.get_gender() == RelLib.Person.MALE:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_normal_row("%s:" % _("Gender"), _("Male"),None)
|
2005-02-01 09:16:29 +05:30
|
|
|
elif self.person.get_gender() == RelLib.Person.FEMALE:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_normal_row("%s:" % _("Gender"), _("Female"),None)
|
2003-01-03 08:49:50 +05:30
|
|
|
else:
|
|
|
|
self.write_normal_row("%s:" % _("Gender"), _("Unknown"),None)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
family_handle = self.person.get_main_parents_family_handle()
|
|
|
|
if family_handle:
|
2004-08-20 03:05:16 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
self.write_link_row("%s:" % _("Father"), family.get_father_handle())
|
|
|
|
self.write_link_row("%s:" % _("Mother"), family.get_mother_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
self.write_link_row("%s:" % _("Father"), None)
|
|
|
|
self.write_link_row("%s:" % _("Mother"), None)
|
|
|
|
self.doc.end_table()
|
|
|
|
|
|
|
|
# Another blank line between the tables
|
|
|
|
|
|
|
|
self.doc.start_paragraph("Data")
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
2004-06-29 00:38:15 +05:30
|
|
|
self.write_urls()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_facts()
|
|
|
|
self.write_notes()
|
|
|
|
self.write_families()
|
2004-08-25 08:32:25 +05:30
|
|
|
self.write_sibling()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
# if inclusion of photos has been enabled, write the photo
|
|
|
|
# gallery.
|
|
|
|
|
|
|
|
if self.photos:
|
|
|
|
self.write_gallery()
|
|
|
|
|
|
|
|
# write source information
|
|
|
|
|
|
|
|
if self.scnt > 1:
|
|
|
|
self.write_sources()
|
|
|
|
|
2003-07-21 05:44:27 +05:30
|
|
|
# draw mini-tree
|
2003-12-28 04:43:54 +05:30
|
|
|
self.write_tree(ind_list)
|
2003-07-21 05:44:27 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.link:
|
|
|
|
self.doc.start_paragraph("Data")
|
|
|
|
self.doc.start_link("index.%s" % self.ext)
|
|
|
|
self.doc.write_text(_("Return to the index of people"))
|
|
|
|
self.doc.end_link()
|
2004-08-25 08:32:25 +05:30
|
|
|
if self.places:
|
|
|
|
self.doc.newline()
|
|
|
|
self.doc.start_link("loc.%s" % self.ext)
|
|
|
|
self.doc.write_text(_("Return to the index of places"))
|
|
|
|
self.doc.end_link()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
"""Close the document"""
|
|
|
|
self.doc.close()
|
|
|
|
|
|
|
|
def write_gallery(self):
|
|
|
|
"""Write the image gallery. Add images that are not marked
|
|
|
|
as private, creating a thumbnail and copying the original
|
|
|
|
image to the directory."""
|
|
|
|
|
2004-05-07 07:50:39 +05:30
|
|
|
index = 0
|
2004-02-25 08:55:57 +05:30
|
|
|
for object_ref in self.person.get_media_list():
|
2004-07-28 07:59:07 +05:30
|
|
|
obj_id = object_ref.get_reference_handle()
|
2004-08-07 10:46:57 +05:30
|
|
|
obj = self.db.get_object_from_handle(obj_id)
|
2005-05-24 18:38:06 +05:30
|
|
|
mime_type = obj.get_mime_type()
|
|
|
|
if not mime_type or not mime_type.startswith("image"):
|
2004-05-07 07:50:39 +05:30
|
|
|
continue
|
|
|
|
if object_ref.get_privacy():
|
|
|
|
continue
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
try:
|
2004-03-11 09:01:35 +05:30
|
|
|
src = obj.get_path()
|
2004-01-17 12:21:49 +05:30
|
|
|
junk,ext = os.path.splitext(src)
|
2004-08-24 00:10:25 +05:30
|
|
|
base = '%s%s' % (obj.get_gramps_id(),ext)
|
2004-01-17 12:21:49 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.image_dir:
|
2003-06-04 02:48:23 +05:30
|
|
|
shutil.copyfile(src,"%s/%s/%s" % (self.dir,self.image_dir,base))
|
|
|
|
try:
|
|
|
|
shutil.copystat(src,"%s/%s/%s" % (self.dir,self.image_dir,base))
|
|
|
|
except:
|
|
|
|
pass
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-06-04 02:48:23 +05:30
|
|
|
shutil.copyfile(src,"%s/%s" % (self.dir,base))
|
|
|
|
try:
|
|
|
|
shutil.copystat(src,"%s/%s" % (self.dir,base))
|
|
|
|
except:
|
|
|
|
pass
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-03-11 05:10:13 +05:30
|
|
|
# First image should not appear in the gallery, but needs
|
|
|
|
# the source to be linked to, hence the copy-only.
|
|
|
|
if index == 0:
|
|
|
|
index = 1
|
|
|
|
continue
|
2004-05-07 07:50:39 +05:30
|
|
|
elif index == 1:
|
|
|
|
# If there's a second image then we need to start out
|
|
|
|
# Gallery section and the table
|
|
|
|
self.doc.start_paragraph("Data")
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
self.doc.start_paragraph("GalleryTitle")
|
|
|
|
self.doc.write_text(_("Gallery"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
self.doc.start_table("gallery","IndTable")
|
|
|
|
index = 2
|
2004-03-11 05:10:13 +05:30
|
|
|
|
2004-03-11 09:01:35 +05:30
|
|
|
description = obj.get_description()
|
2004-03-11 05:10:13 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.start_row()
|
|
|
|
self.doc.start_cell("ImageCell")
|
|
|
|
self.doc.start_paragraph("Data")
|
|
|
|
if self.image_dir:
|
|
|
|
self.doc.start_link("%s/%s" % (self.image_dir,base))
|
|
|
|
else:
|
|
|
|
self.doc.start_link("%s" % base)
|
2004-03-11 05:10:13 +05:30
|
|
|
self.doc.add_media_object(src,"row",1.5,1.5,description)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_link()
|
|
|
|
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.start_cell("NoteCell")
|
2004-05-07 07:50:39 +05:30
|
|
|
if description:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.start_paragraph("PhotoDescription")
|
|
|
|
self.doc.write_text(description)
|
|
|
|
self.doc.end_paragraph()
|
2004-05-07 07:50:39 +05:30
|
|
|
if obj.get_note():
|
2004-02-14 11:10:30 +05:30
|
|
|
self.doc.write_note(obj.get_note(),obj.get_note_format(),"PhotoNote")
|
2004-05-07 07:50:39 +05:30
|
|
|
elif object_ref.get_note():
|
|
|
|
self.doc.write_note(object_ref.get_note(),object_ref.get_note_format(),"PhotoNote")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
except IOError:
|
|
|
|
pass
|
2004-05-07 07:50:39 +05:30
|
|
|
if index == 2:
|
|
|
|
self.doc.end_table()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------
|
2004-06-29 00:38:15 +05:30
|
|
|
def write_urls(self):
|
|
|
|
|
|
|
|
first = 1
|
|
|
|
|
|
|
|
for url in self.person.get_url_list():
|
|
|
|
if url.get_privacy() and self.private:
|
|
|
|
continue
|
|
|
|
|
|
|
|
if first:
|
|
|
|
first = 0
|
|
|
|
self.doc.start_paragraph("UrlTitle")
|
|
|
|
self.doc.write_text(_("Links"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.start_paragraph("UrlList")
|
|
|
|
|
|
|
|
self.doc.start_link(url.get_path())
|
|
|
|
self.doc.write_text(url.get_description())
|
|
|
|
self.doc.end_link()
|
|
|
|
self.doc.newline()
|
|
|
|
|
|
|
|
if not first:
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def write_facts(self):
|
|
|
|
|
|
|
|
if self.alive:
|
|
|
|
return
|
|
|
|
count = 0
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
event_handle_list = [ self.person.get_birth_handle(), self.person.get_death_handle() ]
|
|
|
|
event_handle_list = event_handle_list + self.person.get_event_list()
|
|
|
|
event_handle_list.sort(self.sort.by_date)
|
|
|
|
for event_handle in event_handle_list:
|
|
|
|
if not event_handle:
|
2004-03-11 09:54:03 +05:30
|
|
|
continue
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
event = self.db.get_event_from_handle(event_handle)
|
2004-02-14 11:10:30 +05:30
|
|
|
if event.get_privacy():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-02-14 11:10:30 +05:30
|
|
|
name = _(event.get_name())
|
2004-10-03 04:37:43 +05:30
|
|
|
date_text = event.get_date()
|
2004-02-14 11:10:30 +05:30
|
|
|
descr = event.get_description()
|
2004-07-28 07:59:07 +05:30
|
|
|
place_handle = event.get_place_handle()
|
2004-08-25 08:32:25 +05:30
|
|
|
place_url = ""
|
2004-07-28 07:59:07 +05:30
|
|
|
if place_handle:
|
2004-08-07 10:46:57 +05:30
|
|
|
place = self.db.get_place_from_handle(place_handle).get_title()
|
2004-08-25 08:32:25 +05:30
|
|
|
if self.places:
|
|
|
|
place_gramps_id = self.db.get_place_from_handle(place_handle).get_gramps_id()
|
|
|
|
place_url = "loc.%s#%s" % (self.ext, place_gramps_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
else:
|
|
|
|
place = ""
|
|
|
|
srcref = event.get_source_references()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-10-03 04:37:43 +05:30
|
|
|
if date_text == "" and descr == "" and place == "" and len(srcref) == 0:
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
if count == 0:
|
|
|
|
self.doc.start_paragraph("EventsTitle")
|
|
|
|
self.doc.write_text(_("Facts and Events"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.start_table("two","IndTable")
|
|
|
|
count = 1
|
|
|
|
|
|
|
|
if place != "" and place[-1] == ".":
|
|
|
|
place = place[0:-1]
|
|
|
|
if descr != "" and descr[-1] == ".":
|
|
|
|
descr = descr[0:-1]
|
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
val = []
|
|
|
|
|
2004-10-03 04:37:43 +05:30
|
|
|
if date_text != "":
|
2002-10-20 19:55:16 +05:30
|
|
|
if place != "":
|
2004-10-03 04:37:43 +05:30
|
|
|
val.append(("%s, " % date_text,""))
|
2004-08-25 08:32:25 +05:30
|
|
|
val.append((place,place_url))
|
|
|
|
val.append((".",""))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-10-03 04:37:43 +05:30
|
|
|
val.append(("%s." % date_text,""))
|
2002-10-20 19:55:16 +05:30
|
|
|
elif place != "":
|
2004-08-25 08:32:25 +05:30
|
|
|
val.append((place,place_url))
|
|
|
|
val.append((".",""))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if descr != "":
|
2004-08-25 08:32:25 +05:30
|
|
|
val.append(("%s." % descr,""))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
self.write_flexible_row(name, val, srcref)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if count != 0:
|
|
|
|
self.doc.end_table()
|
|
|
|
|
|
|
|
def write_notes(self):
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.person.get_note() == "" or self.alive:
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
|
|
|
|
|
|
|
self.doc.start_paragraph("NotesTitle")
|
|
|
|
self.doc.write_text(_("Notes"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.doc.write_note(self.person.get_note(),self.person.get_note_format(),"NotesParagraph")
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def write_fam_fact(self,event):
|
|
|
|
|
|
|
|
if event == None:
|
|
|
|
return
|
2004-02-14 11:10:30 +05:30
|
|
|
name = _(event.get_name())
|
2004-10-03 04:37:43 +05:30
|
|
|
date_text = event.get_date()
|
2004-07-28 07:59:07 +05:30
|
|
|
place_handle = event.get_place_handle()
|
2004-08-25 08:32:25 +05:30
|
|
|
place_url = ""
|
2004-07-28 07:59:07 +05:30
|
|
|
if place_handle:
|
2004-08-07 10:46:57 +05:30
|
|
|
place = self.db.get_place_from_handle(place_handle).get_title()
|
2004-08-25 08:32:25 +05:30
|
|
|
if self.places:
|
|
|
|
place_gramps_id = self.db.get_place_from_handle(place_handle).get_gramps_id()
|
|
|
|
place_url = "loc.%s#%s" % (self.ext, place_gramps_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
else:
|
|
|
|
place = ""
|
|
|
|
descr = event.get_description()
|
2002-10-20 19:55:16 +05:30
|
|
|
if descr != "" and descr[-1] == ".":
|
|
|
|
descr = descr[0:-1]
|
|
|
|
if place != "" and place[-1] == ".":
|
|
|
|
place = place[0:-1]
|
|
|
|
|
2004-10-03 04:37:43 +05:30
|
|
|
if date_text == "" and place == "" and descr == "":
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
val = []
|
2004-10-03 04:37:43 +05:30
|
|
|
if date_text == "":
|
2002-10-20 19:55:16 +05:30
|
|
|
if place == "":
|
2004-08-25 08:32:25 +05:30
|
|
|
if descr != "":
|
|
|
|
val.append(("%s." % descr,""))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
if descr == "":
|
2004-08-25 08:32:25 +05:30
|
|
|
val.append((place,place_url))
|
|
|
|
val.append((".",""))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-08-25 08:32:25 +05:30
|
|
|
val.append((place,place_url))
|
|
|
|
val.append((".",""))
|
|
|
|
val.append(("%s." % descr,""))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
if place == "":
|
|
|
|
if descr == "":
|
2004-10-03 04:37:43 +05:30
|
|
|
val.append(("%s." % date_text,""))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-10-03 04:37:43 +05:30
|
|
|
val.append(("%s. %s." % (date_text,descr),""))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
if descr == "":
|
2004-10-03 04:37:43 +05:30
|
|
|
val.append(("%s, " % date_text,""))
|
2004-08-25 08:32:25 +05:30
|
|
|
val.append((place,place_url))
|
|
|
|
val.append((".",""))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-10-03 04:37:43 +05:30
|
|
|
val.append(("%s, " % date_text,""))
|
2004-08-25 08:32:25 +05:30
|
|
|
val.append((place,place_url))
|
|
|
|
val.append((".",""))
|
|
|
|
val.append(("%s." % descr,""))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
self.write_flexible_row(name, val)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def write_families(self):
|
2004-07-28 07:59:07 +05:30
|
|
|
if len(self.person.get_family_handle_list()) == 0:
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
|
|
|
|
|
|
|
self.doc.start_paragraph("FamilyTitle")
|
|
|
|
self.doc.write_text(_("Marriages/Children"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
self.doc.start_table("three","IndTable")
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for family_handle in self.person.get_family_handle_list():
|
2004-08-20 03:05:16 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.person.get_handle() == family.get_father_handle():
|
|
|
|
spouse_id = family.get_mother_handle()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
spouse_id = family.get_father_handle()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.start_row()
|
|
|
|
self.doc.start_cell("NormalCell",2)
|
|
|
|
self.doc.start_paragraph("Spouse")
|
2004-02-14 11:10:30 +05:30
|
|
|
if spouse_id:
|
2004-08-07 10:46:57 +05:30
|
|
|
spouse = self.db.get_person_from_handle(spouse_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.list.has_key(spouse_id):
|
2004-08-24 00:10:25 +05:30
|
|
|
self.doc.start_link("%s.%s" % (spouse.get_gramps_id(),self.ext))
|
2004-02-14 11:10:30 +05:30
|
|
|
self.doc.write_text(spouse.get_primary_name().get_regular_name())
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_link()
|
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.doc.write_text(spouse.get_primary_name().get_regular_name())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
self.doc.write_text(_("unknown"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
|
|
|
|
if not self.alive:
|
2004-07-28 07:59:07 +05:30
|
|
|
for event_handle in family.get_event_list():
|
|
|
|
if event_handle:
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
event = self.db.get_event_from_handle(event_handle)
|
2004-03-11 09:54:03 +05:30
|
|
|
if event.get_privacy() == 0:
|
|
|
|
self.write_fam_fact(event)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
child_list = family.get_child_handle_list()
|
2002-10-20 19:55:16 +05:30
|
|
|
if len(child_list) > 0:
|
|
|
|
|
|
|
|
self.doc.start_row()
|
|
|
|
self.doc.start_cell("NormalCell")
|
|
|
|
self.doc.start_paragraph("Label")
|
|
|
|
self.doc.write_text(_("Children"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
|
|
|
|
self.doc.start_cell("NormalCell")
|
|
|
|
self.doc.start_paragraph("Data")
|
|
|
|
|
|
|
|
first = 1
|
2004-07-28 07:59:07 +05:30
|
|
|
for child_handle in family.get_child_handle_list():
|
2004-08-07 10:46:57 +05:30
|
|
|
child = self.db.get_person_from_handle(child_handle)
|
2004-02-14 11:10:30 +05:30
|
|
|
name = child.get_primary_name().get_regular_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
if first == 1:
|
|
|
|
first = 0
|
|
|
|
else:
|
|
|
|
self.doc.write_text('\n')
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.list.has_key(child_handle):
|
2004-08-24 00:10:25 +05:30
|
|
|
self.doc.start_link("%s.%s" % (child.get_gramps_id(),self.ext))
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(name)
|
|
|
|
self.doc.end_link()
|
|
|
|
else:
|
|
|
|
self.doc.write_text(name)
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
self.doc.end_table()
|
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
def write_sibling(self):
|
|
|
|
if len(self.person.get_parent_family_handle_list()) == 0:
|
|
|
|
return
|
|
|
|
|
|
|
|
"""collect all siblings into an array"""
|
|
|
|
all_sisters = []
|
|
|
|
for (family_handle,mrel,frel) in self.person.get_parent_family_handle_list():
|
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
|
|
|
if len( family.get_child_handle_list() ) > 0:
|
|
|
|
for child_handle in family.get_child_handle_list():
|
|
|
|
all_sisters.append(child_handle)
|
|
|
|
|
|
|
|
"""if more than one person_handle exists, the person has siblings"""
|
|
|
|
if len(all_sisters) > 1:
|
|
|
|
self.doc.start_paragraph("SiblingsTitle")
|
|
|
|
self.doc.write_text(_("Siblings"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
2005-07-09 01:54:54 +05:30
|
|
|
self.doc.start_table("four","IndTable")
|
|
|
|
self.doc.start_row()
|
|
|
|
self.doc.start_cell("NormalCell")
|
|
|
|
self.doc.start_paragraph("Label")
|
|
|
|
self.doc.write_text(_("Siblings"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
|
|
|
|
self.doc.start_cell("NormalCell")
|
|
|
|
first = True
|
2004-08-25 08:32:25 +05:30
|
|
|
for child_handle in all_sisters:
|
|
|
|
child = self.db.get_person_from_handle(child_handle)
|
|
|
|
name = child.get_primary_name().get_regular_name()
|
2005-07-09 01:54:54 +05:30
|
|
|
if first:
|
|
|
|
self.doc.start_paragraph("Data")
|
|
|
|
first = False
|
|
|
|
else:
|
|
|
|
self.doc.write_text('\n')
|
2004-08-25 08:32:25 +05:30
|
|
|
if self.person.get_handle() == child_handle:
|
|
|
|
self.doc.write_text(name)
|
|
|
|
elif self.list.has_key(child_handle):
|
|
|
|
self.doc.start_link("%s.%s" % (child.get_gramps_id(),self.ext))
|
|
|
|
self.doc.write_text(name)
|
|
|
|
self.doc.end_link()
|
|
|
|
else:
|
|
|
|
self.doc.write_text(name)
|
2005-07-09 01:54:54 +05:30
|
|
|
if not first:
|
2004-08-25 08:32:25 +05:30
|
|
|
self.doc.end_paragraph()
|
2005-07-09 01:54:54 +05:30
|
|
|
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
self.doc.end_table()
|
2004-08-25 08:32:25 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2003-01-15 10:55:50 +05:30
|
|
|
# WebReport
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-01-15 10:55:50 +05:30
|
|
|
class WebReport(Report.Report):
|
2005-01-07 10:23:43 +05:30
|
|
|
def __init__(self,database,person,options_class):
|
|
|
|
"""
|
|
|
|
Creates WebReport object that produces the report.
|
|
|
|
|
|
|
|
The arguments are:
|
|
|
|
|
|
|
|
database - the GRAMPS database instance
|
|
|
|
person - currently selected person
|
|
|
|
options_class - instance of the Options class for this report
|
|
|
|
|
|
|
|
This report needs the following parameters (class variables)
|
|
|
|
that come in the options class.
|
|
|
|
|
|
|
|
filter
|
|
|
|
od
|
|
|
|
HTMLimg
|
|
|
|
HTMLrestrictinfo
|
|
|
|
HTMLincpriv
|
|
|
|
HTMLnotxtsi
|
|
|
|
HTMLlnktoalphabet
|
|
|
|
HTMLsplita
|
|
|
|
HTMLplaceidx
|
|
|
|
HTMLshorttree
|
|
|
|
HTMLidxcol
|
|
|
|
HTMLimagedir
|
|
|
|
HTMLincid
|
|
|
|
HTMLidurl
|
|
|
|
HTMLlinktidx
|
|
|
|
HTMLext
|
|
|
|
HTMLtreed
|
|
|
|
HTMLidxt
|
|
|
|
HTMLgendex
|
|
|
|
HTMLidxbirth
|
|
|
|
yearso
|
|
|
|
"""
|
|
|
|
# self,db,person,target_path,max_gen,photos,filter,restrict,
|
|
|
|
# private, srccomments, include_link, include_mini_tree,
|
|
|
|
# style, image_dir, template_name,use_id,id_link,gendex,places,ext,
|
|
|
|
# include_alpha_links,separate_alpha,n_cols,ind_template_name,
|
|
|
|
# depth,birth_dates,year_only):
|
|
|
|
self.database = database
|
|
|
|
self.start_person = person
|
|
|
|
self.options_class = options_class
|
|
|
|
|
|
|
|
filter_num = options_class.get_filter_number()
|
|
|
|
filters = options_class.get_report_filters(person)
|
|
|
|
filters.extend(GenericFilter.CustomFilters.get_filters())
|
|
|
|
self.filter = filters[filter_num]
|
|
|
|
|
|
|
|
default_style = BaseDoc.StyleSheet()
|
|
|
|
self.options_class.make_default_style(default_style)
|
|
|
|
style_file = self.options_class.handler.get_stylesheet_savefile()
|
|
|
|
style_list = BaseDoc.StyleSheetList(style_file,default_style)
|
|
|
|
style_name = self.options_class.handler.get_default_stylesheet_name()
|
|
|
|
self.selected_style = style_list.get_style_sheet(style_name)
|
|
|
|
|
|
|
|
self.template_name = options_class.handler.template_name
|
|
|
|
|
|
|
|
self.target_path = options_class.handler.options_dict['HTMLod']
|
|
|
|
self.ext = options_class.handler.options_dict['HTMLext']
|
|
|
|
self.use_id = options_class.handler.options_dict['HTMLincid']
|
|
|
|
self.id_link = options_class.handler.options_dict['HTMLlinktidx']
|
|
|
|
self.photos = options_class.handler.options_dict['HTMLimg']
|
|
|
|
self.restrict = options_class.handler.options_dict['HTMLrestrictinfo']
|
|
|
|
self.private = options_class.handler.options_dict['HTMLincpriv']
|
|
|
|
self.srccomments = options_class.handler.options_dict['HTMLcmtxtsi']
|
|
|
|
self.include_link = options_class.handler.options_dict['HTMLlinktidx']
|
|
|
|
self.include_mini_tree = options_class.handler.options_dict['HTMLshorttree']
|
|
|
|
self.image_dir = options_class.handler.options_dict['HTMLimagedir']
|
|
|
|
self.use_gendex = options_class.handler.options_dict['HTMLgendex']
|
|
|
|
self.use_places = options_class.handler.options_dict['HTMLplaceidx']
|
|
|
|
self.include_alpha_links = options_class.handler.options_dict['HTMLlnktoalphabet']
|
|
|
|
self.separate_alpha = options_class.handler.options_dict['HTMLsplita']
|
|
|
|
self.n_cols = options_class.handler.options_dict['HTMLidxcol']
|
|
|
|
self.ind_template_name = options_class.handler.options_dict['HTMLidxt']
|
|
|
|
self.depth = options_class.handler.options_dict['HTMLtreed']
|
|
|
|
self.birth_dates = options_class.handler.options_dict['HTMLidxbirth']
|
|
|
|
self.year_only = options_class.handler.options_dict['HTMLyearso']
|
|
|
|
self.sort = Sort.Sort(self.database)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def get_progressbar_data(self):
|
2004-12-09 04:24:26 +05:30
|
|
|
return (_("Generate HTML reports - GRAMPS"),
|
|
|
|
'<span size="larger" weight="bold">%s</span>' %
|
|
|
|
_("Creating Web Pages"))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
def dump_gendex(self,person_handle_list,html_dir):
|
2002-10-20 19:55:16 +05:30
|
|
|
fname = "%s/gendex.txt" % html_dir
|
|
|
|
try:
|
|
|
|
f = open(fname,"w")
|
|
|
|
except:
|
|
|
|
return
|
2004-07-28 07:59:07 +05:30
|
|
|
for p_id in person_handle_list:
|
2005-01-07 10:23:43 +05:30
|
|
|
p = self.database.get_person_from_handle(p_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
name = p.get_primary_name()
|
|
|
|
firstName = name.get_first_name()
|
|
|
|
surName = name.get_surname()
|
|
|
|
suffix = name.get_suffix()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-04-16 17:46:56 +05:30
|
|
|
f.write("%s.%s|" % (p.get_gramps_id(),self.ext))
|
2002-10-20 19:55:16 +05:30
|
|
|
f.write("%s|" % surName)
|
|
|
|
if suffix == "":
|
|
|
|
f.write("%s /%s/|" % (firstName,surName))
|
|
|
|
else:
|
|
|
|
f.write("%s /%s/, %s|" % (firstName,surName, suffix))
|
2004-07-28 07:59:07 +05:30
|
|
|
for e_id in [p.get_birth_handle(),p.get_death_handle()]:
|
2004-03-11 09:01:35 +05:30
|
|
|
if e_id:
|
2005-01-07 10:23:43 +05:30
|
|
|
e = self.database.get_event_from_handle(e_id)
|
2004-03-11 09:01:35 +05:30
|
|
|
else:
|
2005-04-16 17:46:56 +05:30
|
|
|
e = None
|
2002-10-20 19:55:16 +05:30
|
|
|
if e:
|
2005-04-16 17:46:56 +05:30
|
|
|
f.write("%s|" % DateHandler.displayer.display(e.get_date_object()))
|
2004-07-28 07:59:07 +05:30
|
|
|
if e.get_place_handle():
|
2005-01-07 10:23:43 +05:30
|
|
|
f.write('%s|' % self.database.get_place_from_handle(e.get_place_handle()).get_title())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
f.write('|')
|
|
|
|
else:
|
|
|
|
f.write('||')
|
|
|
|
f.write('\n')
|
|
|
|
f.close()
|
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
def dump_places(self,person_handle_list,styles,template,html_dir):
|
|
|
|
"""Writes an index file, listing all places and the referenced persons."""
|
|
|
|
|
|
|
|
doc = HtmlLinkDoc(self.selected_style,None,template,None)
|
|
|
|
doc.set_extension(self.ext)
|
|
|
|
doc.set_title(_("Place Index"))
|
|
|
|
|
|
|
|
doc.open("%s/loc.%s" % (html_dir,self.ext))
|
|
|
|
doc.start_paragraph("Title")
|
|
|
|
doc.write_text(_("Place Index"))
|
|
|
|
doc.end_paragraph()
|
|
|
|
|
|
|
|
used_places = {}
|
|
|
|
for person_handle in person_handle_list:
|
2005-01-07 10:23:43 +05:30
|
|
|
person = self.database.get_person_from_handle(person_handle)
|
2004-08-25 08:32:25 +05:30
|
|
|
for event_handle in [person.get_birth_handle(), person.get_death_handle()] + person.get_event_list():
|
2005-01-07 10:23:43 +05:30
|
|
|
event = self.database.get_event_from_handle(event_handle)
|
2004-08-25 08:32:25 +05:30
|
|
|
if event:
|
|
|
|
if event.get_place_handle() not in used_places:
|
|
|
|
used_places[event.get_place_handle()] = []
|
|
|
|
used_places[event.get_place_handle()].append((person_handle, event.get_name()))
|
|
|
|
for family_handle in person.get_family_handle_list():
|
2005-01-07 10:23:43 +05:30
|
|
|
family = self.database.get_family_from_handle(family_handle)
|
2004-08-25 08:32:25 +05:30
|
|
|
for event_handle in family.get_event_list():
|
2005-01-07 10:23:43 +05:30
|
|
|
event = self.database.get_event_from_handle(event_handle)
|
2004-08-25 08:32:25 +05:30
|
|
|
if event:
|
|
|
|
if event.get_place_handle() not in used_places:
|
|
|
|
used_places[event.get_place_handle()] = []
|
|
|
|
used_places[event.get_place_handle()].append((person_handle, event.get_name()))
|
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
for key in self.database.get_place_handles():
|
2004-08-25 08:32:25 +05:30
|
|
|
if key in used_places:
|
2005-01-07 10:23:43 +05:30
|
|
|
myplace = self.database.get_place_from_handle(key)
|
2004-08-25 08:32:25 +05:30
|
|
|
doc.start_paragraph("IndexLabel")
|
|
|
|
doc.write_linktarget(myplace.get_gramps_id())
|
|
|
|
doc.write_text(myplace.get_title())
|
|
|
|
doc.end_paragraph()
|
|
|
|
|
|
|
|
for match in used_places[key]:
|
|
|
|
person_handle = match[0]
|
|
|
|
event_name = match[1]
|
2005-01-07 10:23:43 +05:30
|
|
|
person = self.database.get_person_from_handle(person_handle)
|
2004-08-25 08:32:25 +05:30
|
|
|
name = person.get_primary_name().get_name()
|
|
|
|
|
|
|
|
if self.birth_dates:
|
2005-01-07 10:23:43 +05:30
|
|
|
birth_handle = self.database.get_person_from_handle(person_handle).get_birth_handle()
|
2004-08-25 08:32:25 +05:30
|
|
|
if birth_handle:
|
2005-01-07 10:23:43 +05:30
|
|
|
birth_event = self.database.get_event_from_handle(birth_handle)
|
2004-08-25 08:32:25 +05:30
|
|
|
if self.year_only:
|
|
|
|
birth_dobj = birth_event.get_date_object()
|
|
|
|
if birth_dobj.get_year_valid():
|
|
|
|
birth_date = birth_dobj.get_year()
|
|
|
|
else:
|
|
|
|
birth_date = ""
|
|
|
|
else:
|
|
|
|
birth_date = birth_event.get_date()
|
|
|
|
else:
|
|
|
|
birth_date = ""
|
|
|
|
doc.start_link("%s.%s" % (person.get_gramps_id(),self.ext))
|
|
|
|
doc.write_text(name)
|
|
|
|
if self.birth_dates and birth_date:
|
|
|
|
doc.write_text(' (%s %s)' % (_BORN,birth_date))
|
|
|
|
doc.end_link()
|
|
|
|
doc.write_text(' (%s)' % _(event_name))
|
|
|
|
doc.newline()
|
|
|
|
|
|
|
|
|
|
|
|
if self.include_link:
|
|
|
|
doc.start_paragraph("Data")
|
|
|
|
doc.start_link("index.%s" % self.ext)
|
|
|
|
doc.write_text(_("Return to the index of people"))
|
|
|
|
doc.end_link()
|
|
|
|
doc.end_paragraph()
|
|
|
|
doc.close()
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
def dump_index(self,person_handle_list,styles,template,html_dir):
|
2004-03-11 05:10:13 +05:30
|
|
|
"""Writes an index file, listing all people in the person list."""
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
doc = HtmlLinkDoc(self.selected_style,None,template,None)
|
|
|
|
doc.set_extension(self.ext)
|
|
|
|
doc.set_title(_("Family Tree Index"))
|
|
|
|
|
|
|
|
doc.open("%s/index.%s" % (html_dir,self.ext))
|
|
|
|
doc.start_paragraph("Title")
|
|
|
|
doc.write_text(_("Family Tree Index"))
|
|
|
|
doc.end_paragraph()
|
|
|
|
|
|
|
|
a = {}
|
2004-07-28 07:59:07 +05:30
|
|
|
for person_handle in person_handle_list:
|
2005-01-07 10:23:43 +05:30
|
|
|
person = self.database.get_person_from_handle(person_handle)
|
2004-02-14 11:10:30 +05:30
|
|
|
n = person.get_primary_name().get_surname()
|
2002-10-20 19:55:16 +05:30
|
|
|
if n:
|
|
|
|
a[n[0]] = 1
|
|
|
|
else:
|
|
|
|
a[''] = 1
|
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
section_number = 1
|
|
|
|
link_keys = a.keys()
|
2005-06-05 09:31:56 +05:30
|
|
|
link_keys.sort(locale.strcoll)
|
2004-02-15 08:54:12 +05:30
|
|
|
for n in link_keys:
|
|
|
|
a[n] = section_number
|
|
|
|
section_number = section_number + 1
|
|
|
|
|
|
|
|
if self.include_alpha_links:
|
|
|
|
doc.start_paragraph('IndexLabelLinks')
|
|
|
|
if self.separate_alpha:
|
|
|
|
link_str = "index_%%03d.%s" % self.ext
|
|
|
|
else:
|
|
|
|
link_str = "#%03d"
|
|
|
|
for n in link_keys:
|
|
|
|
doc.start_link(link_str % a[n])
|
|
|
|
doc.write_text(n)
|
|
|
|
doc.end_link()
|
|
|
|
doc.write_text(' ')
|
|
|
|
doc.end_paragraph()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
if self.separate_alpha:
|
|
|
|
doc.close()
|
|
|
|
for n in link_keys:
|
2004-07-28 07:59:07 +05:30
|
|
|
p_id_list = [ p_id for p_id in person_handle_list if \
|
2005-01-07 10:23:43 +05:30
|
|
|
(self.database.get_person_from_handle(p_id).get_primary_name().get_surname() \
|
|
|
|
and (self.database.get_person_from_handle(p_id).get_primary_name().get_surname()[0] == n) ) ]
|
2005-06-05 09:31:56 +05:30
|
|
|
p_id_list.sort(self.sort.by_sorted_name)
|
2004-02-15 08:54:12 +05:30
|
|
|
doc = HtmlLinkDoc(self.selected_style,None,template,None)
|
|
|
|
doc.set_extension(self.ext)
|
|
|
|
doc.set_title(_("Section %s") % n)
|
|
|
|
|
|
|
|
doc.open("%s/index_%03d.%s" % (html_dir,a[n],self.ext))
|
|
|
|
doc.start_paragraph("Title")
|
|
|
|
doc.write_text(_("Section %s") % n)
|
2002-10-20 19:55:16 +05:30
|
|
|
doc.end_paragraph()
|
2004-02-15 08:54:12 +05:30
|
|
|
|
2004-05-24 10:02:19 +05:30
|
|
|
n_rows = len(p_id_list)/self.n_cols
|
2004-02-15 08:54:12 +05:30
|
|
|
td_width = 100/self.n_cols
|
|
|
|
|
|
|
|
doc.write_raw('<table width="100%" border="0">')
|
|
|
|
doc.write_raw('<tr><td width="%d%%" valign="top">' % td_width)
|
|
|
|
col_len = n_rows
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for person_handle in p_id_list:
|
2005-01-07 10:23:43 +05:30
|
|
|
the_person = self.database.get_person_from_handle(person_handle)
|
2005-06-05 09:31:56 +05:30
|
|
|
name = _nd.sorted(the_person)
|
2004-03-17 08:34:10 +05:30
|
|
|
|
|
|
|
if self.birth_dates:
|
2005-01-07 10:23:43 +05:30
|
|
|
birth_handle = self.database.get_person_from_handle(person_handle).get_birth_handle()
|
2004-07-28 07:59:07 +05:30
|
|
|
if birth_handle:
|
2005-01-07 10:23:43 +05:30
|
|
|
birth_event = self.database.get_event_from_handle(birth_handle)
|
2004-03-17 08:34:10 +05:30
|
|
|
if self.year_only:
|
|
|
|
birth_dobj = birth_event.get_date_object()
|
|
|
|
if birth_dobj.get_year_valid():
|
|
|
|
birth_date = birth_dobj.get_year()
|
|
|
|
else:
|
|
|
|
birth_date = ""
|
|
|
|
else:
|
|
|
|
birth_date = birth_event.get_date()
|
|
|
|
else:
|
|
|
|
birth_date = ""
|
2004-02-15 08:54:12 +05:30
|
|
|
|
2004-08-24 00:10:25 +05:30
|
|
|
doc.start_link("%s.%s" % (the_person.get_gramps_id(),self.ext))
|
2004-02-15 08:54:12 +05:30
|
|
|
doc.write_text(name)
|
2004-03-17 08:34:10 +05:30
|
|
|
if self.birth_dates and birth_date:
|
|
|
|
doc.write_text(' (%s %s)' % (_BORN,birth_date))
|
2004-02-15 08:54:12 +05:30
|
|
|
doc.end_link()
|
|
|
|
|
|
|
|
if col_len <= 0:
|
|
|
|
doc.write_raw('</td><td width="%d%%" valign="top">' % td_width)
|
|
|
|
col_len = n_rows
|
|
|
|
else:
|
|
|
|
doc.newline()
|
|
|
|
col_len = col_len - 1
|
|
|
|
doc.write_raw('</td></tr></table>')
|
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
n_rows = len(person_handle_list) + len(link_keys)
|
2004-02-15 08:54:12 +05:30
|
|
|
n_rows = n_rows/self.n_cols
|
|
|
|
td_width = 100/self.n_cols
|
|
|
|
|
|
|
|
doc.write_raw('<table width="100%" border="0">')
|
|
|
|
doc.write_raw('<tr><td width="%d%%" valign="top">' % td_width)
|
|
|
|
col_len = n_rows
|
|
|
|
for n in link_keys:
|
2004-07-28 07:59:07 +05:30
|
|
|
p_id_list = [ p_id for p_id in person_handle_list if \
|
2005-01-07 10:23:43 +05:30
|
|
|
(self.database.get_person_from_handle(p_id).get_primary_name().get_surname() \
|
|
|
|
and (self.database.get_person_from_handle(p_id).get_primary_name().get_surname()[0] == n) ) ]
|
2005-06-05 09:31:56 +05:30
|
|
|
p_id_list.sort(self.sort.by_sorted_name)
|
2002-10-20 19:55:16 +05:30
|
|
|
doc.start_paragraph('IndexLabel')
|
2004-02-15 08:54:12 +05:30
|
|
|
if self.include_alpha_links:
|
|
|
|
doc.write_linktarget("%03d" % a[n])
|
|
|
|
doc.write_text(n)
|
2004-02-15 09:18:45 +05:30
|
|
|
doc.end_paragraph()
|
2004-02-15 08:54:12 +05:30
|
|
|
col_len = col_len - 1
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for person_handle in p_id_list:
|
2005-01-07 10:23:43 +05:30
|
|
|
the_person = self.database.get_person_from_handle(person_handle)
|
2005-06-05 09:31:56 +05:30
|
|
|
name = _nd.sorted(the_person)
|
2004-02-15 08:54:12 +05:30
|
|
|
|
2004-03-17 08:34:10 +05:30
|
|
|
if self.birth_dates:
|
2005-01-07 10:23:43 +05:30
|
|
|
birth_handle = self.database.get_person_from_handle(person_handle).get_birth_handle()
|
2004-07-28 07:59:07 +05:30
|
|
|
if birth_handle:
|
2005-01-07 10:23:43 +05:30
|
|
|
birth_event = self.database.get_event_from_handle(birth_handle)
|
2004-03-17 08:34:10 +05:30
|
|
|
if self.year_only:
|
|
|
|
birth_dobj = birth_event.get_date_object()
|
|
|
|
if birth_dobj.get_year_valid():
|
|
|
|
birth_date = birth_dobj.get_year()
|
|
|
|
else:
|
|
|
|
birth_date = ""
|
|
|
|
else:
|
|
|
|
birth_date = birth_event.get_date()
|
|
|
|
else:
|
|
|
|
birth_date = ""
|
|
|
|
|
2004-08-24 00:10:25 +05:30
|
|
|
doc.start_link("%s.%s" % (the_person.get_gramps_id(),self.ext))
|
2004-02-15 08:54:12 +05:30
|
|
|
doc.write_text(name)
|
2004-03-17 08:34:10 +05:30
|
|
|
if self.birth_dates and birth_date:
|
|
|
|
doc.write_text(' (%s %s)' % (_BORN,birth_date))
|
2004-02-15 08:54:12 +05:30
|
|
|
doc.end_link()
|
|
|
|
if col_len <= 0:
|
|
|
|
doc.write_raw('</td><td width="%d%%" valign="top">' % td_width)
|
|
|
|
doc.start_paragraph('IndexLabel')
|
|
|
|
doc.write_text(_("%s (continued)") % n)
|
|
|
|
doc.end_paragraph()
|
|
|
|
col_len = n_rows
|
|
|
|
else:
|
|
|
|
doc.newline()
|
|
|
|
col_len = col_len - 1
|
|
|
|
doc.write_raw('</td></tr></table>')
|
2004-08-25 08:32:25 +05:30
|
|
|
if self.include_link and self.use_places:
|
|
|
|
doc.start_paragraph("Data")
|
|
|
|
doc.start_link("loc.%s" % self.ext)
|
|
|
|
doc.write_text(_("Return to the index of places"))
|
|
|
|
doc.end_link()
|
|
|
|
doc.end_paragraph()
|
|
|
|
doc.close()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def write_report(self):
|
|
|
|
dir_name = self.target_path
|
2005-07-09 01:54:54 +05:30
|
|
|
if not dir_name:
|
2002-10-20 19:55:16 +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):
|
2003-01-15 10:55:50 +05:30
|
|
|
ErrorDialog(_("Neither %s nor %s are directories") % \
|
|
|
|
(dir_name,parent_dir))
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
os.mkdir(dir_name)
|
|
|
|
except IOError, value:
|
2003-07-17 08:07:28 +05:30
|
|
|
ErrorDialog(_("Could not create the directory: %s") % \
|
2003-01-15 10:55:50 +05:30
|
|
|
dir_name + "\n" + value[1])
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
|
|
|
except:
|
2003-07-17 08:07:28 +05:30
|
|
|
ErrorDialog(_("Could not create the directory: %s") % \
|
2003-01-15 10:55:50 +05:30
|
|
|
dir_name)
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
|
|
|
|
|
|
|
if self.image_dir:
|
|
|
|
image_dir_name = os.path.join(dir_name, self.image_dir)
|
|
|
|
else:
|
|
|
|
image_dir_name = dir_name
|
|
|
|
if not os.path.isdir(image_dir_name) and self.photos != 0:
|
|
|
|
try:
|
|
|
|
os.mkdir(image_dir_name)
|
|
|
|
except IOError, value:
|
2003-07-17 08:07:28 +05:30
|
|
|
ErrorDialog(_("Could not create the directory: %s") % \
|
2002-10-20 19:55:16 +05:30
|
|
|
image_dir_name + "\n" + value[1])
|
|
|
|
return
|
|
|
|
except:
|
2003-07-17 08:07:28 +05:30
|
|
|
ErrorDialog(_("Could not create the directory: %s") % \
|
2002-10-20 19:55:16 +05:30
|
|
|
image_dir_name)
|
|
|
|
return
|
2005-04-13 23:46:20 +05:30
|
|
|
|
|
|
|
ind_list = self.database.get_person_handles(sort_handles=False)
|
|
|
|
ind_list = self.filter.apply(self.database,ind_list)
|
2004-08-25 08:32:25 +05:30
|
|
|
progress_steps = len(ind_list)
|
|
|
|
if len(ind_list) > 1:
|
|
|
|
progress_steps = progress_steps+1
|
|
|
|
if self.use_gendex == 1:
|
|
|
|
progress_steps = progress_steps+1
|
|
|
|
if self.use_places == 1:
|
|
|
|
progress_steps = progress_steps+1
|
|
|
|
self.progress_bar_setup(float(progress_steps))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
doc = HtmlLinkDoc(self.selected_style,None,self.template_name,None)
|
|
|
|
doc.set_extension(self.ext)
|
|
|
|
doc.set_image_dir(self.image_dir)
|
|
|
|
|
|
|
|
self.add_styles(doc)
|
|
|
|
doc.build_style_declaration()
|
|
|
|
|
|
|
|
my_map = {}
|
|
|
|
for l in ind_list:
|
2004-03-11 09:01:35 +05:30
|
|
|
my_map[l] = l
|
2004-07-28 07:59:07 +05:30
|
|
|
for person_handle in ind_list:
|
2005-01-07 10:23:43 +05:30
|
|
|
person = self.database.get_person_from_handle(person_handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
tdoc = HtmlLinkDoc(self.selected_style,None,None,None,doc)
|
|
|
|
tdoc.set_extension(self.ext)
|
2004-02-14 11:10:30 +05:30
|
|
|
tdoc.set_keywords([person.get_primary_name().get_surname(),
|
|
|
|
person.get_primary_name().get_regular_name()])
|
2005-01-07 10:23:43 +05:30
|
|
|
idoc = IndividualPage(self.database,person, self.photos, self.restrict,
|
2002-10-20 19:55:16 +05:30
|
|
|
self.private, self.srccomments,
|
2004-08-25 08:32:25 +05:30
|
|
|
self.include_link, self.use_places,
|
|
|
|
self.include_mini_tree, my_map, dir_name,
|
|
|
|
self.image_dir, tdoc, self.use_id,
|
|
|
|
self.id_link, self.ext, self.depth)
|
2003-12-28 04:43:54 +05:30
|
|
|
idoc.create_page(my_map)
|
2002-10-20 19:55:16 +05:30
|
|
|
idoc.close()
|
|
|
|
self.progress_bar_step()
|
2002-11-28 11:22:02 +05:30
|
|
|
while gtk.events_pending():
|
2005-04-13 23:46:20 +05:30
|
|
|
gtk.main_iteration()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if len(ind_list) > 1:
|
|
|
|
self.dump_index(ind_list,self.selected_style,
|
2004-02-15 08:54:12 +05:30
|
|
|
self.ind_template_name,dir_name)
|
2004-08-25 08:32:25 +05:30
|
|
|
self.progress_bar_step()
|
|
|
|
while gtk.events_pending():
|
2005-04-13 23:46:20 +05:30
|
|
|
gtk.main_iteration()
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.use_gendex == 1:
|
|
|
|
self.dump_gendex(ind_list,dir_name)
|
2004-08-25 08:32:25 +05:30
|
|
|
self.progress_bar_step()
|
|
|
|
while gtk.events_pending():
|
2005-04-13 23:46:20 +05:30
|
|
|
gtk.main_iteration()
|
2004-08-25 08:32:25 +05:30
|
|
|
if self.use_places == 1:
|
|
|
|
self.dump_places(ind_list,self.selected_style,
|
|
|
|
self.ind_template_name,dir_name)
|
|
|
|
self.progress_bar_step()
|
|
|
|
while gtk.events_pending():
|
2005-04-13 23:46:20 +05:30
|
|
|
gtk.main_iteration()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.progress_bar_done()
|
|
|
|
|
|
|
|
def add_styles(self,doc):
|
2003-09-02 06:17:09 +05:30
|
|
|
tbl = BaseDoc.TableStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
tbl.set_width(100)
|
|
|
|
tbl.set_column_widths([15,85])
|
|
|
|
doc.add_table_style("IndTable",tbl)
|
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
cell = BaseDoc.TableCellStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
doc.add_cell_style("NormalCell",cell)
|
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
cell = BaseDoc.TableCellStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
cell.set_padding(0.2)
|
|
|
|
doc.add_cell_style("ImageCell",cell)
|
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
cell = BaseDoc.TableCellStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
cell.set_padding(0.2)
|
|
|
|
doc.add_cell_style("NoteCell",cell)
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-01-07 10:23:43 +05:30
|
|
|
class WebReportOptions(ReportOptions.ReportOptions):
|
2003-10-31 06:50:58 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
2003-10-31 06:50:58 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
def __init__(self,name,person_id=None):
|
|
|
|
ReportOptions.ReportOptions.__init__(self,name,person_id)
|
|
|
|
|
|
|
|
def set_new_options(self):
|
|
|
|
# Options specific for this report
|
|
|
|
self.options_dict = {
|
|
|
|
'HTMLod' : '',
|
|
|
|
'HTMLimg' : 2,
|
|
|
|
'HTMLrestrictinfo' : 0,
|
|
|
|
'HTMLincpriv' : 0,
|
|
|
|
'HTMLcmtxtsi' : 0,
|
|
|
|
'HTMLlnktoalphabet' : 0,
|
|
|
|
'HTMLsplita' : 0,
|
|
|
|
'HTMLshorttree' : 1,
|
|
|
|
'HTMLimagedir' : 'images',
|
|
|
|
'HTMLincid' : 0,
|
|
|
|
'HTMLidurl' : '',
|
|
|
|
'HTMLlinktidx' : 1,
|
|
|
|
'HTMLext' : 'html',
|
|
|
|
'HTMLtreed' : 3,
|
|
|
|
'HTMLidxt' : '',
|
|
|
|
'HTMLidxcol' : 2,
|
|
|
|
'HTMLgendex' : 0,
|
|
|
|
'HTMLidxbirth' : 0,
|
|
|
|
'HTMLplaceidx' : 0,
|
|
|
|
'HTMLyearso' : 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
self.options_help = {
|
2005-08-18 11:28:28 +05:30
|
|
|
'HTMLod' : ("=str","Output directory for the web site",
|
|
|
|
"/full/name/of/the/dir"),
|
|
|
|
'HTMLimg' : ("=num","Inclusion of images",
|
|
|
|
["No images at all",
|
|
|
|
"No images for living people",
|
|
|
|
"Images for all people"], True
|
|
|
|
),
|
|
|
|
'HTMLrestrictinfo' : ("=0/1",
|
|
|
|
"Restrict information on living people",
|
|
|
|
["Do not restrict", "Restrict"], True),
|
|
|
|
'HTMLincpriv' : ("=0/1","Inclusion of people marked private",
|
|
|
|
["Do not include","Include"], True),
|
|
|
|
'HTMLcmtxtsi' : ("=0/1","Inclusion of comments and text "
|
|
|
|
"in source information",
|
|
|
|
["Do not include","Include"], True),
|
|
|
|
'HTMLlnktoalphabet' : ("=0/1","Include links to alphabetical "
|
|
|
|
"sections in index page",
|
|
|
|
["Do not include","Include"], True),
|
|
|
|
'HTMLsplita' : ("=0/1","Split alphabetical sections "
|
|
|
|
"to different pages",
|
|
|
|
["Do not split sections","Split sections"],
|
|
|
|
True),
|
|
|
|
'HTMLshorttree' : ("=0/1","Include short ancestor tree",
|
|
|
|
["Do not include","Include"], True),
|
|
|
|
'HTMLimagedir' : ("=str","Image subdirectory",
|
|
|
|
"image_subdir_name"),
|
|
|
|
'HTMLincid' : ("=0/1","Include GRAMPS ID in the report",
|
|
|
|
["Do not include","Include"], True),
|
|
|
|
'HTMLidurl' : ("=str","URL for links from GRAMPS IDs",
|
|
|
|
"the_url_value"),
|
|
|
|
'HTMLlinktidx' : ("=0/1","Include links to the index page",
|
|
|
|
["Do not include","Include"], True),
|
|
|
|
'HTMLext' : ("=str","Extension for generated files",
|
|
|
|
"Any extension you like: html, htm, "
|
|
|
|
"php, asp, etc."),
|
|
|
|
'HTMLtreed' : ("=num","Depth of ancestor tree",
|
|
|
|
"Any integer number"),
|
|
|
|
'HTMLidxt' : ("=str","Template name for the index page",
|
|
|
|
"/full/path/to/the/tpkg"),
|
|
|
|
'HTMLidxcol' : ("=num",
|
|
|
|
"Number of columns in the index page",
|
|
|
|
"Any integer number"),
|
|
|
|
'HTMLgendex' : ("=0/1","Create a GENDEX index",
|
|
|
|
["Do not create","Create"], True),
|
|
|
|
'HTMLidxbirth' : ("=0/1","Append birth dates to the names "
|
|
|
|
"on the index page",
|
|
|
|
["Do not append","Append"], True),
|
|
|
|
'HTMLplaceidx' : ("=0/1","Create an index of all Places",
|
|
|
|
["Do not create","Create"], True),
|
|
|
|
'HTMLyearso' : ("=0/1","Use only birth year "
|
|
|
|
"on the index page",
|
|
|
|
["Use full date","Use just year"], True),
|
2005-01-07 10:23:43 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
def enable_options(self):
|
|
|
|
# Semi-common options that should be enabled for this report
|
|
|
|
self.enable_dict = {
|
|
|
|
'filter' : 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
def get_report_filters(self,person):
|
|
|
|
"""Set up the list of possible content filters."""
|
|
|
|
if person:
|
|
|
|
name = person.get_primary_name().get_name()
|
2005-07-09 01:54:54 +05:30
|
|
|
gramps_id = person.get_gramps_id()
|
2005-01-07 10:23:43 +05:30
|
|
|
else:
|
|
|
|
name = 'PERSON'
|
2005-07-09 01:54:54 +05:30
|
|
|
gramps_id = ''
|
2005-01-07 10:23:43 +05:30
|
|
|
|
|
|
|
all = GenericFilter.GenericFilter()
|
|
|
|
all.set_name(_("Entire Database"))
|
|
|
|
all.add_rule(GenericFilter.Everyone([]))
|
|
|
|
|
|
|
|
des = GenericFilter.GenericFilter()
|
|
|
|
des.set_name(_("Descendants of %s") % name)
|
2005-07-09 01:54:54 +05:30
|
|
|
des.add_rule(GenericFilter.IsDescendantOf([gramps_id,1]))
|
2005-01-07 10:23:43 +05:30
|
|
|
|
|
|
|
df = GenericFilter.GenericFilter()
|
|
|
|
df.set_name(_("Descendant Families of %s") % name)
|
2005-07-09 01:54:54 +05:30
|
|
|
df.add_rule(GenericFilter.IsDescendantFamilyOf([gramps_id]))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
ans = GenericFilter.GenericFilter()
|
|
|
|
ans.set_name(_("Ancestors of %s") % name)
|
2005-07-09 01:54:54 +05:30
|
|
|
ans.add_rule(GenericFilter.IsAncestorOf([gramps_id,1]))
|
2005-01-07 10:23:43 +05:30
|
|
|
|
|
|
|
com = GenericFilter.GenericFilter()
|
|
|
|
com.set_name(_("People with common ancestor with %s") % name)
|
2005-07-09 01:54:54 +05:30
|
|
|
com.add_rule(GenericFilter.HasCommonAncestorWith([gramps_id]))
|
2005-01-07 10:23:43 +05:30
|
|
|
|
|
|
|
return [all,des,df,ans,com]
|
|
|
|
|
|
|
|
def add_user_options(self,dialog):
|
2002-10-20 19:55:16 +05:30
|
|
|
lnk_msg = _("Include a link to the index page")
|
|
|
|
priv_msg = _("Do not include records marked private")
|
|
|
|
restrict_msg = _("Restrict information on living people")
|
|
|
|
no_img_msg = _("Do not use images")
|
|
|
|
no_limg_msg = _("Do not use images for living people")
|
|
|
|
no_com_msg = _("Do not include comments and text in source information")
|
|
|
|
include_id_msg = _("Include the GRAMPS ID in the report")
|
|
|
|
gendex_msg = _("Create a GENDEX index")
|
2004-08-25 08:32:25 +05:30
|
|
|
places_msg = _("Create an index of all Places")
|
2002-10-20 19:55:16 +05:30
|
|
|
imgdir_msg = _("Image subdirectory")
|
2004-03-11 05:10:13 +05:30
|
|
|
depth_msg = _("Ancestor tree depth")
|
2002-10-20 19:55:16 +05:30
|
|
|
ext_msg = _("File extension")
|
2004-02-15 08:54:12 +05:30
|
|
|
alpha_links_msg = _("Links to alphabetical sections in index page")
|
|
|
|
sep_alpha_msg = _("Split alphabetical sections to separate pages")
|
2004-03-17 08:34:10 +05:30
|
|
|
birth_date_msg = _("Append birth dates to the names")
|
|
|
|
year_only_msg = _("Use only year of birth")
|
2003-07-21 05:44:27 +05:30
|
|
|
tree_msg = _("Include short ancestor tree")
|
2005-01-07 10:23:43 +05:30
|
|
|
|
2003-07-21 05:44:27 +05:30
|
|
|
self.mini_tree = gtk.CheckButton(tree_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.mini_tree.set_active(self.options_dict['HTMLshorttree'])
|
|
|
|
|
2004-03-11 05:10:13 +05:30
|
|
|
self.depth = gtk.SpinButton()
|
|
|
|
self.depth.set_digits(0)
|
|
|
|
self.depth.set_increments(1,2)
|
|
|
|
self.depth.set_range(1,10)
|
2005-02-24 05:55:34 +05:30
|
|
|
self.depth.set_numeric(True)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.depth.set_value(self.options_dict['HTMLtreed'])
|
2003-07-21 05:44:27 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.use_link = gtk.CheckButton(lnk_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.use_link.set_active(self.options_dict['HTMLlinktidx'])
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.no_private = gtk.CheckButton(priv_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.no_private.set_active(not self.options_dict['HTMLincpriv'])
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.restrict_living = gtk.CheckButton(restrict_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.restrict_living.set_active(self.options_dict['HTMLrestrictinfo'])
|
|
|
|
|
|
|
|
# FIXME: document this:
|
|
|
|
# 0 -- no images of any kind
|
|
|
|
# 1 -- no living images, but some images
|
|
|
|
# 2 -- any images
|
|
|
|
images = self.options_dict['HTMLimg']
|
2002-10-20 19:55:16 +05:30
|
|
|
self.no_images = gtk.CheckButton(no_img_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.no_images.set_active(not images)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.no_living_images = gtk.CheckButton(no_limg_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.no_living_images.set_sensitive(not images)
|
|
|
|
self.no_living_images.set_active(images in (0,1))
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.no_comments = gtk.CheckButton(no_com_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.no_comments.set_active(not self.options_dict['HTMLcmtxtsi'])
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.include_id = gtk.CheckButton(include_id_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.include_id.set_active(self.options_dict['HTMLincid'])
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.gendex = gtk.CheckButton(gendex_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.gendex.set_active(self.options_dict['HTMLgendex'])
|
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
self.places = gtk.CheckButton(places_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.places.set_active(self.options_dict['HTMLplaceidx'])
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.imgdir = gtk.Entry()
|
2005-01-07 10:23:43 +05:30
|
|
|
self.imgdir.set_text(self.options_dict['HTMLimagedir'])
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.linkpath = gtk.Entry()
|
2005-01-07 10:23:43 +05:30
|
|
|
self.linkpath.set_sensitive(self.options_dict['HTMLincid'])
|
|
|
|
self.linkpath.set_text(self.options_dict['HTMLidurl'])
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.include_id.connect('toggled',self.show_link)
|
2005-01-12 09:46:22 +05:30
|
|
|
|
|
|
|
the_ext = self.options_dict['HTMLext']
|
|
|
|
self.ext = gtk.combo_box_new_text()
|
|
|
|
index = 0
|
|
|
|
active_index = 0
|
|
|
|
for item in _ext:
|
|
|
|
self.ext.append_text(item)
|
|
|
|
if item == the_ext:
|
|
|
|
active_index = index
|
|
|
|
index = index + 1
|
|
|
|
self.ext.set_active(active_index)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
self.use_alpha_links = gtk.CheckButton(alpha_links_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.use_alpha_links.set_active(self.options_dict['HTMLlnktoalphabet'])
|
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
self.use_sep_alpha = gtk.CheckButton(sep_alpha_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.use_sep_alpha.set_sensitive(self.options_dict['HTMLlnktoalphabet'])
|
|
|
|
self.use_sep_alpha.set_active(self.options_dict['HTMLsplita'])
|
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
self.use_n_cols = gtk.SpinButton()
|
|
|
|
self.use_n_cols.set_digits(0)
|
|
|
|
self.use_n_cols.set_increments(1,2)
|
|
|
|
self.use_n_cols.set_range(1,5)
|
2005-02-24 05:55:34 +05:30
|
|
|
self.use_n_cols.set_numeric(True)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.use_n_cols.set_value(self.options_dict['HTMLidxcol'])
|
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
tlist = Report._template_map.keys()
|
|
|
|
tlist.sort()
|
2005-01-12 09:46:22 +05:30
|
|
|
|
|
|
|
ind_template_name = self.options_dict['HTMLidxt']
|
|
|
|
self.ind_template = gtk.combo_box_new_text()
|
|
|
|
self.ind_template.append_text(Report._default_template)
|
|
|
|
template_index = 1
|
|
|
|
active_index = 0
|
2004-02-15 08:54:12 +05:30
|
|
|
for template in tlist:
|
|
|
|
if template != Report._user_template:
|
2005-01-12 09:46:22 +05:30
|
|
|
self.ind_template.append_text(template)
|
|
|
|
if Report._template_map[template] == ind_template_name:
|
|
|
|
active_index = template_index
|
2005-01-13 23:51:04 +05:30
|
|
|
template_index = template_index + 1
|
2005-01-12 09:46:22 +05:30
|
|
|
self.ind_template.append_text(Report._user_template)
|
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
self.ind_user_template = gnome.ui.FileEntry("HTML_Template",_("Choose File"))
|
2005-01-12 09:46:22 +05:30
|
|
|
if ind_template_name and not active_index:
|
|
|
|
active_index = template_index
|
|
|
|
user_template = ind_template_name
|
|
|
|
self.ind_user_template.set_sensitive(1)
|
|
|
|
else:
|
|
|
|
user_template = ''
|
|
|
|
self.ind_user_template.set_sensitive(0)
|
|
|
|
|
|
|
|
if os.path.isfile(user_template):
|
|
|
|
self.ind_user_template.set_filename(user_template)
|
|
|
|
self.ind_user_template.set_modal(True)
|
|
|
|
self.ind_template.set_active(active_index)
|
2005-01-07 10:23:43 +05:30
|
|
|
|
2004-03-17 08:34:10 +05:30
|
|
|
self.add_birth_date = gtk.CheckButton(birth_date_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.add_birth_date.set_active(self.options_dict['HTMLidxbirth'])
|
|
|
|
|
2004-03-17 08:34:10 +05:30
|
|
|
self.use_year_only = gtk.CheckButton(year_only_msg)
|
2005-01-07 10:23:43 +05:30
|
|
|
self.use_year_only.set_active(self.options_dict['HTMLyearso'])
|
|
|
|
self.use_year_only.set_sensitive(self.options_dict['HTMLidxbirth'])
|
2004-03-17 08:34:10 +05:30
|
|
|
|
|
|
|
self.add_birth_date.connect('toggled',self.on_birth_date_toggled)
|
2004-02-15 08:54:12 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
dialog.add_option(imgdir_msg,self.imgdir)
|
|
|
|
dialog.add_option('',self.mini_tree)
|
|
|
|
dialog.add_option(depth_msg,self.depth)
|
|
|
|
dialog.add_option('',self.use_link)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-03-11 05:10:13 +05:30
|
|
|
self.mini_tree.connect('toggled',self.on_mini_tree_toggled)
|
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
self.use_alpha_links.connect('toggled',self.on_use_alpha_links_toggled)
|
2005-01-12 09:46:22 +05:30
|
|
|
self.ind_template.connect('changed',self.ind_template_changed)
|
2004-02-15 08:54:12 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
title = _("Privacy")
|
2005-01-07 10:23:43 +05:30
|
|
|
dialog.add_frame_option(title,None,self.no_private)
|
|
|
|
dialog.add_frame_option(title,None,self.restrict_living)
|
|
|
|
dialog.add_frame_option(title,None,self.no_images)
|
|
|
|
dialog.add_frame_option(title,None,self.no_living_images)
|
|
|
|
dialog.add_frame_option(title,None,self.no_comments)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
title = _('Index page')
|
2005-01-07 10:23:43 +05:30
|
|
|
dialog.add_frame_option(title,_('Template'),self.ind_template)
|
|
|
|
dialog.add_frame_option(title,_("User Template"),self.ind_user_template)
|
|
|
|
dialog.add_frame_option(title,None,self.use_alpha_links)
|
|
|
|
dialog.add_frame_option(title,None,self.use_sep_alpha)
|
|
|
|
dialog.add_frame_option(title,_('Number of columns'),self.use_n_cols)
|
|
|
|
dialog.add_frame_option(title,None,self.add_birth_date)
|
|
|
|
dialog.add_frame_option(title,None,self.use_year_only)
|
2004-02-15 08:54:12 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
title = _('Advanced')
|
2005-01-07 10:23:43 +05:30
|
|
|
dialog.add_frame_option(title,'',self.include_id)
|
|
|
|
dialog.add_frame_option(title,_('GRAMPS ID link URL'),self.linkpath)
|
|
|
|
dialog.add_frame_option(title,'',self.gendex)
|
|
|
|
dialog.add_frame_option(title,'',self.places)
|
|
|
|
dialog.add_frame_option(title,ext_msg,self.ext)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.no_images.connect('toggled',self.on_nophotos_toggled)
|
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
def parse_user_options(self,dialog):
|
|
|
|
"""Parse the privacy options frame of the dialog. Save the
|
|
|
|
user selected choices for later use."""
|
|
|
|
|
|
|
|
self.options_dict['HTMLrestrictinfo'] = int(self.restrict_living.get_active())
|
|
|
|
self.options_dict['HTMLincpriv'] = int(not self.no_private.get_active())
|
|
|
|
self.options_dict['HTMLimagedir'] = unicode(self.imgdir.get_text())
|
|
|
|
self.options_dict['HTMLshorttree'] = int(self.mini_tree.get_active())
|
|
|
|
self.options_dict['HTMLtreed'] = self.depth.get_value_as_int()
|
|
|
|
self.options_dict['HTMLlinktidx'] = int(self.use_link.get_active())
|
|
|
|
|
2005-01-12 09:46:22 +05:30
|
|
|
html_ext = _ext[self.ext.get_active()]
|
2005-01-07 10:23:43 +05:30
|
|
|
if html_ext[0] == '.':
|
|
|
|
html_ext = html_ext[1:]
|
|
|
|
self.options_dict['HTMLext'] = html_ext
|
|
|
|
|
|
|
|
self.options_dict['HTMLincid'] = int(self.include_id.get_active())
|
|
|
|
self.options_dict['HTMLgendex'] = int(self.gendex.get_active())
|
|
|
|
self.options_dict['HTMLplaceidx'] = int(self.places.get_active())
|
|
|
|
self.options_dict['HTMLidurl'] = unicode(self.linkpath.get_text().strip())
|
|
|
|
|
|
|
|
self.options_dict['HTMLcmtxtsi'] = int(not self.no_comments.get_active())
|
|
|
|
if self.no_images.get_active():
|
|
|
|
photos = 0
|
|
|
|
elif self.no_living_images.get_active():
|
|
|
|
photos = 1
|
|
|
|
else:
|
|
|
|
photos = 2
|
|
|
|
self.options_dict['HTMLimg'] = photos
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-12 09:46:22 +05:30
|
|
|
active = self.ind_template.get_active()
|
|
|
|
text = unicode(self.ind_template.get_model()[active][0])
|
2005-01-07 10:23:43 +05:30
|
|
|
if Report._template_map.has_key(text):
|
|
|
|
if text == Report._user_template:
|
2005-01-12 09:46:22 +05:30
|
|
|
ind_template_name = self.ind_user_template.get_full_path(0)
|
2005-01-07 10:23:43 +05:30
|
|
|
else:
|
|
|
|
ind_template_name = "%s/%s" % (const.template_dir,Report._template_map[text])
|
|
|
|
else:
|
2005-01-12 09:46:22 +05:30
|
|
|
ind_template_name = ""
|
2005-01-07 10:23:43 +05:30
|
|
|
self.options_dict['HTMLidxt'] = ind_template_name
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
self.options_dict['HTMLlnktoalphabet'] = int(self.use_alpha_links.get_active())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
if self.options_dict['HTMLlnktoalphabet']:
|
|
|
|
separate_alpha = int(self.use_sep_alpha.get_active())
|
|
|
|
else:
|
|
|
|
separate_alpha = 0
|
|
|
|
self.options_dict['HTMLsplita'] = int(separate_alpha)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
self.options_dict['HTMLidxcol'] = self.use_n_cols.get_value_as_int()
|
|
|
|
self.options_dict['HTMLidxbirth'] = int(self.add_birth_date.get_active())
|
|
|
|
self.options_dict['HTMLyearso'] = int(self.use_year_only.get_active())
|
|
|
|
self.options_dict['HTMLod'] = dialog.target_path
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Callback functions from the dialog
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def show_link(self,obj):
|
|
|
|
self.linkpath.set_sensitive(obj.get_active())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
def on_nophotos_toggled(self,obj):
|
|
|
|
"""Keep the 'restrict photos' checkbox in line with the 'no
|
|
|
|
photos' checkbox. If there are no photos included, it makes
|
|
|
|
no sense to worry about restricting which photos are included,
|
|
|
|
now does it?"""
|
|
|
|
self.no_living_images.set_sensitive(not obj.get_active())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
def on_use_alpha_links_toggled(self,obj):
|
|
|
|
"""Keep the 'split alpha sections to separate pages' checkbox in
|
|
|
|
line with the 'use alpha links' checkbox. If there are no alpha
|
|
|
|
links included, it makes no sense to worry about splitting or not
|
|
|
|
the alpha link target to separate pages."""
|
|
|
|
self.use_sep_alpha.set_sensitive(obj.get_active())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
def on_mini_tree_toggled(self,obj):
|
|
|
|
"""Keep the 'Mini tree depth' spin button in line with
|
|
|
|
the 'include short tree' checkbox. If there is no mini tree included,
|
|
|
|
it makes no sense to worry about its depth."""
|
|
|
|
self.depth.set_sensitive(obj.get_active())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
def ind_template_changed(self,obj):
|
2005-01-12 09:46:22 +05:30
|
|
|
active = obj.get_active()
|
|
|
|
text = unicode(obj.get_model()[active][0])
|
2005-01-07 10:23:43 +05:30
|
|
|
if Report._template_map.has_key(text):
|
|
|
|
if Report._template_map[text]:
|
|
|
|
self.ind_user_template.set_sensitive(0)
|
|
|
|
else:
|
|
|
|
self.ind_user_template.set_sensitive(1)
|
|
|
|
else:
|
|
|
|
self.ind_user_template.set_sensitive(0)
|
|
|
|
|
|
|
|
def on_birth_date_toggled(self,obj):
|
|
|
|
"""Keep the 'User year only' check button in line with
|
|
|
|
the 'Add birth date' checkbox. If no mini birth date is added
|
|
|
|
then it makes no sense to worry about its format."""
|
|
|
|
self.use_year_only.set_sensitive(obj.get_active())
|
|
|
|
|
|
|
|
def make_default_style(self,default_style):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Make the default output style for the Web Pages Report."""
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1, face=BaseDoc.FONT_SANS_SERIF, size=16)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
|
|
|
p.set(align=BaseDoc.PARA_ALIGN_CENTER,font=font)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the title of the page."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("Title",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=12,italic=1)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set(font=font,bborder=1)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the header that identifies "
|
|
|
|
"facts and events."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("EventsTitle",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=12,italic=1)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set(font=font,bborder=1)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the header for the notes section."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("NotesTitle",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(face=BaseDoc.FONT_SANS_SERIF,size=10)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
|
|
|
p.set(font=font,align=BaseDoc.PARA_ALIGN_CENTER)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the copyright notice."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("Copyright",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=12,italic=1)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set(font=font,bborder=1)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the header for the sources section."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("SourcesTitle",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set(font=font)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used on the index page that labels each section."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("IndexLabel",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-15 08:54:12 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
|
|
|
p.set(font=font,align=BaseDoc.PARA_ALIGN_CENTER)
|
|
|
|
p.set_description(_("The style used on the index page that labels links to each section."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("IndexLabelLinks",p)
|
2004-02-15 08:54:12 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=12,italic=1)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set(font=font,bborder=1)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the header for the image section."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("GalleryTitle",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=12,italic=1)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
|
|
|
p.set(font=font,bborder=1)
|
|
|
|
p.set_description(_("The style used for the header for the siblings section."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("SiblingsTitle",p)
|
2004-08-25 08:32:25 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=12,italic=1)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set(font=font,bborder=1)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the header for the marriages "
|
|
|
|
"and children section."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("FamilyTitle",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=12)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set_font(font)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the spouse's name."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("Spouse",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
font.set(size=12,italic=1)
|
2003-09-02 06:17:09 +05:30
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set_font(font)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the general data labels."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("Label",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
font.set_size(12)
|
2003-09-02 06:17:09 +05:30
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set_font(font)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the general data."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("Data",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=12)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set_font(font)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the description of images."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("PhotoDescription",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
font.set(size=12)
|
2003-09-02 06:17:09 +05:30
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set_font(font)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the notes associated with images."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("PhotoNote",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
font.set_size(10)
|
2003-09-02 06:17:09 +05:30
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set_font(font)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the source information."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("SourceParagraph",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
font.set_size(12)
|
2003-09-02 06:17:09 +05:30
|
|
|
p = BaseDoc.ParagraphStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
p.set_font(font)
|
2003-03-08 10:33:18 +05:30
|
|
|
p.set_description(_("The style used for the note information."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("NotesParagraph",p)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-06-29 00:38:15 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=12,italic=1)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
|
|
|
p.set(font=font,bborder=1)
|
|
|
|
p.set_description(_("The style used for the header for the URL section."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("UrlTitle",p)
|
2004-06-29 00:38:15 +05:30
|
|
|
|
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set_size(12)
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
|
|
|
p.set_font(font)
|
|
|
|
p.set_description(_("The style used for the URL information."))
|
2005-01-07 10:23:43 +05:30
|
|
|
default_style.add_style("UrlList",p)
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class WebReportDialog(Report.ReportDialog):
|
|
|
|
|
|
|
|
def __init__(self,database,person):
|
|
|
|
self.database = database
|
|
|
|
self.person = person
|
|
|
|
name = "webpage"
|
|
|
|
translated_name = _("Generate Web Site")
|
|
|
|
self.options_class = WebReportOptions(name)
|
2005-12-06 12:08:09 +05:30
|
|
|
self.category = Report.CATEGORY_WEB
|
2005-01-07 10:23:43 +05:30
|
|
|
Report.ReportDialog.__init__(self,database,person,self.options_class,
|
|
|
|
name,translated_name)
|
|
|
|
|
|
|
|
response = self.window.run()
|
2005-04-13 23:46:20 +05:30
|
|
|
if response == gtk.RESPONSE_OK:
|
2005-01-07 10:23:43 +05:30
|
|
|
try:
|
|
|
|
self.make_report()
|
|
|
|
except (IOError,OSError),msg:
|
|
|
|
ErrorDialog(str(msg))
|
|
|
|
self.window.destroy()
|
|
|
|
|
|
|
|
def get_title(self):
|
|
|
|
"""The window title for this dialog"""
|
|
|
|
return "%s - %s - GRAMPS" % (_("Generate Web Site"),_("Web Page"))
|
|
|
|
|
|
|
|
def get_target_browser_title(self):
|
|
|
|
"""The title of the window created when the 'browse' button is
|
|
|
|
clicked in the 'Save As' frame."""
|
|
|
|
return _("Target Directory")
|
|
|
|
|
|
|
|
def get_target_is_directory(self):
|
|
|
|
"""This report creates a directory full of files, not a single file."""
|
|
|
|
return 1
|
|
|
|
|
|
|
|
def get_default_directory(self):
|
|
|
|
"""Get the name of the directory to which the target dialog
|
|
|
|
box should default. This value can be set in the preferences
|
|
|
|
panel."""
|
|
|
|
return self.options_class.handler.options_dict['HTMLod']
|
2004-06-29 00:38:15 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def make_document(self):
|
|
|
|
"""Do Nothing. This document will be created in the
|
|
|
|
make_report routine."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def setup_format_frame(self):
|
|
|
|
"""Do nothing, since we don't want a format frame (HTML only)"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def setup_post_process(self):
|
|
|
|
"""The format frame is not used in this dialog. Hide it, and
|
|
|
|
set the output notebook to always display the html template
|
|
|
|
page."""
|
2003-01-19 12:16:45 +05:30
|
|
|
self.output_notebook.set_current_page(1)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def parse_format_frame(self):
|
|
|
|
"""The format frame is not used in this dialog."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def make_report(self):
|
|
|
|
"""Create the object that will produce the web pages."""
|
2003-05-23 09:38:03 +05:30
|
|
|
|
|
|
|
try:
|
2005-01-07 10:23:43 +05:30
|
|
|
MyReport = WebReport(self.database,self.person,self.options_class)
|
|
|
|
"""
|
|
|
|
self.target_path,
|
2003-05-23 09:38:03 +05:30
|
|
|
self.max_gen, self.photos, self.filter,
|
|
|
|
self.restrict, self.private, self.srccomments,
|
2003-07-21 05:44:27 +05:30
|
|
|
self.include_link, self.include_mini_tree,
|
|
|
|
self.selected_style,
|
2003-05-23 09:38:03 +05:30
|
|
|
self.img_dir_text,self.template_name,
|
2004-08-25 08:32:25 +05:30
|
|
|
self.use_id,self.id_link,self.use_gendex,self.use_places,
|
2004-02-15 08:54:12 +05:30
|
|
|
self.html_ext,self.include_alpha_links,
|
|
|
|
self.separate_alpha,self.n_cols,
|
2004-03-17 08:34:10 +05:30
|
|
|
self.ind_template_name,self.depth_value,
|
|
|
|
self.birth_dates,self.year_only)
|
2005-01-07 10:23:43 +05:30
|
|
|
"""
|
2003-06-12 07:34:42 +05:30
|
|
|
MyReport.write_report()
|
2003-05-23 09:38:03 +05:30
|
|
|
except Errors.FilterError, msg:
|
|
|
|
(m1,m2) = msg.messages()
|
|
|
|
ErrorDialog(m1,m2)
|
2003-07-21 05:44:27 +05:30
|
|
|
|
2005-01-07 10:23:43 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-07-21 05:44:27 +05:30
|
|
|
class MiniTree:
|
|
|
|
"""
|
|
|
|
This is one dirty piece of code, that is why I made it it's own
|
|
|
|
class. I'm sure that someone with more knowledge of GRAMPS can make
|
|
|
|
it much cleaner.
|
|
|
|
"""
|
2005-01-07 10:23:43 +05:30
|
|
|
def __init__(self,db,person,doc,the_map,depth):
|
|
|
|
self.map = the_map
|
2004-02-14 11:10:30 +05:30
|
|
|
self.db = db
|
2003-07-21 05:44:27 +05:30
|
|
|
self.doc = doc
|
2004-03-11 05:10:13 +05:30
|
|
|
self.depth = depth
|
2003-07-21 05:44:27 +05:30
|
|
|
self.person = person
|
2004-03-11 05:10:13 +05:30
|
|
|
self.lines_map = {}
|
|
|
|
self.draw_parents(person,2**(self.depth-1),'',self.depth,1)
|
|
|
|
keys = self.lines_map.keys()
|
|
|
|
keys.sort()
|
|
|
|
self.lines = [ self.lines_map[key] for key in keys ]
|
|
|
|
|
|
|
|
def draw_parents(self,person,position,indent,generations,topline):
|
|
|
|
|
|
|
|
name = person.get_primary_name().get_regular_name()
|
|
|
|
self.lines_map[position] = ""
|
|
|
|
|
|
|
|
if topline and indent:
|
|
|
|
# if we're on top (father's) line, replace last '|' with space
|
|
|
|
self.lines_map[position] += indent[:-1] + ' '
|
|
|
|
else:
|
|
|
|
self.lines_map[position] += indent
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if person and person.get_handle() and self.map.has_key(person.get_handle()):
|
2004-08-24 00:10:25 +05:30
|
|
|
self.lines_map[position] += "<A HREF='%s%s'>%s</A>" % (person.get_gramps_id(),
|
2004-03-11 05:10:13 +05:30
|
|
|
self.doc.ext, name)
|
|
|
|
else:
|
|
|
|
self.lines_map[position] += "<U>%s</U>" % name
|
|
|
|
|
|
|
|
# We are done with this generation
|
|
|
|
generations = generations - 1
|
|
|
|
if not generations: return
|
|
|
|
|
|
|
|
offset = 2**(generations-1)
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
family_handle = person.get_main_parents_family_handle()
|
|
|
|
if not family_handle: return
|
2003-07-21 05:44:27 +05:30
|
|
|
|
2004-08-20 03:05:16 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
father_handle = family.get_father_handle()
|
|
|
|
mother_handle = family.get_mother_handle()
|
2004-03-11 05:10:13 +05:30
|
|
|
|
|
|
|
if topline:
|
|
|
|
# if we're on top (father's) line, replace last '|' with space
|
|
|
|
# then add '|' to the end for the next generation
|
|
|
|
if indent:
|
|
|
|
father_indent = indent[:-1] + ' ' + ' ' * len(name) + '|'
|
|
|
|
else:
|
|
|
|
father_indent = ' ' * len(name) + '|'
|
|
|
|
mother_indent = indent + ' ' * len(name) + '|'
|
|
|
|
else:
|
|
|
|
# if we're not on top (i.e. mother's) line, remove last '|'
|
|
|
|
# from next mother's indent, then add '|' to both
|
|
|
|
father_indent = indent + ' ' * len(name) + '|'
|
|
|
|
mother_indent = indent[:-1] + ' ' + ' ' * len(name) + '|'
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if father_handle:
|
2004-08-07 10:46:57 +05:30
|
|
|
father = self.db.get_person_from_handle(father_handle)
|
2004-03-11 05:10:13 +05:30
|
|
|
next_pos = position - offset
|
|
|
|
self.lines_map[position] += '|'
|
|
|
|
self.draw_parents(father,next_pos,father_indent,generations,1)
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if mother_handle:
|
2004-08-07 10:46:57 +05:30
|
|
|
mother = self.db.get_person_from_handle(mother_handle)
|
2004-03-11 05:10:13 +05:30
|
|
|
next_pos = position + offset
|
|
|
|
self.draw_parents(mother,next_pos,mother_indent,generations,0)
|
2003-07-21 05:44:27 +05:30
|
|
|
|
|
|
|
def draw_father(self, person, name, line, indent):
|
|
|
|
self.draw_string(line, indent, '|')
|
|
|
|
self.draw_string(line-1, indent+1, "")
|
|
|
|
self.draw_link(line-1, person, name)
|
|
|
|
|
|
|
|
def draw_mother(self, person, name, line, indent):
|
|
|
|
self.draw_string(line+1, indent, '|')
|
|
|
|
self.draw_link(line+1, person, name)
|
|
|
|
|
|
|
|
def draw_string(self, line, indent, text):
|
|
|
|
self.lines[line] += ' ' * (indent-len(self.lines[line])) + text
|
|
|
|
|
|
|
|
def draw_link(self, line, person, name):
|
2004-07-28 07:59:07 +05:30
|
|
|
if person and person.get_handle() and self.map.has_key(person.get_handle()):
|
2004-08-24 00:10:25 +05:30
|
|
|
self.lines[line] += "<A HREF='%s%s'>%s</A>" % (person.get_gramps_id(),
|
2003-07-21 05:44:27 +05:30
|
|
|
self.doc.ext, name)
|
|
|
|
else:
|
|
|
|
self.lines[line] += "<U>%s</U>" % name
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-01-07 10:23:43 +05:30
|
|
|
def cl_report(database,name,category,options_str_dict):
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
clr = Report.CommandLineReport(database,name,category,
|
|
|
|
WebReportOptions,options_str_dict)
|
2005-01-07 10:23:43 +05:30
|
|
|
|
|
|
|
# Exit here if show option was given
|
|
|
|
if clr.show:
|
|
|
|
return
|
|
|
|
|
|
|
|
try:
|
|
|
|
MyReport = WebReport(database,clr.person,clr.option_class)
|
|
|
|
MyReport.write_report()
|
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
DisplayTrace.DisplayTrace()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-01-05 10:32:19 +05:30
|
|
|
from PluginMgr import register_report
|
2002-10-20 19:55:16 +05:30
|
|
|
register_report(
|
2005-01-07 10:23:43 +05:30
|
|
|
name = 'webpage',
|
2005-12-06 12:08:09 +05:30
|
|
|
category = Report.CATEGORY_WEB,
|
2005-01-07 10:23:43 +05:30
|
|
|
report_class = WebReportDialog,
|
|
|
|
options_class = cl_report,
|
|
|
|
modes = Report.MODE_GUI | Report.MODE_CLI,
|
2005-12-06 12:08:09 +05:30
|
|
|
translated_name = _("Generate Web Site"),
|
2005-08-18 11:28:28 +05:30
|
|
|
author_name="Donald N. Allingham",
|
|
|
|
author_email="don@gramps-project.org",
|
2005-12-06 12:08:09 +05:30
|
|
|
status=(_("Unsupported")),
|
2005-08-18 11:28:28 +05:30
|
|
|
description=_("Generates web (HTML) pages for individuals, "
|
|
|
|
"or a set of individuals. This report is considered "
|
|
|
|
"to be deprecated. Please migrate to the new "
|
|
|
|
"Narrative Web Page generator."),
|
2005-12-06 12:08:09 +05:30
|
|
|
unsupported=True
|
2002-10-20 19:55:16 +05:30
|
|
|
)
|