Debian Codegraph @

reports/dump_html.ll

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