| 1 |
/* |
| 2 |
* @progname dump_html_sd.ll |
| 3 |
* @version 1.0 |
| 4 |
* @author Scott McGee, Steve Dum |
| 5 |
* @category sample |
| 6 |
* @output HTML |
| 7 |
* @description |
| 8 |
|
| 9 |
dump_html_sd.ll dumps an entire database to static HTML files. |
| 10 |
|
| 11 |
by Scott McGee ([email protected]) |
| 12 |
1.4 13/06/02 |
| 13 |
lots of modifications by Steve Dum ([email protected]) |
| 14 |
|
| 15 |
This report basically generate a |
| 16 |
master index and write a series of html files for everyone in |
| 17 |
your database. It generates both decendant and pedigree charts for |
| 18 |
each individual. There are lots of assumptions in how you store |
| 19 |
data in your database inbeded in the script -- or should I say how I |
| 20 |
store info. SD. |
| 21 |
|
| 22 |
*/ |
| 23 |
|
| 24 |
/* customization globals - customize values assigned in main */ |
| 25 |
global(db_owner) /* name of database owner */ |
| 26 |
global(owner_addr) /* url of database owner (mailto or homepage) */ |
| 27 |
global(use_image) /* flag to indicate whether to use genweb image */ |
| 28 |
global(genweb_image) /* name of genweb image to place on each page */ |
| 29 |
global(use_page) /* flag to add link to genweb page or homepage */ |
| 30 |
global(genweb_page) /* URL of base genweb (or homepage) web page */ |
| 31 |
global(page_name) /* name of base genweb (or homepage) web page */ |
| 32 |
global(LDS) /* display LDS Ordinances? (1=yes 0=no) */ |
| 33 |
global(html_index) /* put HTML <ISINDEX> tag in INDEX file (1=yes 0=no) */ |
| 34 |
|
| 35 |
|
| 36 |
proc set_static_html_globals(){ |
| 37 |
/* customize these globals to customize the output to your site */ |
| 38 |
set(db_owner, getproperty("user.fullname")) |
| 39 |
set(owner_addr, getproperty("user.email")) |
| 40 |
set(use_image, 0) /* 1 to use image, 0 to not use image */ |
| 41 |
set(genweb_image, "../../pics/genweb.gif") |
| 42 |
set(use_page, 0) /* 1 to use link to page, 0 if not */ |
| 43 |
set(genweb_page, "../genweb.html") |
| 44 |
set(page_name, "genweb page") /* might change to "my homepage" */ |
| 45 |
set(LDS, 0) |
| 46 |
set(html_index, 0) /* use 1 to add <ISINDEX> to INDEX file */ |
| 47 |
} |
| 48 |
/* end of customization globals - customize values assigned in main */ |
| 49 |
|
| 50 |
/* other globals */ |
| 51 |
global(found) /* external file to inline image found flag */ |
| 52 |
global(per_file) /* number of people per file to write */ |
| 53 |
global(first) /* first person shouldn't be asked about */ |
| 54 |
|
| 55 |
global(RVAL) /* ?? (part of borrowed code) */ |
| 56 |
global(last_surname) /* last surname in index - used for anchors */ |
| 57 |
global(first_indi) /* starting person */ |
| 58 |
global(sour_count) /* count of source records */ |
| 59 |
global(sourcnt) /* count of source records when doing birth/death */ |
| 60 |
global(href_table) /* table that has filenames individuals are in */ |
| 61 |
|
| 62 |
global(linecount) /* globals for descendent chart */ |
| 63 |
global(MAXLINES) |
| 64 |
global(gens) |
| 65 |
global(mainpre) |
| 66 |
global(spousepre) |
| 67 |
global(indentpre) |
| 68 |
|
| 69 |
proc main () { |
| 70 |
|
| 71 |
set(gens, 3) |
| 72 |
set(mainpre, "-") |
| 73 |
set(spousepre, " s-") |
| 74 |
set(indentpre, " |") |
| 75 |
set(MAXLINES, 500) |
| 76 |
|
| 77 |
set(sour_count,0) |
| 78 |
indiset(out_set) |
| 79 |
|
| 80 |
call set_static_html_globals() |
| 81 |
set(per_file, 1) |
| 82 |
|
| 83 |
print("Reading data...\n") |
| 84 |
forindi(j, n) { |
| 85 |
addtoset(out_set, j, n) |
| 86 |
} |
| 87 |
print("Working...\n") |
| 88 |
call html_out(out_set) |
| 89 |
} |
| 90 |
|
| 91 |
proc html_out (o) { |
| 92 |
/* |
| 93 |
set(s, concat("There are ", d(lengthset(o)), |
| 94 |
" people in your list, how many per file?")) |
| 95 |
getstr(a,s) |
| 96 |
set(per_file, atoi(a)) |
| 97 |
*/ |
| 98 |
set(per_file,50) |
| 99 |
|
| 100 |
if (not(per_file)) { |
| 101 |
set(per_file, 1) |
| 102 |
} |
| 103 |
set(loop_count, 0) |
| 104 |
set(file_count, 0) |
| 105 |
call init_href(o) |
| 106 |
forindiset(o, i, j, n) { |
| 107 |
set(indi, i) |
| 108 |
if (eq(loop_count, 0)) { |
| 109 |
incr(file_count) |
| 110 |
call write_head(file_count) |
| 111 |
} |
| 112 |
incr(loop_count) |
| 113 |
call genhtml(indi, o) |
| 114 |
if (or(eq(loop_count, per_file), eq(n, lengthset(o)))) { |
| 115 |
call write_tail() |
| 116 |
set(loop_count, 0) |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
call do_index(o) |
| 121 |
|
| 122 |
} |
| 123 |
|
| 124 |
proc write_head(count) { |
| 125 |
set(filename, concat("html/", database(), "/",database(),"_", d(count), ".html")) |
| 126 |
print("Writing ", filename, "\n") |
| 127 |
newfile(filename, 0) |
| 128 |
"<HTML><HEAD>\n" |
| 129 |
"<TITLE> " database() "_" d(count) ".html </TITLE>\n" |
| 130 |
"</HEAD><BODY>\n" |
| 131 |
"<style type=\"text/css\">\n" |
| 132 |
"p.hindent { margin-top: 0.2em; margin-bottom:0em;\n" |
| 133 |
" text-indent: -2em; padding-left: 2em;}\n" |
| 134 |
"p.indent { margin-top: 0.2em; margin-bottom:0em;\n" |
| 135 |
" text-indent: 0em; padding-left: 2em;}\n" |
| 136 |
"</style>\n" |
| 137 |
if (use_image) { |
| 138 |
"<IMG SRC=\"" |
| 139 |
genweb_image |
| 140 |
"\" ALT = \"\"><BR><BR>\n" |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
proc write_tail() { |
| 145 |
"<BR><HR><ADDRESS>\n" |
| 146 |
date(gettoday()) |
| 147 |
"<BR>\n" |
| 148 |
"Database maintained by " |
| 149 |
"<A HREF=\"" owner_addr "\">\n" |
| 150 |
db_owner |
| 151 |
"</A></ADDRESS>\n" |
| 152 |
"</BODY></HTML>\n" |
| 153 |
} |
| 154 |
|
| 155 |
proc genhtml (i, o) { |
| 156 |
/* print(" ", fullname(i,0,1,300), "\n") */ |
| 157 |
"<A NAME=\"" key(i) "\"></A>\n" |
| 158 |
/* was <H1>...</H1> but fudged to get key in slightly smaller font */ |
| 159 |
"<P><FONT size=+2><B>" |
| 160 |
givens(i) " " surname(i) |
| 161 |
" <Font size=-1>(" key(i) ")</Font></B></FONT><P>\n" |
| 162 |
|
| 163 |
set(path, get_picture(i)) |
| 164 |
if (found) { |
| 165 |
"<IMG width=30% SRC =\"" |
| 166 |
if (eq(found,2)) { "../../" } |
| 167 |
path |
| 168 |
"\" ALT = \"\"><BR>\n" |
| 169 |
} |
| 170 |
"<H3>" date(birth(i)) " - " date(death(i)) "</H3>" nl() |
| 171 |
call afn(i) |
| 172 |
call scan_events(i,0) |
| 173 |
if (LDS) { |
| 174 |
/* LDS ordinances */ |
| 175 |
set(started, 0) |
| 176 |
fornodes(inode(i), node) { |
| 177 |
if (eq(0, strcmp(tag(node), "BAPL"))) { |
| 178 |
if (not(started)) { |
| 179 |
set(started, 1) |
| 180 |
"<BR>LDS Ordinances: B " |
| 181 |
} |
| 182 |
} |
| 183 |
/* determine if endowed */ |
| 184 |
if (eq(0, strcmp(tag(node), "ENDL"))) { |
| 185 |
if (not(started)) { |
| 186 |
set(started, 1) |
| 187 |
"<BR>LDS Ordinances: " |
| 188 |
} |
| 189 |
"E " |
| 190 |
} |
| 191 |
} |
| 192 |
/* determine if sealed to parents */ |
| 193 |
set(fam, fnode(parents(i))) |
| 194 |
set(ind, inode(i)) |
| 195 |
if (fam) { |
| 196 |
fornodes(fam, node) { |
| 197 |
if (and(eqstr("CHIL", tag(node)), eqstr(xref(ind), value(node)))) { |
| 198 |
fornodes(node, next) { |
| 199 |
if (eqstr(tag(next), "SLGC")) { |
| 200 |
if (not(started)) { |
| 201 |
set(started, 1) |
| 202 |
"<BR>LDS Ordinances: " |
| 203 |
} |
| 204 |
"SC " |
| 205 |
} |
| 206 |
} |
| 207 |
} |
| 208 |
} |
| 209 |
} |
| 210 |
if (started){ |
| 211 |
"<BR>\n" |
| 212 |
} |
| 213 |
} |
| 214 |
call othernames(i) |
| 215 |
call print_html(i) |
| 216 |
"<HR>\n" |
| 217 |
if (p, father(i)) { |
| 218 |
"<P class=\"hindent\">\n" |
| 219 |
"<EM>" "Father</EM> : " |
| 220 |
call name_href(p,1) |
| 221 |
"<BR>\n" |
| 222 |
} |
| 223 |
if (p, mother(i)) { |
| 224 |
"<P class=\"hindent\">\n" |
| 225 |
"<EM>" "Mother</EM> : " |
| 226 |
call name_href(p,1) |
| 227 |
"<BR>\n" |
| 228 |
} |
| 229 |
families(i, f, s, n) { |
| 230 |
"<P class=\"hindent\">\n" |
| 231 |
"<EM>" "Spouse" |
| 232 |
if (gt(nfamilies(i), 1)) { |
| 233 |
" " |
| 234 |
d(n) |
| 235 |
} |
| 236 |
"</EM> : \n" |
| 237 |
if (s) { /* family has a spouse */ |
| 238 |
call name_href(s,1) |
| 239 |
"<BR>\n" |
| 240 |
} |
| 241 |
if (e, marriage(f)) { |
| 242 |
"<P class=\"indent\">\n" |
| 243 |
"<EM>Married</EM> " |
| 244 |
long(e) |
| 245 |
"<BR>\n" |
| 246 |
} |
| 247 |
if (e, divorced(f)) { |
| 248 |
"<P class=\"indent\">\n" |
| 249 |
"<EM>Divorced</EM> " |
| 250 |
long(e) |
| 251 |
"<BR>\n" |
| 252 |
} |
| 253 |
if (LDS) { |
| 254 |
fornodes(fnode(f), node) { |
| 255 |
if (eq(0, strcmp(tag(node), "SLGS"))) { |
| 256 |
"<BR>LDS Ordinances: SS\n" |
| 257 |
} |
| 258 |
} |
| 259 |
} |
| 260 |
if (nchildren(f)) { |
| 261 |
"<P class=\"hindent\">\n" |
| 262 |
"<EM>Children</EM>\n" |
| 263 |
"<OL style=\"margin-top: 0.2em;\">\n" |
| 264 |
children(f, c, nn) { |
| 265 |
"<LI>" |
| 266 |
call name_href(c,1) |
| 267 |
"</LI>\n" |
| 268 |
} |
| 269 |
"</OL>\n" |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
call print_notes(inode(i)) |
| 274 |
|
| 275 |
call print_indi_sources(i) |
| 276 |
|
| 277 |
if (parents(i)) { |
| 278 |
"<P>\nPedigree Chart for " fullname(i,0,1,300) "<BR>\n<PRE>\n" |
| 279 |
call pedigree(0,i) |
| 280 |
"</PRE>\n" |
| 281 |
} |
| 282 |
if (nfamilies(i)) { |
| 283 |
"Descendent Chart for " fullname(i,0,1,300) "<BR>\n<PRE>\n" |
| 284 |
set(linecount,0) |
| 285 |
call dofam(i,"",1,0) |
| 286 |
"</PRE>\n" |
| 287 |
} |
| 288 |
|
| 289 |
/* scan events for sources */ |
| 290 |
call scan_events(i,1) |
| 291 |
"<HR>\n" |
| 292 |
|
| 293 |
/* Insert code here for Pedigree and Descendant charts |
| 294 |
if (parents(i)) { |
| 295 |
"Pedigree Chart<BR>\n" |
| 296 |
} |
| 297 |
if (nfamilies(i)) { |
| 298 |
set(hasChildren, 0) |
| 299 |
families(i, f, s, n) { |
| 300 |
if (nchildren(f)) { |
| 301 |
set(hasChildren, 1) |
| 302 |
} |
| 303 |
} |
| 304 |
if (hasChildren) { |
| 305 |
"Descendant Chart\n" |
| 306 |
} |
| 307 |
} |
| 308 |
"<HR>\n" |
| 309 |
*/ |
| 310 |
"<BR>\n" |
| 311 |
"[<A HREF=\"index.html\">" |
| 312 |
"Index</A>]<BR>\n" |
| 313 |
if (use_page) { |
| 314 |
"[<A HREF=\"" genweb_page "\">" |
| 315 |
"Return to " |
| 316 |
page_name |
| 317 |
" </A>]<BR> \n" |
| 318 |
} |
| 319 |
"<BR><HR><BR>\n" |
| 320 |
} |
| 321 |
|
| 322 |
proc init_href(outset){ |
| 323 |
table(href_table) |
| 324 |
|
| 325 |
forindiset(outset, indi, j, number) { |
| 326 |
insert(href_table, save(key(indi)), number) |
| 327 |
} |
| 328 |
} |
| 329 |
|
| 330 |
func get_href(indi) { |
| 331 |
set(path, "") |
| 332 |
set(found, 0) |
| 333 |
set(value, lookup(href_table, key(indi))) |
| 334 |
if (value){ |
| 335 |
set(number, add(div(sub(value, 1), per_file), 1)) |
| 336 |
set(path, concat(database(),"_", d(number), ".html")) |
| 337 |
set(found, 1) |
| 338 |
} |
| 339 |
return(path) |
| 340 |
} |
| 341 |
|
| 342 |
proc print_notes(i){ |
| 343 |
set(first, 1) |
| 344 |
fornodes(i, n) { |
| 345 |
set(hdr,"") |
| 346 |
if (eqstr(tag(n), "NOTE")) { set(hdr,"Note") } |
| 347 |
elsif(eqstr(tag(n),"NOTE_L")) { set(hdr,"Note_L") } |
| 348 |
elsif(eqstr(tag(n),"NOTE_Q")) { set(hdr,"Note_Q") } |
| 349 |
elsif(eqstr(tag(n),"NOTE_E")) { set(hdr,"Note_E") } |
| 350 |
if (strcmp(hdr,"")) { |
| 351 |
set(s, value(n)) |
| 352 |
if (and(strcmp("",s),reference(s))) { |
| 353 |
set(n,dereference(s)) |
| 354 |
set(hdr, save(concat(hdr," ",substring(s,2,sub(strlen(s),1))))) |
| 355 |
} |
| 356 |
print_note(n,hdr) |
| 357 |
} |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
proc print_indi_sources(indi) { |
| 362 |
fornodes(inode(indi), node) { |
| 363 |
set(hdr,"") |
| 364 |
set(ntag,tag(node)) |
| 365 |
set(first,0) |
| 366 |
if (eqstr("SOUR", ntag)) { set(hdr,"Source") } |
| 367 |
elsif(eqstr("ADDR", ntag)) { set(hdr,"Address") } |
| 368 |
elsif(eqstr("_MDCL", ntag)) { set(hdr,"Medical") } |
| 369 |
elsif(eqstr("OCCU", ntag)) { set(hdr,"Occupation") } |
| 370 |
elsif(eqstr("_FA", trim(ntag,3))) { set(hdr,"Fact") } |
| 371 |
if (strcmp("",hdr)) { |
| 372 |
if (reference(value(node))) { set(node,dereference(value(node))) } |
| 373 |
"<P class=\"hindent\">\n" |
| 374 |
"<EM>" hdr ":</EM>: " |
| 375 |
if (nestr("",value(node))) { |
| 376 |
incr(first) |
| 377 |
value(node) "<BR>\n" |
| 378 |
} |
| 379 |
fornodes(node, next) { |
| 380 |
if (nestr("",value(next))) { |
| 381 |
/* if(eq(first,1)) { "<BR>" } */ |
| 382 |
incr(first) |
| 383 |
value(next) "<BR>\n" |
| 384 |
} |
| 385 |
fornodes(next, nn) { |
| 386 |
if (nestr("",value(next))) { |
| 387 |
/* if(eq(first,1)) { "<BR>" } */ |
| 388 |
incr(first) |
| 389 |
value(nn) "<BR>\n" |
| 390 |
} |
| 391 |
} |
| 392 |
} |
| 393 |
if(gt(first,1)) { "\n" } |
| 394 |
} |
| 395 |
} |
| 396 |
} |
| 397 |
|
| 398 |
proc show_path (node){ |
| 399 |
list(path) |
| 400 |
while (node) { |
| 401 |
push(path, tag(node)) |
| 402 |
set(node, parent(node)) |
| 403 |
} |
| 404 |
"(" |
| 405 |
while (s, pop(path)) { |
| 406 |
if (eqstr(lower(s), "indi")){ |
| 407 |
"Individual " |
| 408 |
}elsif (eqstr(lower(s), "fam")){ |
| 409 |
"Family " |
| 410 |
}elsif (eqstr(lower(s), "famc")){ |
| 411 |
"family " |
| 412 |
}elsif (eqstr(lower(s), "fams")){ |
| 413 |
"family " |
| 414 |
}elsif (eqstr(lower(s), "note")){ |
| 415 |
"note" |
| 416 |
}elsif (eqstr(lower(s), "birt")){ |
| 417 |
"birth " |
| 418 |
}elsif (eqstr(lower(s), "deat")){ |
| 419 |
"death " |
| 420 |
}elsif (eqstr(lower(s), "buri")){ |
| 421 |
"burial " |
| 422 |
}elsif (eqstr(lower(s), "plac")){ |
| 423 |
"place " |
| 424 |
}else{ |
| 425 |
lower(s) |
| 426 |
" " |
| 427 |
} |
| 428 |
} |
| 429 |
")\n" |
| 430 |
} |
| 431 |
|
| 432 |
proc do_index(indi_set) { |
| 433 |
set(last_surname, "ZZ") |
| 434 |
list(RVAL) |
| 435 |
indiset(index) |
| 436 |
|
| 437 |
set(index, indi_set) |
| 438 |
namesort(index) |
| 439 |
print("Writing index.html\n") |
| 440 |
call create_index_file(index) |
| 441 |
print("Writing gendex.txt\n") |
| 442 |
call create_gendex_file(index) |
| 443 |
} |
| 444 |
|
| 445 |
proc create_gendex_file(index) { |
| 446 |
set(fn, save(concat("html/", database(), "/gendex.txt"))) |
| 447 |
newfile(fn, 0) |
| 448 |
forindiset(index, me, v, n) |
| 449 |
{ |
| 450 |
set(path, concat(save(get_href(me)), "#", key(me))) |
| 451 |
path |
| 452 |
"|" |
| 453 |
surname(me) |
| 454 |
"|" |
| 455 |
givens(me) " /" |
| 456 |
surname(me) "/" |
| 457 |
"|" |
| 458 |
if (evt, birth(me)) { |
| 459 |
date(evt) |
| 460 |
} |
| 461 |
"|" |
| 462 |
if (evt, birth(me)) { |
| 463 |
place(evt) |
| 464 |
} |
| 465 |
"|" |
| 466 |
if (evt, death(me)) { |
| 467 |
date(evt) |
| 468 |
} |
| 469 |
"|" |
| 470 |
if (evt, death(me)) { |
| 471 |
place(evt) |
| 472 |
} |
| 473 |
"|\n" |
| 474 |
} |
| 475 |
} |
| 476 |
|
| 477 |
proc create_index_file(index) { |
| 478 |
set(fn, save(concat("html/", database(), "/index.html"))) |
| 479 |
newfile(fn, 0) |
| 480 |
call html_header(concat("Index for ",database()," Database"), html_index) |
| 481 |
"<BODY>\n" |
| 482 |
if (use_image) { |
| 483 |
"<IMG SRC=\"" |
| 484 |
genweb_image |
| 485 |
"\" ALT = \"\"><BR><BR>\n" |
| 486 |
} |
| 487 |
"<H1> Index </H1>\n" |
| 488 |
"<UL>\n" |
| 489 |
forindiset(index, me, v, n) |
| 490 |
{ |
| 491 |
call href(me) |
| 492 |
"\n" |
| 493 |
} |
| 494 |
"</UL>\n" |
| 495 |
call write_tail() |
| 496 |
} |
| 497 |
|
| 498 |
/* href generates html link reference for name in form last,first */ |
| 499 |
proc href(indi) { |
| 500 |
if (indi) { |
| 501 |
call print_name(indi, 1) |
| 502 |
if (ne(strcmp(upper(surname(indi)), last_surname), 0)) { |
| 503 |
print(" ", upper(surname(indi)), "\n") |
| 504 |
set(last_surname, save(upper(surname(indi)))) |
| 505 |
"<A NAME=" qt() last_surname qt() "></A>\n" |
| 506 |
} |
| 507 |
"<LI>" |
| 508 |
set (path, get_href(indi)) |
| 509 |
if (found) { |
| 510 |
"<A HREF=\"" path "#" key(indi) "\">\n" |
| 511 |
} |
| 512 |
pop(RVAL) |
| 513 |
if (found) { |
| 514 |
"</A>" |
| 515 |
} |
| 516 |
do_info(indi,1) |
| 517 |
} |
| 518 |
} |
| 519 |
|
| 520 |
/* name_href generates html link reference for name */ |
| 521 |
proc name_href(indi,long) { |
| 522 |
set (path, get_href(indi)) |
| 523 |
if (found) { |
| 524 |
"<A HREF=\"" path "#" key(indi) "\">" |
| 525 |
} |
| 526 |
if (t,title(indi)) { t " " } |
| 527 |
fullname(indi,0,1,300) |
| 528 |
if (found) {"</A>"} |
| 529 |
do_info(indi,long) |
| 530 |
} |
| 531 |
|
| 532 |
proc html_header(str, isindex) { |
| 533 |
"<HTML>\n" |
| 534 |
"<HEAD>\n" |
| 535 |
if (isindex) { |
| 536 |
"<ISINDEX>\n" |
| 537 |
} |
| 538 |
"<TITLE> " |
| 539 |
str |
| 540 |
" </TITLE>\n" |
| 541 |
"</HEAD>\n" |
| 542 |
} |
| 543 |
|
| 544 |
proc print_name (me, last) { |
| 545 |
call get_title(me) |
| 546 |
set(junk, pop(RVAL)) |
| 547 |
push(RVAL, save(concat(fullname(me, 1, not(last), 45), junk))) |
| 548 |
} |
| 549 |
|
| 550 |
proc get_title (me) { |
| 551 |
fornodes(inode(me), node) { |
| 552 |
if (not(strcmp("TITL", tag(node)))) { |
| 553 |
set(n, node) |
| 554 |
} |
| 555 |
} |
| 556 |
if (n) { |
| 557 |
push(RVAL, save(concat(" ", value(n)))) |
| 558 |
} |
| 559 |
else { |
| 560 |
push(RVAL, "") |
| 561 |
} |
| 562 |
} |
| 563 |
|
| 564 |
proc rjt(n, w) { |
| 565 |
if (lt(n, 10)) { |
| 566 |
set(d, 1) |
| 567 |
} |
| 568 |
elsif (lt(n, 100)) { |
| 569 |
set(d, 2) |
| 570 |
} |
| 571 |
elsif (lt(n, 1000)) { |
| 572 |
set(d, 3) |
| 573 |
} |
| 574 |
elsif (lt(n, 10000)) { |
| 575 |
set(d, 4) |
| 576 |
} |
| 577 |
else { |
| 578 |
set(d, 5) |
| 579 |
} |
| 580 |
if (lt(d, w)) { |
| 581 |
set(pad, save( trim(" ", sub(w, d)))) |
| 582 |
} |
| 583 |
else{ |
| 584 |
set(pad, "") |
| 585 |
} |
| 586 |
push(RVAL, save( concat(pad, save(d(n))))) |
| 587 |
} |
| 588 |
|
| 589 |
proc othernames(indi){ |
| 590 |
if (indi){ |
| 591 |
set(count, 0) |
| 592 |
fornodes(inode(indi), subnode){ |
| 593 |
if (eqstr(tag(subnode), "NAME")){ |
| 594 |
incr(count) |
| 595 |
if (eq(count, 2)){ |
| 596 |
"<BR><EM>Other Names</EM>: \n<UL>" |
| 597 |
"<LI>" call nameval(subnode) "</LI>" |
| 598 |
} elsif (gt(count, 2)){ |
| 599 |
"<LI>" call nameval(subnode) "</LI>\n" |
| 600 |
} |
| 601 |
} elsif (eqstr(tag(subnode),"ALIA")){ |
| 602 |
incr(count) |
| 603 |
if (eq(count, 2)){ |
| 604 |
"<BR><EM>Other Names</EM>: \n<UL>" |
| 605 |
"<LI>" value(subnode) "</LI>" |
| 606 |
} elsif (gt(count, 2)){ |
| 607 |
"<LI>" value(subnode) "</LI>\n" |
| 608 |
} |
| 609 |
} |
| 610 |
} |
| 611 |
if (gt(count, 1)){ |
| 612 |
"</UL>\n" |
| 613 |
} |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
proc afn(indi){ |
| 618 |
if (indi){ |
| 619 |
fornodes(inode(indi), subnode){ |
| 620 |
if (eqstr(tag(subnode), "AFN")){ |
| 621 |
"AFN " |
| 622 |
value(subnode) |
| 623 |
"<BR><BR>\n" |
| 624 |
} |
| 625 |
} |
| 626 |
} |
| 627 |
} |
| 628 |
|
| 629 |
func do_info(me,long){ |
| 630 |
if(not(me)){ |
| 631 |
return("") |
| 632 |
} |
| 633 |
set(out, " -") |
| 634 |
if (evt, birth(me)) { |
| 635 |
if (long) { |
| 636 |
set(out, concat(out, " b. ", long(evt))) |
| 637 |
} else { |
| 638 |
set(out, concat(out, " b. ", short(evt))) |
| 639 |
} |
| 640 |
} else { |
| 641 |
if (evt, baptism(me)) { |
| 642 |
if (long) { |
| 643 |
set(out, concat(out, " bapt. ", long(evt))) |
| 644 |
} else { |
| 645 |
set(out, concat(out, " bapt. ", short(evt))) |
| 646 |
} |
| 647 |
} else { |
| 648 |
if (evt, bapt(me)) { |
| 649 |
if (long) { |
| 650 |
set(out, concat(out, " bapt. ", long(evt))) |
| 651 |
} else { |
| 652 |
set(out, concat(out, " bapt. ", short(evt))) |
| 653 |
} |
| 654 |
} |
| 655 |
} |
| 656 |
} |
| 657 |
if (evt, death(me)) { |
| 658 |
if (long) { |
| 659 |
set(out, concat(out, " d. ", long(evt))) |
| 660 |
} else { |
| 661 |
set(out, concat(out, " d. ", short(evt))) |
| 662 |
} |
| 663 |
} |
| 664 |
return(out) |
| 665 |
} |
| 666 |
|
| 667 |
func bapt (indi) { |
| 668 |
fornodes(inode(indi), node) { |
| 669 |
if (eq(0, strcmp(tag(node), "BAPL"))) { |
| 670 |
return(node) |
| 671 |
} |
| 672 |
if (eq(0, strcmp(tag(node), "BAPM"))) { |
| 673 |
return(node) |
| 674 |
} |
| 675 |
if (eq(0, strcmp(tag(node), "BAPT"))) { |
| 676 |
return(node) |
| 677 |
} |
| 678 |
} |
| 679 |
return(0) |
| 680 |
} |
| 681 |
|
| 682 |
proc nameval(namenode){ |
| 683 |
list(np) |
| 684 |
extractnames(namenode, np, nc, sc) |
| 685 |
forlist(np, v, i){ |
| 686 |
v |
| 687 |
" " |
| 688 |
} |
| 689 |
} |
| 690 |
|
| 691 |
proc print_html(indi){ |
| 692 |
fornodes(inode(indi), node) { |
| 693 |
if (eqstr("REPORT", tag(node))) { |
| 694 |
set(m, child(node)) |
| 695 |
if (eqstr("TYPE", tag(m))) { |
| 696 |
if (eqstr("HTML", value(m))) { |
| 697 |
"<BR>\n" |
| 698 |
fornodes(m, o) { |
| 699 |
if (eqstr("DATA", tag(o))) { |
| 700 |
value(o) |
| 701 |
"\n" |
| 702 |
} |
| 703 |
} |
| 704 |
} |
| 705 |
else { |
| 706 |
if (eqstr("HTML-STATIC", value(m))) { |
| 707 |
"<BR>\n" |
| 708 |
fornodes(m, o) { |
| 709 |
if (eqstr("DATA", tag(o))) { |
| 710 |
value(o) |
| 711 |
"\n" |
| 712 |
} |
| 713 |
} |
| 714 |
} |
| 715 |
} |
| 716 |
} |
| 717 |
} |
| 718 |
} |
| 719 |
} |
| 720 |
|
| 721 |
func divorced(fam) { |
| 722 |
fornodes(fnode(fam), node) { |
| 723 |
if (eq(0, strcmp(tag(node), "DIV"))) { |
| 724 |
return(node) |
| 725 |
} |
| 726 |
} |
| 727 |
return(0) |
| 728 |
} |
| 729 |
|
| 730 |
proc scan_events(indi, flag) { |
| 731 |
set(sourcnt,sour_count) |
| 732 |
fornodes(inode(indi),e) { |
| 733 |
set(match,1) |
| 734 |
if (eq(0, strcmp(tag(e), "BIRT"))) { |
| 735 |
set (type,"Birth") |
| 736 |
} elsif (eq(0, strcmp(tag(e), "DEAT"))) { |
| 737 |
set (type,"Death") |
| 738 |
} elsif (eq(0, strcmp(tag(e), "BAPL"))) { |
| 739 |
set (type,"Baptism") |
| 740 |
} elsif (eq(0, strcmp(tag(e), "CHR"))) { |
| 741 |
set (type,"Christening") |
| 742 |
} elsif (eq(0, strcmp(tag(e), "BURI"))) { |
| 743 |
set (type,"Burial") |
| 744 |
} elsif (eq(0, strcmp(tag(e), "BAPT"))) { |
| 745 |
set (type,"Baptism") |
| 746 |
} elsif (eq(0, strcmp(tag(e), "BAPM"))) { |
| 747 |
set (type,"Baptism") |
| 748 |
} else { |
| 749 |
set(match,0) |
| 750 |
} |
| 751 |
if (eq(match,1)) { |
| 752 |
if (flag) { |
| 753 |
/* flag == 1 print notes with sources */ |
| 754 |
print_sources(e,type) |
| 755 |
} else { |
| 756 |
"<EM>" type "</EM> : " long(e) |
| 757 |
fornodes(e, s) { |
| 758 |
if (and(eqstr(tag(s), "SOUR"),nestr(value(s),""))) { |
| 759 |
incr(sourcnt) |
| 760 |
" [<A HREF=\"#" d(sourcnt) "\">" d(sourcnt) "</A>]" |
| 761 |
} |
| 762 |
} |
| 763 |
"<BR>\n" |
| 764 |
} |
| 765 |
} |
| 766 |
} |
| 767 |
} |
| 768 |
|
| 769 |
func print_sources(e,t) { |
| 770 |
fornodes(e, s) { |
| 771 |
if (and(eqstr(tag(s), "SOUR"),nestr(value(s),""))) { |
| 772 |
incr(sour_count) |
| 773 |
"<P>\n<A NAME=\"" d(sour_count) "\">[<B>" d(sour_count) |
| 774 |
"</B>]</A>[Source " t "]\n" value(s) nl() |
| 775 |
fornodes(s, n) { |
| 776 |
set(hdr,"") |
| 777 |
if (eqstr(tag(n), "NOTE")) { set(hdr,"Note") } |
| 778 |
elsif(eqstr(tag(n),"NOTE_L")) { set(hdr,"Note_L") } |
| 779 |
elsif(eqstr(tag(n),"NOTE_Q")) { set(hdr,"Note_Q") } |
| 780 |
elsif(eqstr(tag(n),"NOTE_E")) { set(hdr,"Note_E") } |
| 781 |
if (strcmp(hdr,"")) { |
| 782 |
set(s, value(n)) |
| 783 |
if (and(strcmp("",s),reference(s))) { |
| 784 |
set(n,dereference(s)) |
| 785 |
set(hdr,save(concat(hdr," ",s))) |
| 786 |
} |
| 787 |
print_note(n,hdr) |
| 788 |
} |
| 789 |
} |
| 790 |
} |
| 791 |
} |
| 792 |
} |
| 793 |
|
| 794 |
func print_note(node,hdr) { |
| 795 |
"<P class=\"hindent\">\n" |
| 796 |
"<EM>" hdr "</EM>: " |
| 797 |
if (strcmp("",value(node))) { |
| 798 |
value(node) nl() |
| 799 |
} |
| 800 |
fornodes(node,next) { |
| 801 |
set(ctag,tag(next)) |
| 802 |
if (or(eqstr("CONT",ctag),eqstr("CONC",ctag))) { |
| 803 |
if (eqstr("CONT",ctag)) { "<BR>" nl() } |
| 804 |
value(next) |
| 805 |
} |
| 806 |
} |
| 807 |
"</P>\n" |
| 808 |
} |
| 809 |
|
| 810 |
func get_picture (indi) { |
| 811 |
/* Note: this code assumes the following tag sturcture |
| 812 |
return found==1 if url, found==2 if FILE |
| 813 |
|
| 814 |
1 _PIC |
| 815 |
2 FILE pics/scott.gif |
| 816 |
2 DATE Jul 1989 |
| 817 |
1 _PIC |
| 818 |
2 URL http://www.someurl.net/~user/userpic.gif |
| 819 |
|
| 820 |
where the first defines an external file stored on the same file |
| 821 |
system and gives the path in the FILE record and the type in the |
| 822 |
FORM record. The second defines an external file stored on another |
| 823 |
site and provides a URL for referencing it. I have proposed this as |
| 824 |
an extension to GEDCOM, but nobody said very much. |
| 825 |
*/ |
| 826 |
|
| 827 |
set(found, 0) |
| 828 |
set(path, "") |
| 829 |
fornodes(inode(indi), node) { |
| 830 |
if (eqstr("_PIC", tag(node))) { |
| 831 |
set(m, child(node)) |
| 832 |
/* files on local system or file on remote system */ |
| 833 |
if (or(eqstr("FILE", tag(m)),eqstr("URL", tag(m)))) { |
| 834 |
set(path, value(m)) |
| 835 |
incr(found) |
| 836 |
if (eqstr("FILE",tag(m))) { incr(found) } |
| 837 |
} |
| 838 |
} |
| 839 |
} |
| 840 |
return(path) |
| 841 |
} |
| 842 |
|
| 843 |
proc pedigree (level, indi) { |
| 844 |
set(has_parent, or(father(indi), mother(indi))) |
| 845 |
if (and(lt(level, 4), has_parent)) { |
| 846 |
call pedigree(add(1,level), father(indi)) |
| 847 |
} |
| 848 |
if (indi) { |
| 849 |
col(mul(4,level)) |
| 850 |
call name_href(indi,le(level,3)) |
| 851 |
nl() |
| 852 |
} else { |
| 853 |
col(mul(4,level)) |
| 854 |
"(Spouse not known)" |
| 855 |
nl() |
| 856 |
} |
| 857 |
if (and(lt(level, 4), has_parent)) { |
| 858 |
call pedigree(add(1,level), mother(indi)) |
| 859 |
} |
| 860 |
} |
| 861 |
|
| 862 |
/* startfam: |
| 863 |
If we haven't reached the maximum or specified generation count, |
| 864 |
call dofam for each child in this family. |
| 865 |
Otherwise, print a message line if there are further descendants |
| 866 |
at this point. |
| 867 |
*/ |
| 868 |
proc startfam (fam,prefix,level,isstep) { |
| 869 |
if (le(level,gens)) { /* if not at last generation */ |
| 870 |
children (fam,child,num) { /* for each child */ |
| 871 |
call dofam (child, /* call dofam */ |
| 872 |
concat(prefix, indentpre), |
| 873 |
add(level,1), |
| 874 |
isstep) |
| 875 |
} |
| 876 |
} else { /* don't do this generation */ |
| 877 |
if (gt(nchildren(fam),0)) { /* but if there are children, */ |
| 878 |
/* issue message */ |
| 879 |
prefix " [[Further descendants here" |
| 880 |
if (eq(isstep,1)) { |
| 881 |
" (stepchildren)" |
| 882 |
} |
| 883 |
".]]\n" |
| 884 |
incr(linecount) |
| 885 |
} |
| 886 |
} |
| 887 |
} |
| 888 |
|
| 889 |
/* dofam: |
| 890 |
Write out a person and check for spouses and children. |
| 891 |
Each spouse is written, then this routine is called |
| 892 |
recursively for each child. An incremented level is passed along |
| 893 |
in case the user specified a limited number of generations |
| 894 |
*/ |
| 895 |
|
| 896 |
proc dofam (nm,prefix,level,isstep) { |
| 897 |
set(pre,mainpre) |
| 898 |
call printpers(nm,concat(prefix,pre),0,0) /* print this person */ |
| 899 |
if (and(ge(linecount,MAXLINES),gt(nfamilies(nm),0))) { |
| 900 |
prefix " [[Reached line count max." |
| 901 |
" May be further descendants here." |
| 902 |
"]]\n" |
| 903 |
} else { |
| 904 |
families(nm, fam, spouse, num) { /* do for each family */ |
| 905 |
if (ne(spouse,null)) { /* if there is a spouse */ |
| 906 |
/* print spouse */ |
| 907 |
call printpers(spouse,concat(prefix,spousepre),1,fam) |
| 908 |
if (and(ge(linecount,MAXLINES),gt(nchildren(fam),0))) { |
| 909 |
prefix " [[Reached line count max." |
| 910 |
" May be further descendants here." |
| 911 |
"]]\n" |
| 912 |
} else { |
| 913 |
families (spouse, spsfam, ospouse, num2) { |
| 914 |
/* for each of the spouse families*/ |
| 915 |
if(eq(fam,spsfam)){ /* only non-step families */ |
| 916 |
call startfam (spsfam,prefix,level,0) |
| 917 |
} |
| 918 |
} /*end spouse's families*/ |
| 919 |
} /* end spouse not ge MAXLINES */ |
| 920 |
} else { /* there is no spouse */ |
| 921 |
call startfam (fam,prefix,level,0) |
| 922 |
} /*end else no spouse*/ |
| 923 |
} /*end 'families'*/ |
| 924 |
} /* end MAXLINES else */ |
| 925 |
} /*end 'proc dofam'*/ |
| 926 |
|
| 927 |
|
| 928 |
/* printpers: |
| 929 |
Write output line for one person. |
| 930 |
Include birth and death dates if known. |
| 931 |
For a spouse, include marriage date if known. |
| 932 |
*/ |
| 933 |
proc printpers (nm, prefix, spouse, fam) { |
| 934 |
prefix |
| 935 |
if(nfamilies(nm)){ |
| 936 |
set(hasChildren, 0) |
| 937 |
families(nm, f, s, n){ |
| 938 |
if(nchildren(f)){ |
| 939 |
set(hasChildren, 1) |
| 940 |
} |
| 941 |
} |
| 942 |
} |
| 943 |
call name_href(nm,1) |
| 944 |
if (e, marriage(fam)) { |
| 945 |
"\t m. " stddate(e) |
| 946 |
} |
| 947 |
"\n" |
| 948 |
incr(linecount) |
| 949 |
} /* end proc printpers */ |