Debian Codegraph @

reports/extract_html.ll

raw
1 /*
2 * @progname extract_html.ll
3 * @version 1.4
4 * @author Scott McGee ([email protected])
5 * @category
6 * @output HTML
7 * @description
8
9 This program allows the user to select a group of individuals from a database
10 and generate a set of HTML files for them. It allows writing multiple people
11 per HTML file, and will create an index file and a GENWEB.txt file for genweb
12 indexing of the resulting data.
13
14 Before running this program, you will want to customize some global values
15 for your site. In the original release, they are set as follow:
16
17 set(db_owner, getproperty("user.fullname"))
18 set(owner_addr, getproperty("user.email"))
19 set(use_image, 1)
20 set(genweb_image, "../../pics/genweb.gif")
21 set(use_page, 1)
22 set(genweb_page, "../genweb.html")
23 set(page_name, "genweb page")
24 set(html_index, 0)
25
26 The first two sets will get your fullname and email address from the
27 corresponding user properties. They do not require editing this file.
28 The other customizations require editing of this file.
29 It also says to put an image at the top of each HTML file and specifies
30 that the image is called genweb.gif. Next, it specifies that a link to my
31 base page be added to each HTML file, that the location of the base page is
32 genweb.html, and that the text for the link be "genweb page". It also says
33 not to use and <ISINDEX> tag in the INDEX.html file.
34
35 The program, when run, will request a person to start with. It then allows
36 selection of additional people by following family links. It then allows
37 addition of all ancestors of the selected set or of the first individual,
38 and then all descendants of the selected set or of the orignal individual.
39 It also allows addition of all persons with a specified number of relations
40 to any individual in any of the groups added above.
41
42 For each person asked about, you will be given some information on them to
43 aid in deciding if they are the one you want or not. This is similar to a
44 person display when browsing with LifeLines.
45
46 Note: This program will assume that you have a directory called genweb in your
47 output directory (as specified by LL_REPORTS) and will write all output files
48 in that directory. If the genweb directory does NOT exist (at least, with
49 LL302) you will be prompted for the name of each output file. Be aware that
50 if you use this to name the files diffently, the references within the files
51 will NOT be changed to reflect the new file name!
52
53 Future Enhancements (Let me know if you want to do one of these for me!):
54 A hierarchical index would be a nice option.
55 Need to add descendant and ancestor (pedigree) charts.
56 Add seperate page(s) for sources and generate hyperlinks to them.
57
58 Thanks to Tom Wetmore for many small routines that have been addapted for
59 use in this program as well as LifeLines itself.
60
61 Scott McGee
62
63 @(#)extract_html.ll 1.4 10/1/95
64
65 */
66
67 include("extract_set.li")
68 include("tools.li")
69
70 /* customization globals - customize values assigned in main */
71 global(db_owner) /* name of database owner */
72 global(owner_addr) /* url of database owner (mailto or homepage) */
73 global(use_image) /* flag to indicate whether to use genweb image */
74 global(genweb_image) /* name of genweb image to place on each page */
75 global(use_page) /* flag to add link to genweb page or homepage */
76 global(genweb_page) /* URL of base genweb (or homepage) web page */
77 global(page_name) /* name of base genweb (or homepage) web page */
78 global(LDS) /* display LDS Ordinances? (1=yes 0=no) */
79 global(html_index) /* add <ISINDEX> tag to INDEX.html file (1=yes 0=no) */
80
81 /* other globals */
82 global(found) /* external file to inline image found flag */
83 global(per_file) /* number of people per file to write */
84 global(first) /* first person shouldn't be asked about */
85
86 global(RVAL) /* ?? (part of borrowed code) */
87 global(last_surname) /* last surname in index - used for anchors */
88 global(first_indi) /* starting person */
89
90 proc main () {
91
92 indiset(out_set)
93
94 /* customize these globals to customize the output to your site */
95 set(db_owner, getproperty("user.fullname"))
96 set(owner_addr, getproperty("user.email"))
97 set(use_image, 1) /* 1 to use image, 0 to not use image */
98 set(genweb_image, "../../pics/genweb.gif")
99 set(use_page, 1) /* 1 to use link to page, 0 if not */
100 set(genweb_page, "../genweb.html")
101 set(page_name, "genweb page") /* might change to "my homepage" */
102 set(LDS, 1)
103 set(html_index, 0) /* 1 to use <ISINDEX>, 0 if not */
104
105 set(per_file, 1)
106
107 getindi(indi)
108 if (indi) {
109 set(first_indi, indi)
110 set(out, extract_set(indi))
111 call html_out(out)
112 }
113 else {
114 print("No one identified -- terminating\n")
115 }
116 }
117
118 proc html_out (o) {
119 set(s, concat("There are ", d(lengthset(o)),
120 " people in your list, how many per file?"))
121 getstr(a,s)
122 set(per_file, atoi(a))
123 if(not(per_file)) {
124 set(per_file, 1)
125 }
126 set(loop_count, 0)
127 set(file_count, 0)
128 set(href_table, init_href(o))
129 forindiset(o, i, j, n) {
130 set(indi, i)
131 if(eq(loop_count, 0)) {
132 incr(file_count)
133 call write_head(file_count)
134 }
135 incr(loop_count)
136 call genhtml(indi, o, href_table)
137 if(or(eq(loop_count, per_file), eq(n, lengthset(o)))) {
138 call write_tail()
139 set(loop_count, 0)
140 }
141 }
142
143 call do_index(o, href_table)
144
145 }
146
147 proc write_head(count) {
148 set(filename, concat("genweb/", database(), "/genweb_", d(count), ".html"))
149 print("Writing ", filename, "\n")
150 newfile(filename, 0)
151 "<HTML><HEAD>\n"
152 "<TITLE> genweb_"
153 d(count)
154 ".html </TITLE>\n" "</HEAD><BODY>\n"
155 if(use_image) {
156 "<IMG SRC=\""
157 genweb_image
158 "\" ALT = \"\"><BR><BR>\n"
159 }
160 }
161
162 proc write_tail() {
163 "<BR><HR><ADDRESS>\n"
164 date(gettoday())
165 "<BR>\n"
166 "Database maintained by "
167 "<A HREF=\"" owner_addr "\">\n"
168 db_owner
169 "</A></ADDRESS>\n"
170 "</BODY></HTML>\n"
171 }
172
173 proc genhtml (i, o, href_table) {
174 /* print(" ", fullname(i,0,1,300), "\n") */
175 "<A NAME=\""
176 key(i)
177 "\"></A>\n"
178 "<H1>"
179 set(vn,givens(i))
180 set(vn1,save(vn))
181 givens(i)
182 " "
183 set(nn,surname(i))
184 set(nn1,save(nn))
185 nn1
186 "</H1>\n"
187 set(path, get_picture(i))
188 if (found) {
189 "<IMG SRC =\""
190 if(nestr(lower(trim(path, 4)), "http")) {
191 if(nestr(lower(trim(path, 3)), "ftp")) {
192 if(nestr(lower(trim(path, 5)), "file:")) {
193 if(nestr(lower(trim(path, 6)), "gopher")) {
194 "../"
195 }
196 }
197 }
198 }
199 path
200 "\" ALT = \"\"><BR><BR>\n"
201 }
202 call afn(i)
203 if (e, birth(i)) {
204 "<EM>Born</EM> : " long(e) "<BR>\n"
205 }
206 if (e, baptism(i)) {
207 "<EM>Baptised</EM> : " long(e) "<BR>\n"
208 }
209 elsif (e, bapt(i)) {
210 "<EM>Baptised</EM> : " long(e) "<BR>\n"
211 }
212 if (e, death(i)) {
213 "<EM>Died</EM> : " long(e) "<BR>\n"
214 }
215 if (e, burial(i)) {
216 "<EM>Buried</EM> : " long(e) "<BR> \n"
217 }
218 if(LDS) {
219 /* LDS ordinances */
220 set(started, 0)
221 fornodes(inode(i), node) {
222 if (eq(0, strcmp(tag(node), "BAPL"))) {
223 if(not(started)) {
224 set(started, 1)
225 "<BR>LDS Ordinances: B "
226 }
227 }
228 /* determine if endowed */
229 if (eq(0, strcmp(tag(node), "ENDL"))) {
230 if(not(started)) {
231 set(started, 1)
232 "<BR>LDS Ordinances: "
233 }
234 "E "
235 }
236 }
237 /* determine if sealed to parents */
238 set(fam, fnode(parents(i)))
239 set(ind, inode(i))
240 if(fam) {
241 fornodes(fam, node) {
242 if(and(eqstr("CHIL", tag(node)), eqstr(xref(ind), value(node)))) {
243 fornodes(node, next) {
244 if(eqstr(tag(next), "SLGC")) {
245 if(not(started)) {
246 set(started, 1)
247 "<BR>LDS Ordinances: "
248 }
249 "SC "
250 }
251 }
252 }
253 }
254 }
255 if(started){
256 "<BR>\n"
257 }
258 }
259 /* "<BR>" */
260 call othernames(i)
261 call print_html(i)
262 "<HR>\n"
263 if (p, father(i)) {
264 "<EM>" "Father</EM> : "
265 set (path, get_href(p, href_table))
266 if(found) {
267 "<A HREF=\""
268 path
269 "#"
270 key(p)
271 "\">"
272 }
273 if (t,title(p)) {t " "}
274 fullname(p,0,1,300)
275 if(found) {"</A>"}
276 do_info(p)
277 "<BR>\n"
278 }
279 if (p, mother(i)) {
280 "<EM>" "Mother</EM> : "
281 set (path, get_href(p, href_table))
282 if(found) {
283 "<A HREF=\""
284 path
285 "#"
286 key(p)
287 "\">"
288 }
289 if (t,title(p)) {t " "}
290 fullname(p,0,1,300)
291 if(found) {"</A>"}
292 do_info(p)
293 "<BR>\n"
294 }
295 families(i, f, s, n) {
296 "<P><EM>" "Spouse"
297 if (gt(nfamilies(i), 1)) {
298 " "
299 d(n)
300 }
301 "</EM> : \n"
302 if (s) { /* family has a spouse */
303 set (path, get_href(s, href_table))
304 if(found) {
305 "<A HREF=\""
306 path
307 "#"
308 key(s)
309 "\">"
310 }
311 if (t,title(s)) {t " "}
312 fullname(s,0,1,300)
313 if(found) {"</A>"}
314 do_info(s)
315 "<BR>\n"
316 }
317 if (e, marriage(f)) {
318 "<EM>Married</EM> "
319 long(e)
320 "<BR>\n"
321 }
322 if (e, divorced(f)) {
323 "<EM>Divorced</EM> "
324 long(e)
325 "<BR>\n"
326 }
327 if(LDS) {
328 fornodes(fnode(f), node) {
329 if (eq(0, strcmp(tag(node), "SLGS"))) {
330 "<BR>LDS Ordinances: SS\n"
331 }
332 }
333 }
334 "<OL>\n"
335 children(f, c, nn) {
336 "<LI>"
337 set (path, get_href(c, href_table))
338 if(found) {
339 "<A HREF=\""
340 path
341 "#"
342 key(c)
343 "\">"
344 }
345 if (t,title(c)) {t " "}
346 fullname(c,0,1,300)
347 if(found) {"</A>"}
348 do_info(c)
349 "</LI>\n"
350 }
351 "</OL>\n"
352 }
353 call print_notes(i)
354 "<HR>\n"
355
356 /* Insert code here for Pedigree and Descendant charts
357 if(parents(i)) {
358 "Pedigree Chart<BR>\n"
359 }
360 if(nfamilies(i)) {
361 set(hasChildren, 0)
362 families(i, f, s, n) {
363 if(nchildren(f)) {
364 set(hasChildren, 1)
365 }
366 }
367 if(hasChildren) {
368 "Descendant Chart\n"
369 }
370 }
371 "<HR>\n"
372 */
373 "<BR>\n"
374 "[<A HREF=\"INDEX.html\">"
375 "Index to database</A>]<BR>\n"
376 if(use_page) {
377 "[<A HREF=\"" genweb_page "\">"
378 "Return to "
379 page_name
380 " </A>]<BR> \n"
381 }
382 "<BR><HR><BR>\n"
383 }
384
385 func init_href(outset){
386 table(href_table)
387
388 forindiset(outset, indi, j, number) {
389 insert(href_table, save(key(indi)), number)
390 }
391 return(href_table)
392 }
393
394 func get_href(indi, href_table) {
395 set(path, "")
396 set(found, 0)
397 set(value, lookup(href_table, key(indi)))
398 if(value){
399 set(number, add(div(sub(value, 1), per_file), 1))
400 set(path, concat("genweb_", d(number), ".html"))
401 set(found, 1)
402 }
403 return(path)
404 }
405
406 proc print_notes(indi){
407 set(first, 1)
408 traverse(inode(indi), node, l) {
409 if (not(strcmp("NOTE", tag(node)))) {
410 if(first) {
411 "<EM>Notes</EM> : <BR>\n"
412 set(first, 0)
413 }
414 "<P>"
415 call show_path(node)
416 value(node)
417 "\n"
418 fornodes(node, next) {
419 value(next)
420 "\n"
421 }
422 "</P>\n"
423 }
424 }
425 }
426
427 proc show_path (node){
428 list(path)
429 while (node) {
430 push(path, tag(node))
431 set(node, parent(node))
432 }
433 "("
434 while (s, pop(path)) {
435 if(eqstr(lower(s), "indi")){
436 "Individual "
437 }elsif(eqstr(lower(s), "fam")){
438 "Family "
439 }elsif(eqstr(lower(s), "famc")){
440 "family "
441 }elsif(eqstr(lower(s), "fams")){
442 "family "
443 }elsif(eqstr(lower(s), "note")){
444 "note"
445 }elsif(eqstr(lower(s), "birt")){
446 "birth "
447 }elsif(eqstr(lower(s), "deat")){
448 "death "
449 }elsif(eqstr(lower(s), "buri")){
450 "burial "
451 }elsif(eqstr(lower(s), "plac")){
452 "place "
453 }else{
454 lower(s)
455 " "
456 }
457 }
458 ")\n"
459 }
460
461 proc do_index(indi_set, href_table) {
462 set(last_surname, "ZZ")
463 list(RVAL)
464 indiset(index)
465
466 set(index, indi_set)
467 namesort(index)
468 print("Writing INDEX.html\n")
469 call create_index_file(index, href_table)
470 print("Writing GENDEX.txt\n")
471 call create_gendex_file(index, href_table)
472 }
473
474 proc create_gendex_file(index, href_table) {
475 set(fn, save(concat("genweb/", database(), "/GENDEX.txt")))
476 newfile(fn, 0)
477 forindiset(index, me, v, n)
478 {
479 set(path, concat(save(get_href(me, href_table)), "#", key(me)))
480 path
481 "|"
482 surname(me)
483 "|"
484 givens(me) " /"
485 surname(me) "/"
486 "|"
487 if (evt, birth(me)) {
488 date(evt)
489 }
490 "|"
491 if (evt, birth(me)) {
492 place(evt)
493 }
494 "|"
495 if (evt, death(me)) {
496 date(evt)
497 }
498 "|"
499 if (evt, death(me)) {
500 place(evt)
501 }
502 "|\n"
503 }
504 }
505
506 proc create_index_file(index, href_table) {
507 set(fn, save(concat("genweb/", database(), "/INDEX.html")))
508 newfile(fn, 0)
509 call html_header("Interactive Genealogical Server Index", html_index)
510 "<BODY>\n"
511 if(use_image) {
512 "<IMG SRC=\""
513 genweb_image
514 "\" ALT = \"\"><BR><BR>\n"
515 }
516 "<H1> INDEX </H1>\n"
517 "<UL>\n"
518 forindiset(index, me, v, n)
519 {
520 call href(me, href_table)
521 "\n"
522 }
523 "</UL>\n"
524 call write_tail()
525 }
526
527 proc href(me, href_table) {
528 if(me) {
529 call print_name(me, 1)
530 if(ne(strcmp(upper(surname(me)), last_surname), 0)) {
531 print(" ", upper(surname(me)), "\n")
532 set(last_surname, save(upper(surname(me))))
533 "<A NAME=" qt() last_surname qt() "></A>\n"
534 }
535 "<LI>"
536 set (path, get_href(me, href_table))
537 if(found) {
538 "<A HREF=\""
539 path
540 "#"
541 key(me)
542 "\">\n"
543 }
544 pop(RVAL)
545 if(found) {
546 "</A>"
547 }
548 do_info(me)
549 }
550 }
551
552 proc html_header(str, isindex) {
553 "<HTML>\n"
554 "<HEAD>\n"
555 if(isindex) {
556 "<ISINDEX>\n"
557 }
558 "<TITLE> "
559 str
560 " </TITLE>\n"
561 "</HEAD>\n"
562 }
563
564 proc print_name (me, last) {
565 call get_title(me)
566 set(junk, pop(RVAL))
567 push(RVAL, save(concat(fullname(me, 1, not(last), 45), junk)))
568 }
569
570 proc get_title (me) {
571 fornodes(inode(me), node) {
572 if (not(strcmp("TITL", tag(node)))) {
573 set(n, node)
574 }
575 }
576 if (n) {
577 push(RVAL, save(concat(" ", value(n))))
578 }
579 else {
580 push(RVAL, "")
581 }
582 }
583
584 proc rjt(n, w) {
585 if (lt(n, 10)) {
586 set(d, 1)
587 }
588 elsif (lt(n, 100)) {
589 set(d, 2)
590 }
591 elsif (lt(n, 1000)) {
592 set(d, 3)
593 }
594 elsif (lt(n, 10000)) {
595 set(d, 4)
596 }
597 else {
598 set(d, 5)
599 }
600 if (lt(d, w)) {
601 set(pad, save( trim(" ", sub(w, d))))
602 }
603 else{
604 set(pad, "")
605 }
606 push(RVAL, save( concat(pad, save(d(n)))))
607 }
608
609 proc othernames(indi){
610 if(indi){
611 set(count, 0)
612 fornodes(inode(indi), subnode){
613 if(eqstr(tag(subnode), "NAME")){
614 incr(count)
615 if(eq(count, 2)){
616 "<BR><EM>Other Names</EM>: \n<UL>"
617 "<LI>"
618 call nameval(subnode)
619 "</LI>"
620 }elsif(gt(count, 2)){
621 "<LI>"
622 call nameval(subnode)
623 "</LI>\n"
624 }
625 }
626 }
627 if(gt(count, 1)){
628 "</UL>\n"
629 }
630 }
631 }
632
633 proc afn(indi){
634 if(indi){
635 fornodes(inode(indi), subnode){
636 if(eqstr(tag(subnode), "AFN")){
637 "AFN "
638 value(subnode)
639 "<BR><BR>\n"
640 }
641 }
642 }
643 }
644
645 proc nameval(namenode){
646 list(np)
647 extractnames(namenode, np, nc, sc)
648 forlist(np, v, i){
649 v
650 " "
651 }
652 }
653
654 proc print_html(indi){
655 fornodes(inode(indi), node) {
656 if (not(strcmp("REPORT", tag(node)))) {
657 set(m, child(node))
658 if (not(strcmp("TYPE", tag(m)))) {
659 if (not(strcmp("HTML", value(m)))) {
660 "<BR>\n"
661 fornodes(m, o) {
662 if (not(strcmp("DATA", tag(o)))) {
663 value(o)
664 "\n"
665 }
666 "\n"
667 }
668 }
669 else {
670 if (eqstr("HTML-STATIC", value(m))) {
671 "<BR>\n"
672 fornodes(m, o) {
673 if (eqstr("DATA", tag(o))) {
674 value(o)
675 "\n"
676 }
677 "\n"
678 }
679 }
680 }
681 }
682 }
683 }
684 }
685
686 func divorced(fam) {
687 fornodes(fnode(fam), node) {
688 if (eq(0, strcmp(tag(node), "DIV"))) {
689 return(node)
690 }
691 }
692 return(0)
693 }