#
#From: "Mark"
#Date: Fri, 31 Jul 1998 17:13:17 -0800
#I hacked a template that includes both the family group sheet and linked
#pedigree charts for husband and wife if you want to put it in your template
#directory. I couldn't see any options to do that, so I brute forced it with
#the output template, the g2h code is pretty ugly, but it appears to work for
#me.
#
# GED2HTML output program -- customize to taste
#
# Copyright (c) 1998 Eugene W. Stark
# All rights reserved.
#
# Permission is hereby granted to registered users of GED2HTML to
# make copies and modifications to this code for their own personal
# use and to distribute such modified copies, provided that this
# copyright notice is retained on all modified or distributed copies.
# Any other use of this code is prohibited without written permission.
#
#---------------------------------------------------------------------
# The first several definitions in this file are entry points that
# the output processor expects to be here. Whatever changes you make,
# you must leave some sort of definitions here for these routines.
#---------------------------------------------------------------------
define do_initialize { do_initialize_ ; }
define do_index i { do_index_ i ; }
define do_surnames s { do_surnames_ s ; }
define do_individuals i { do_individuals_ i ; }
define do_families f { do_families_ f ; }
define do_sources s { do_sources_ s ; }
define do_notes n { do_notes_ n ; }
define do_gendex i { do_gendex_ i ; }
#---------------------------------------------------------------------
# The rest are auxiliary routines used by the above.
# You can change whatever you want from this point on.
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# INITIALIZATION
#---------------------------------------------------------------------
# This routine runs *after* the initialization routine from an options
# file specified in the dialog box or command line, and *before* any
# GEDCOM is read.
define do_initialize_
local l
{
internationalize ;
#
# The purpose of the following silliness is to get an English-formatted
# date to put in the META elements of the HTML output, without
# affecting the previously selected language and locale.
#
set l to LANGUAGE
set LANGUAGE to "English"
set METADATE to TODAY
set LANGUAGE to l
}
#---------------------------------------------------------------------
# PAGE HEADERS AND FOOTERS
#---------------------------------------------------------------------
# Output the HTML BODY tag, handling colors, images, etc.
define html_body
{
print "" ;
}
# Produce the footer on each HTML page.
define page_footer
{
if HOMEPAGE then
print "" ,
print_alternatives HOME_TEXT "HOME" ;
print "
" ;
else
print "" ;
end
print "
" ;
print "" ,
print_alternatives CREATED_BY_TEXT "HTML created by" ;
print " " VERSION " " ,
print_alternatives ON_TEXT "on" ;
print " " TODAY ". " ;
print "
" ;
}
# Output author contact information, if MAILTO is set
define author_contact
{
if MAILTO then
print "" ,
print_alternatives EMAIL_TEXT "EMAIL" ;
print "" ;
print "
" ;
else
print "
" ;
end
}
# Output the first argument if it is non-NULL, otherwise the second argument.
# This is used for international customization.
define print_alternatives x y
{
if x then
print x ,
else
print y ,
end
}
#---------------------------------------------------------------------
# PERSONS INDEX PAGES
#---------------------------------------------------------------------
# Output a single page of the hierarchical persons index.
# Parameter i is head of a list of index nodes to be output
# on a single page.
define do_index_ i
{
print "" ;
print "" ;
print "" ;
print "" ,
print "(" ,
print_name i.parent.first.name ;
print " - " ,
print_name i.parent.last.name ;
print ")" ,
print "" ;
if ~OMIT_META then
print "" ;
print "" ;
print "" ;
print "" ;
if HEADER.copr then
print "" ;
end
end
print "" ;
html_body ;
print "" ,
print_alternatives INDEX_OF_PERSONS_TEXT "Index of Persons" ;
print "
" ;
if ~(i.parent & i.parent.parent) then
print "" ,
header_info ;
if HEADER.copr then
print "
" HEADER.copr ;
end
print "" ;
if HEADER.note then
print "" ;
print_text HEADER.note 0 ;
print "
" ;
end
if HEADER.submitter then
submitter_info HEADER.submitter ;
end
author_contact ;
end
print "" ;
while i do
if i.children then
#
# If there are still-lower-level index nodes,
# output links to them.
#
print "" ,
print_name i.first.name ;
if i.first.title then
print " (" i.first.title ")" ,
end
print " -- to -- " ,
print_name i.last.name ;
if i.last.title then
print " (" i.last.title ")" ,
end
print "
" ;
else
#
# If we have reached a leaf node of the index,
# output a link to the corresponding individual data page.
#
print "" ;
print "" ,
print_name i.first.name ;
if i.first.living then
print "" ,
else
if i.first.title then
print " (" i.first.title ")" ,
end
print "" ,
print " (" ,
birth_and_death i.first ;
print ")" ,
end
print "
" ;
end
if ~i.next then
print "
" ;
index_links i.parent 0 ;
end
set i to i.next
end
print "" ,
print_alternatives SURNAMES_TEXT "SURNAMES" ;
print "
" ;
page_footer ;
print "" ;
print "" ;
}
#
# Create UP, BACK, and NEXT pointers for navigation within a
# hierarchical index.
# The second argument is zero for persons index, nonzero for
# surnames index
#
define index_links i which
local pred succ
{
print "" ;
if i then
if i.parent then
if UP_TEXT then
index_link UP_TEXT i.parent which ;
else
index_link "UP" i.parent which ;
end
end
if i.prev then
if BACK_TEXT then
index_link BACK_TEXT i.prev which ;
else
index_link "BACK" i.prev which ;
end
else
set pred to i.pred
if pred then
if BACK_TEXT then
index_link BACK_TEXT i.parent.pred which ;
else
index_link "BACK" i.parent.pred which ;
end
end
end
if i.next then
if NEXT_TEXT then
index_link NEXT_TEXT i.next which ;
else
index_link "NEXT" i.next which ;
end
else
set succ to i.succ
if succ then
if NEXT_TEXT then
index_link NEXT_TEXT i.succ which ;
else
index_link "NEXT" i.succ which ;
end
end
end
end
print "
" ;
}
# Output a link to a node i in the persons index,
# with d as the highlighted text of the link.
# The third argument is zero for persons index, nonzero for
# surnames index
define index_link d s which
{
print "" d "" ,
print " (" ,
if which then
emit_surname s.first.surname ;
print " - " ,
emit_surname s.last.surname ;
else
print_name s.first.name ;
print " - " ,
print_name s.last.name ;
end
print ")
" ;
}
# Routine that outputs information from the GEDCOM header on
# each index page.
define header_info
{
print NUMBER_OF_INDIVIDUALS " " ,
print_alternatives INDIVIDUALS_TEXT "individuals" ;
print ", " NUMBER_OF_FAMILIES " " ,
print_alternatives FAMILIES_TEXT "families" ;
if HEADER.filename then
print " " ,
print_alternatives FROM_FILE_TEXT "from file" ;
print " " HEADER.filename ,
if HEADER.date then
print " (" HEADER.date.value ")" ;
end
end
}
# Output submitter information from the GEDCOM header
define submitter_info s
local t
{
if s.name | s.address | s.phone then
print "" ,
print_alternatives AUTHOR_TEXT "Author" ;
print_alternatives COLON_TEXT ": " ;
print "
" ,
if s.name & s.name.text then
print s.name.text ,
print "
" ;
end
if s.address & s.address.text then
set t to s.address.text
while t do
print t.text ,
if t.cont then
print ", " ,
set t to t.cont
else
set t to t.conc
end
end
print "
" ;
end
if s.phone & s.phone.text then
print s.phone.text ;
end
print "
" ;
end
}
#---------------------------------------------------------------------
# SURNAMES INDEX PAGES
#---------------------------------------------------------------------
# Output a single page of the surnames index.
# Parameter s is the head of a list of surname index nodes to
# be output in a single file.
define do_surnames_ s
local pred succ tabs
{
print "" ;
print "" ;
print "" ;
print "" ,
print_alternatives INDEX_OF_SURNAMES_TEXT "Index of Surnames" ;
print "" ;
if ~OMIT_META then
print "" ;
print "" ;
print "" ;
print "" ;
if HEADER.copr then
print "" ;
end
end
print "" ;
html_body ;
print "" ,
print_alternatives INDEX_OF_SURNAMES_TEXT "Index of Surnames" ;
print "
" ;
if ~(s.parent & s.parent.parent) then
print "" ,
header_info ;
if HEADER.copr then
print "
" HEADER.copr ;
end
print "" ;
if HEADER.note then
print "" ;
print_text HEADER.note 0 ;
print "
" ;
end
if HEADER.submitter then
submitter_info HEADER.submitter ;
end
author_contact ;
end
#
# If the index consists of a single node, and we haven't been
# asked to produce a hierarchical index, then use "alphabet tab" format
#
if ~s.children & SURNAME_WIDTH = 0 & ~NO_ALPHABET_TABS then
do_alphabetical s ;
#
# Otherwise use the more general hierarchical format
#
else
print "" ;
while s do
if s.children then # Internal node of hierarchical index
# emit index tabs to lower levels
print "" ;
emit_surname s.first.surname ;
print " -- to -- " ,
emit_surname s.last.surname ;
print "
" ;
else # Leaf node of hierarchical index
# emit links to persons index
print "" ,
emit_surname s.first.surname ;
print "" ,
if s.next then
print "," ;
else
print ;
end
end
if ~s.next then
print "
" ;
index_links s.parent 1 ;
end
set s to s.next
end
end
print "" ,
print_alternatives INDEX_TEXT "INDEX" ;
print "
" ;
page_footer ;
print "" ;
print "