* src/plugins/NavWebPage.py: More enhancements

* src/Sort.py: sort places by title


svn: r4026
This commit is contained in:
Don Allingham 2005-02-13 03:54:47 +00:00
parent 2db8fad3cd
commit f47f7b0d7f
3 changed files with 152 additions and 583 deletions

View File

@ -1,3 +1,7 @@
2005-02-12 Don Allingham <dallingham@users.sourceforge.net>
* src/plugins/NavWebPage.py: More enhancements
* src/Sort.py: sort places by title
2005-02-09 Don Allingham <dallingham@users.sourceforge.net>
* src/plugins/NavWebpage.py: Build template pages for unused
pages, add Surname List and Individual List pages.

View File

@ -105,3 +105,11 @@ class Sort:
a = self.database.get_event_from_handle(a_id)
b = self.database.get_event_from_handle(b_id)
return cmp(a.get_date_object(),b.get_date_object())
def by_place_title(self,a_id,b_id):
"""Sort routine for comparing two events by their dates. """
if not (a_id and b_id):
return 0
a = self.database.get_place_from_handle(a_id)
b = self.database.get_place_from_handle(b_id)
return cmp(a.title,b.title)

View File

@ -124,8 +124,8 @@ _css = [
class BasePage:
def __init__(self):
pass
def __init__(self,title):
self.title_str = title
def lnkfmt(self,text):
return text.replace(' ','%20')
@ -143,9 +143,8 @@ class BasePage:
def display_header(self,ofile,title,author=""):
ofile.write('<!DOCTYPE HTML PUBLIC ')
ofile.write('"-//W3C//DTD HTML 4.01 Transitional//EN">\n')
ofile.write('<html>\n')
ofile.write('<head>\n')
ofile.write('<title>My Family Tree</title>\n')
ofile.write('<html>\n<head>\n')
ofile.write('<title>%s</title>\n' % self.title_str)
ofile.write('<meta http-equiv="Content-Type" content="text/html; ')
ofile.write('charset=ISO-8859-1">\n')
ofile.write('<link href="%s" ' % _NARRATIVE)
@ -155,7 +154,7 @@ class BasePage:
ofile.write('<body>\n')
ofile.write('<div class="navheader">\n')
ofile.write(' <div class="navbyline">By: %s</div>\n' % author)
ofile.write(' <h1 class="navtitle">%s</h1>\n' % title)
ofile.write(' <h1 class="navtitle">%s</h1>\n' % self.title_str)
ofile.write(' <hr>\n')
ofile.write(' <div class="nav">\n')
ofile.write(' <a href="index.html">Home</a> &nbsp;\n')
@ -163,6 +162,7 @@ class BasePage:
ofile.write(' <a href="surnames.html">Surnames</a> &nbsp;\n')
ofile.write(' <a href="individuals.html">Individuals</a> &nbsp;\n')
ofile.write(' <a href="sources.html">Sources</a> &nbsp;\n')
ofile.write(' <a href="places.html">Places</a> &nbsp;\n')
ofile.write(' <a href="download.html">Download</a> &nbsp;\n')
ofile.write(' <a href="contact.html">Contact</a> &nbsp;\n')
ofile.write(' </div>\n')
@ -175,7 +175,8 @@ class BasePage:
#------------------------------------------------------------------------
class IndividualListPage(BasePage):
def __init__(self, db, person_handle_list, html_dir):
def __init__(self, db, title, person_handle_list, html_dir):
BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"individuals.html")
ofile = open(page_name, "w")
@ -187,8 +188,8 @@ class IndividualListPage(BasePage):
ofile.write('<blockquote>\n')
ofile.write('<table class="infolist" cellspacing="0" ')
ofile.write('cellpadding="0" border="0">\n')
ofile.write('<tr><td class="field"><u><b>Surname</b></u></td>\n')
ofile.write('<td class="field"><u><b>Name</b></u></td>\n')
ofile.write('<tr><td class="field"><u><b>%s</b></u></td>\n' % _('Surname'))
ofile.write('<td class="field"><u><b>%s</b></u></td>\n' % _('Name'))
ofile.write('</tr>\n')
self.sort = Sort.Sort(db)
@ -217,6 +218,67 @@ class IndividualListPage(BasePage):
ofile.close()
return
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
class PlaceListPage(BasePage):
def __init__(self, db, title, handle_list, html_dir):
BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"places.html")
ofile = open(page_name, "w")
self.display_header(ofile,_('Places'),
db.get_researcher().get_name())
ofile.write('<h3>%s</h3>\n' % _('Places'))
ofile.write('<p>%s</p>\n' % _('Index of all the places in the '
'project.'))
ofile.write('<blockquote>\n')
ofile.write('<table class="infolist" cellspacing="0" ')
ofile.write('cellpadding="0" border="0">\n')
ofile.write('<tr><td class="field"><u>')
ofile.write('<b>%s</b></u></td>\n' % _('Letter'))
ofile.write('<td class="field"><u>')
ofile.write('<b>%s</b></u></td>\n' % _('Place'))
ofile.write('</tr>\n')
self.sort = Sort.Sort(db)
handle_list.sort(self.sort.by_place_title)
last_name = ""
last_letter = ''
for handle in handle_list:
place = db.get_place_from_handle(handle)
n = place.title
if len(n) == 0:
continue
if n[0] != last_letter:
last_letter = n[0]
ofile.write('<tr><td colspan="2">&nbsp;</td></tr>\n')
ofile.write('<tr><td class="category">%s</td>' % last_letter)
ofile.write('<td class="data">')
ofile.write(n)
ofile.write(' <sup><a href="%s.html">' % place.gramps_id)
ofile.write('[%s]' % place.gramps_id)
ofile.write('</a></sup></td></tr>')
elif n != last_letter:
last_surname = n
ofile.write('<tr><td class="category">&nbsp;</td>')
ofile.write('<td class="data">')
ofile.write(n)
ofile.write(' <sup><a href="%s">' % place.gramps_id)
ofile.write('[%s]' % place.gramps_id)
ofile.write('</a></sup></td></tr>')
ofile.write('</table>\n</blockquote>\n')
self.display_footer(ofile)
ofile.close()
#------------------------------------------------------------------------
#
#
@ -224,7 +286,8 @@ class IndividualListPage(BasePage):
#------------------------------------------------------------------------
class SurnameListPage(BasePage):
def __init__(self, db, person_handle_list, html_dir):
def __init__(self, db, title, person_handle_list, html_dir):
BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"surnames.html")
ofile = open(page_name, "w")
@ -241,9 +304,9 @@ class SurnameListPage(BasePage):
ofile.write('<table class="infolist" cellspacing="0" ')
ofile.write('cellpadding="0" border="0">\n')
ofile.write('<tr><td class="field"><u>')
ofile.write('<b>%s</b></u></td>\n' % _('Surname'))
ofile.write('<b>%s</b></u></td>\n' % _('Letter'))
ofile.write('<td class="field"><u>')
ofile.write('<b>%s</b></u></td>\n' % _('Name'))
ofile.write('<b>%s</b></u></td>\n' % _('Surname'))
ofile.write('</tr>\n')
self.sort = Sort.Sort(db)
@ -285,7 +348,8 @@ class SurnameListPage(BasePage):
#------------------------------------------------------------------------
class IntroductionPage(BasePage):
def __init__(self, db, html_dir):
def __init__(self, db, title, html_dir):
BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"introduction.html")
ofile = open(page_name, "w")
@ -304,7 +368,8 @@ class IntroductionPage(BasePage):
#------------------------------------------------------------------------
class HomePage(BasePage):
def __init__(self, db, html_dir):
def __init__(self, db, title, html_dir):
BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"index.html")
ofile = open(page_name, "w")
@ -323,7 +388,8 @@ class HomePage(BasePage):
#------------------------------------------------------------------------
class SourcesPage(BasePage):
def __init__(self, db, html_dir):
def __init__(self, db, title, handle_list, html_dir):
BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"sources.html")
ofile = open(page_name, "w")
@ -342,7 +408,8 @@ class SourcesPage(BasePage):
#------------------------------------------------------------------------
class DownloadPage(BasePage):
def __init__(self, db, html_dir):
def __init__(self, db, title, html_dir):
BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"download.html")
ofile = open(page_name, "w")
@ -361,7 +428,8 @@ class DownloadPage(BasePage):
#------------------------------------------------------------------------
class ContactPage(BasePage):
def __init__(self, db, html_dir):
def __init__(self, db, title, html_dir):
BasePage.__init__(self,title)
page_name = os.path.join(html_dir,"contact.html")
ofile = open(page_name, "w")
@ -386,7 +454,8 @@ class IndividualPage(BasePage):
RelLib.Person.UNKNOWN : const.unknown,
}
def __init__(self, db, person, dirpath, ind_list):
def __init__(self, db, person, title, dirpath, ind_list):
BasePage.__init__(self,title)
self.person = person
self.db = db
self.ind_list = ind_list
@ -507,11 +576,6 @@ class IndividualPage(BasePage):
ofile.write('<td class="data">%s</td>\n' % gender)
ofile.write('</tr>\n')
# Gramps ID
ofile.write('<tr><td class="field">%s</td>\n' % _('GRAMPS ID'))
ofile.write('<td class="data">%s</td>\n' % self.person.gramps_id)
ofile.write('</tr>\n')
# Birth
handle = self.person.get_birth_handle()
if handle:
@ -755,15 +819,9 @@ class WebReport(Report.Report):
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
@ -772,36 +830,19 @@ class WebReport(Report.Report):
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.title = options_class.handler.options_dict['HTMLtitle']
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)
def get_progressbar_data(self):
@ -809,116 +850,6 @@ class WebReport(Report.Report):
'<span size="larger" weight="bold">%s</span>' %
_("Creating Web Pages"))
def dump_gendex(self,person_handle_list,html_dir):
fname = "%s/gendex.txt" % html_dir
try:
f = open(fname,"w")
except:
return
for p_id in person_handle_list:
p = self.database.get_person_from_handle(p_id)
name = p.get_primary_name()
firstName = name.get_first_name()
surName = name.get_surname()
suffix = name.get_suffix()
f.write("%s.%s|" % (p_id,self.ext))
f.write("%s|" % surName)
if suffix == "":
f.write("%s /%s/|" % (firstName,surName))
else:
f.write("%s /%s/, %s|" % (firstName,surName, suffix))
for e_id in [p.get_birth_handle(),p.get_death_handle()]:
if e_id:
e = self.database.get_event_from_handle(e_id)
else:
continue
if e:
f.write("%s|" % DateHander.displayer.display(e.get_date_object()))
if e.get_place_handle():
f.write('%s|' % self.database.get_place_from_handle(e.get_place_handle()).get_title())
else:
f.write('|')
else:
f.write('||')
f.write('\n')
f.close()
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:
person = self.database.get_person_from_handle(person_handle)
for event_handle in [person.get_birth_handle(), person.get_death_handle()] + person.get_event_list():
event = self.database.get_event_from_handle(event_handle)
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():
family = self.database.get_family_from_handle(family_handle)
for event_handle in family.get_event_list():
event = self.database.get_event_from_handle(event_handle)
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 key in self.database.get_place_handles():
if key in used_places:
myplace = self.database.get_place_from_handle(key)
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]
person = self.database.get_person_from_handle(person_handle)
name = person.get_primary_name().get_name()
if self.birth_dates:
birth_handle = self.database.get_person_from_handle(person_handle).get_birth_handle()
if birth_handle:
birth_event = self.database.get_event_from_handle(birth_handle)
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()
def write_report(self):
dir_name = self.target_path
if dir_name == None:
@ -950,55 +881,46 @@ class WebReport(Report.Report):
os.mkdir(image_dir_name)
except IOError, value:
ErrorDialog(_("Could not create the directory: %s") % \
image_dir_name + "\n" + value[1])
image_dir_name + "\n" + value[1])
return
except:
ErrorDialog(_("Could not create the directory: %s") % \
image_dir_name)
image_dir_name)
return
ind_list = self.filter.apply(self.database,self.database.get_person_handles(sort_handles=False))
ind_list = self.filter.apply(self.database,
self.database.get_person_handles(sort_handles=False))
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
progress_steps = progress_steps+1
self.progress_bar_setup(float(progress_steps))
self.write_css(dir_name)
HomePage(self.database,dir_name)
SourcesPage(self.database,dir_name)
ContactPage(self.database,dir_name)
DownloadPage(self.database,dir_name)
IntroductionPage(self.database,dir_name)
HomePage(self.database,self.title,dir_name)
ContactPage(self.database,self.title,dir_name)
DownloadPage(self.database,self.title,dir_name)
IntroductionPage(self.database,self.title,dir_name)
for person_handle in ind_list:
person = self.database.get_person_from_handle(person_handle)
idoc = IndividualPage(self.database,person, dir_name, ind_list)
idoc = IndividualPage(self.database,person,self.title,dir_name, ind_list)
self.progress_bar_step()
while gtk.events_pending():
gtk.main_iteration()
if len(ind_list) > 1:
IndividualListPage(self.database, ind_list, dir_name)
SurnameListPage(self.database, ind_list, dir_name)
self.progress_bar_step()
while gtk.events_pending():
gtk.main_iteration()
if self.use_gendex == 1:
self.dump_gendex(ind_list,dir_name)
self.progress_bar_step()
while gtk.events_pending():
gtk.main_iteration()
if 0:
self.dump_places(ind_list,self.selected_style,
self.ind_template_name,dir_name)
IndividualListPage(self.database, self.title, ind_list, dir_name)
SurnameListPage(self.database, self.title, ind_list, dir_name)
self.progress_bar_step()
while gtk.events_pending():
gtk.main_iteration()
SourcesPage(self.database,self.title,
self.database.get_source_handles(),dir_name)
PlaceListPage(self.database,self.title,
self.database.get_place_handles(),dir_name)
self.progress_bar_done()
def write_css(self,dir_name):
@ -1007,21 +929,7 @@ class WebReport(Report.Report):
f.close()
def add_styles(self,doc):
tbl = BaseDoc.TableStyle()
tbl.set_width(100)
tbl.set_column_widths([15,85])
doc.add_table_style("IndTable",tbl)
cell = BaseDoc.TableCellStyle()
doc.add_cell_style("NormalCell",cell)
cell = BaseDoc.TableCellStyle()
cell.set_padding(0.2)
doc.add_cell_style("ImageCell",cell)
cell = BaseDoc.TableCellStyle()
cell.set_padding(0.2)
doc.add_cell_style("NoteCell",cell)
pass
#------------------------------------------------------------------------
#
@ -1049,14 +957,13 @@ class WebReportOptions(ReportOptions.ReportOptions):
'HTMLsplita' : 0,
'HTMLshorttree' : 1,
'HTMLimagedir' : 'images',
'HTMLtitle' : 'My Family Tree',
'HTMLincid' : 0,
'HTMLidurl' : '',
'HTMLlinktidx' : 1,
'HTMLext' : 'html',
'HTMLtreed' : 3,
'HTMLidxt' : '',
'HTMLidxcol' : 2,
'HTMLgendex' : 0,
'HTMLidxbirth' : 0,
'HTMLplaceidx' : 0,
'HTMLyearso' : 1,
@ -1103,37 +1010,17 @@ class WebReportOptions(ReportOptions.ReportOptions):
return [all,des,df,ans,com]
def add_user_options(self,dialog):
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")
places_msg = _("Create an index of all Places")
imgdir_msg = _("Image subdirectory")
depth_msg = _("Ancestor tree depth")
title_msg = _("Web site title")
ext_msg = _("File extension")
alpha_links_msg = _("Links to alphabetical sections in index page")
sep_alpha_msg = _("Split alphabetical sections to separate pages")
birth_date_msg = _("Append birth dates to the names")
year_only_msg = _("Use only year of birth")
tree_msg = _("Include short ancestor tree")
self.mini_tree = gtk.CheckButton(tree_msg)
self.mini_tree.set_active(self.options_dict['HTMLshorttree'])
self.depth = gtk.SpinButton()
self.depth.set_digits(0)
self.depth.set_increments(1,2)
self.depth.set_range(1,10)
self.depth.set_numeric(gtk.TRUE)
self.depth.set_value(self.options_dict['HTMLtreed'])
self.use_link = gtk.CheckButton(lnk_msg)
self.use_link.set_active(self.options_dict['HTMLlinktidx'])
self.no_private = gtk.CheckButton(priv_msg)
self.no_private.set_active(not self.options_dict['HTMLincpriv'])
@ -1155,74 +1042,27 @@ class WebReportOptions(ReportOptions.ReportOptions):
self.no_comments = gtk.CheckButton(no_com_msg)
self.no_comments.set_active(not self.options_dict['HTMLcmtxtsi'])
self.include_id = gtk.CheckButton(include_id_msg)
self.include_id.set_active(self.options_dict['HTMLincid'])
self.gendex = gtk.CheckButton(gendex_msg)
self.gendex.set_active(self.options_dict['HTMLgendex'])
self.places = gtk.CheckButton(places_msg)
self.places.set_active(self.options_dict['HTMLplaceidx'])
self.imgdir = gtk.Entry()
self.imgdir.set_text(self.options_dict['HTMLimagedir'])
self.title = gtk.Entry()
self.title.set_text(self.options_dict['HTMLtitle'])
self.linkpath = gtk.Entry()
self.linkpath.set_sensitive(self.options_dict['HTMLincid'])
self.linkpath.set_text(self.options_dict['HTMLidurl'])
self.include_id.connect('toggled',self.show_link)
self.ext = gtk.combo_box_new_text()
for text in ['.html','.htm','.php','.php3','.cgi']:
ext_options = ['.html','.htm','.shtml','.php','.php3','.cgi']
for text in ext_options:
self.ext.append_text(text)
#self.ext.set_active(self.options_dict['HTMLext'])
self.use_alpha_links = gtk.CheckButton(alpha_links_msg)
self.use_alpha_links.set_active(self.options_dict['HTMLlnktoalphabet'])
self.use_sep_alpha = gtk.CheckButton(sep_alpha_msg)
self.use_sep_alpha.set_sensitive(self.options_dict['HTMLlnktoalphabet'])
self.use_sep_alpha.set_active(self.options_dict['HTMLsplita'])
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)
self.use_n_cols.set_numeric(gtk.TRUE)
self.use_n_cols.set_value(self.options_dict['HTMLidxcol'])
self.ind_template = gtk.Combo()
template_list = [ Report._default_template ]
tlist = Report._template_map.keys()
tlist.sort()
for template in tlist:
if template != Report._user_template:
template_list.append(template)
template_list.append(Report._user_template)
self.ind_template.set_popdown_strings(template_list)
self.ind_template.entry.set_editable(0)
self.ind_user_template = gnome.ui.FileEntry("HTML_Template",_("Choose File"))
self.ind_user_template.set_sensitive(0)
self.add_birth_date = gtk.CheckButton(birth_date_msg)
self.add_birth_date.set_active(self.options_dict['HTMLidxbirth'])
self.use_year_only = gtk.CheckButton(year_only_msg)
self.use_year_only.set_active(self.options_dict['HTMLyearso'])
self.use_year_only.set_sensitive(self.options_dict['HTMLidxbirth'])
self.add_birth_date.connect('toggled',self.on_birth_date_toggled)
def_ext = "." + self.options_dict['HTMLext']
self.ext.set_active(ext_options.index(def_ext))
dialog.add_option(title_msg,self.title)
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)
self.mini_tree.connect('toggled',self.on_mini_tree_toggled)
self.use_alpha_links.connect('toggled',self.on_use_alpha_links_toggled)
self.ind_template.entry.connect('changed',self.ind_template_changed)
dialog.add_option(ext_msg,self.ext)
title = _("Privacy")
dialog.add_frame_option(title,None,self.no_private)
@ -1230,23 +1070,6 @@ class WebReportOptions(ReportOptions.ReportOptions):
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)
title = _('Index page')
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)
title = _('Advanced')
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)
self.no_images.connect('toggled',self.on_nophotos_toggled)
def parse_user_options(self,dialog):
@ -1256,9 +1079,7 @@ class WebReportOptions(ReportOptions.ReportOptions):
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())
self.options_dict['HTMLtitle'] = unicode(self.title.get_text())
#html_ext = unicode(self.ext.entry.get_text().strip())
html_ext = ".html"
@ -1266,9 +1087,6 @@ class WebReportOptions(ReportOptions.ReportOptions):
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())
@ -1279,28 +1097,6 @@ class WebReportOptions(ReportOptions.ReportOptions):
else:
photos = 2
self.options_dict['HTMLimg'] = photos
text = unicode(self.ind_template.entry.get_text())
if Report._template_map.has_key(text):
if text == Report._user_template:
ind_template_name = dialog.ind_user_template.get_full_path(0)
else:
ind_template_name = "%s/%s" % (const.template_dir,Report._template_map[text])
else:
ind_template_name = None
self.options_dict['HTMLidxt'] = ind_template_name
self.options_dict['HTMLlnktoalphabet'] = int(self.use_alpha_links.get_active())
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)
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
#------------------------------------------------------------------------
@ -1318,171 +1114,9 @@ class WebReportOptions(ReportOptions.ReportOptions):
now does it?"""
self.no_living_images.set_sensitive(not obj.get_active())
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())
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())
def ind_template_changed(self,obj):
text = unicode(obj.get_text())
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):
"""Make the default output style for the Web Pages Report."""
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)
p.set_description(_("The style used for the title of the page."))
default_style.add_style("Title",p)
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 that identifies "
"facts and events."))
default_style.add_style("EventsTitle",p)
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 notes section."))
default_style.add_style("NotesTitle",p)
font = BaseDoc.FontStyle()
font.set(face=BaseDoc.FONT_SANS_SERIF,size=10)
p = BaseDoc.ParagraphStyle()
p.set(font=font,align=BaseDoc.PARA_ALIGN_CENTER)
p.set_description(_("The style used for the copyright notice."))
default_style.add_style("Copyright",p)
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 sources section."))
default_style.add_style("SourcesTitle",p)
font = BaseDoc.FontStyle()
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=14,italic=1)
p = BaseDoc.ParagraphStyle()
p.set(font=font)
p.set_description(_("The style used on the index page that labels each section."))
default_style.add_style("IndexLabel",p)
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."))
default_style.add_style("IndexLabelLinks",p)
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 image section."))
default_style.add_style("GalleryTitle",p)
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."))
default_style.add_style("SiblingsTitle",p)
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 marriages "
"and children section."))
default_style.add_style("FamilyTitle",p)
font = BaseDoc.FontStyle()
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=12)
p = BaseDoc.ParagraphStyle()
p.set_font(font)
p.set_description(_("The style used for the spouse's name."))
default_style.add_style("Spouse",p)
font = BaseDoc.FontStyle()
font.set(size=12,italic=1)
p = BaseDoc.ParagraphStyle()
p.set_font(font)
p.set_description(_("The style used for the general data labels."))
default_style.add_style("Label",p)
font = BaseDoc.FontStyle()
font.set_size(12)
p = BaseDoc.ParagraphStyle()
p.set_font(font)
p.set_description(_("The style used for the general data."))
default_style.add_style("Data",p)
font = BaseDoc.FontStyle()
font.set(bold=1,face=BaseDoc.FONT_SANS_SERIF,size=12)
p = BaseDoc.ParagraphStyle()
p.set_font(font)
p.set_description(_("The style used for the description of images."))
default_style.add_style("PhotoDescription",p)
font = BaseDoc.FontStyle()
font.set(size=12)
p = BaseDoc.ParagraphStyle()
p.set_font(font)
p.set_description(_("The style used for the notes associated with images."))
default_style.add_style("PhotoNote",p)
font = BaseDoc.FontStyle()
font.set_size(10)
p = BaseDoc.ParagraphStyle()
p.set_font(font)
p.set_description(_("The style used for the source information."))
default_style.add_style("SourceParagraph",p)
font = BaseDoc.FontStyle()
font.set_size(12)
p = BaseDoc.ParagraphStyle()
p.set_font(font)
p.set_description(_("The style used for the note information."))
default_style.add_style("NotesParagraph",p)
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."))
default_style.add_style("UrlTitle",p)
font = BaseDoc.FontStyle()
font.set_size(12)
p = BaseDoc.ParagraphStyle()
p.set_font(font)
p.set_description(_("The style used for the URL information."))
default_style.add_style("UrlList",p)
pass
#------------------------------------------------------------------------
#
@ -1500,6 +1134,7 @@ class WebReportDialog(Report.ReportDialog):
self.category = const.CATEGORY_WEB
Report.ReportDialog.__init__(self,database,person,self.options_class,
name,translated_name)
self.style_name = None
response = self.window.run()
if response == gtk.RESPONSE_OK:
@ -1509,6 +1144,14 @@ class WebReportDialog(Report.ReportDialog):
ErrorDialog(str(msg))
self.window.destroy()
def setup_style_frame(self):
"""The style frame is not used in this dialog."""
pass
def parse_style_frame(self):
"""The style frame is not used in this dialog."""
pass
def get_title(self):
"""The window title for this dialog"""
return "%s - %s - GRAMPS" % (_("Generate Web Site"),_("Web Page"))
@ -1562,7 +1205,6 @@ class WebReportDialog(Report.ReportDialog):
self.use_id,self.id_link,self.use_gendex,self.use_places,
self.html_ext,self.include_alpha_links,
self.separate_alpha,self.n_cols,
self.ind_template_name,self.depth_value,
self.birth_dates,self.year_only)
"""
MyReport.write_report()
@ -1570,103 +1212,6 @@ class WebReportDialog(Report.ReportDialog):
(m1,m2) = msg.messages()
ErrorDialog(m1,m2)
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
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.
"""
def __init__(self,db,person,doc,the_map,depth):
self.map = the_map
self.db = db
self.doc = doc
self.depth = depth
self.person = person
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
if person and person.get_handle() and self.map.has_key(person.get_handle()):
self.lines_map[position] += "<A HREF='%s%s'>%s</A>" % (person.get_gramps_id(),
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)
family_handle = person.get_main_parents_family_handle()
if not family_handle: return
family = self.db.get_family_from_handle(family_handle)
father_handle = family.get_father_handle()
mother_handle = family.get_mother_handle()
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) + '|'
if father_handle:
father = self.db.get_person_from_handle(father_handle)
next_pos = position - offset
self.lines_map[position] += '|'
self.draw_parents(father,next_pos,father_indent,generations,1)
if mother_handle:
mother = self.db.get_person_from_handle(mother_handle)
next_pos = position + offset
self.draw_parents(mother,next_pos,mother_indent,generations,0)
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):
if person and person.get_handle() and self.map.has_key(person.get_handle()):
self.lines[line] += "<A HREF='%s%s'>%s</A>" % (person.get_gramps_id(),
self.doc.ext, name)
else:
self.lines[line] += "<U>%s</U>" % name
#------------------------------------------------------------------------
#
#
@ -1687,6 +1232,18 @@ def cl_report(database,name,category,options_str_dict):
import DisplayTrace
DisplayTrace.DisplayTrace()
#------------------------------------------------------------------------
#
# Empty class to keep the BaseDoc-targeted format happy
#
#------------------------------------------------------------------------
class EmptyDoc:
def __init__(self,styles,type,template,orientation,source=None):
pass
def init(self):
pass
#-------------------------------------------------------------------------
#
#