File: name2html.ll

package info (click to toggle)
lifelines 3.0.50-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 11,140 kB
  • ctags: 6,517
  • sloc: ansic: 57,468; xml: 8,014; sh: 4,255; makefile: 848; yacc: 601; perl: 170; sed: 16
file content (402 lines) | stat: -rw-r--r-- 8,176 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
/*
 * @progname       name2html.ll
 * @version        1.5
 * @author         Scott McGee
 * @category       
 * @output         HTML
 * @description

Converts the selected indi record to an HTML file.

This program is based primarily on my version of indi2html with additions
(based on suggestions by Tom Westmore) to handle name lookup and possible
multiple matches.

@(#)name2html.ll	1.5 10/6/95
*/

include("cgi_html.li")
include("tools.li")

global(found)  /* external file to inline found */
global(path)   /* path to external file to inline */
global(LDS)    /* report LDS ordinaces (1=yes 0=no) */

proc main (){
  call set_cgi_html_globals()
  set(is_indi_html, 1)

  set(LDS, 1)
  getindiset(iset, "What name to you want an HTML file for?")
  if (eq(1, lengthset(iset))) {
	forindiset(iset, i, v, n) {
		set(indi, i)
	}
	call genhtml(indi)
  } elsif (ne(0, lengthset(iset))) {
    call list_to_html(iset)
  }
  else {
    "<HTML><HEAD>\n"
    "<TITLE>No Match</TITLE>\n"
    "</HEAD><BODY>\n"
    if(use_image){
      "<IMG SRC=\""
      genweb_image
      "\" ALT = \"\"><BR><BR>\n"
    }
    "<H1>No Match</H1>\n"
    "Sorry, no match was found for the requested name!\n"
    "</BODY></HTML>\n"
  }
}

proc genhtml (i){
  html_head(i)

  call afn(i)
  if (e, birth(i)) {
    "<EM>Born</EM> : " long(e) "<BR>\n"
  }
  if (e, baptism(i)) {
    "<EM>Baptised</EM> : " long(e) "<BR>\n"
  }
  elsif (e, bapt(i)) {
    "<EM>Baptised</EM> : " long(e) "<BR>\n"
  }
  if (e, death(i)) {
    "<EM>Died</EM> : " long(e) "<BR>\n"
  }
  if (e, burial(i)) {
    "<EM>Buried</EM> : " long(e) "<BR>	\n"
  }
  if(LDS) {
    /* LDS ordinances */
    set(started, 0)
    fornodes(inode(i), node) {
      if (eq(0, strcmp(tag(node), "BAPL"))) {
        if(not(started)) {
          set(started, 1)
          "<BR>LDS Ordinances: B "
        }
      }
      /* determine if endowed */
      if (eq(0, strcmp(tag(node), "ENDL"))) {
        if(not(started)) {
          set(started, 1)
          "<BR>LDS Ordinances: "
        }
        "E "
      }
    }
    /* determine if sealed to parents */
    set(fam, parents(i))
    if(fam){
      set(val, concat("@", key(i), "@"))
      fornodes(fnode(fam), node) {
        if (eq(0, strcmp(tag(node), "CHIL"))) {
          if (eq(0, strcmp(value(node), val))) {
            fornodes(node, next) {
              if (eq(0, strcmp(tag(next), "SLGC"))) {
                if(not(started)) {
                  set(started, 1)
                  "<BR>LDS Ordinances: "
                }
                "SC "
              }
            }
          }
        }
      }
    }
    if(started){
      "<BR>\n"
    }
  }
  call othernames(i)
  call print_html(i)
  set(hasChildren, 0)
  if(nfamilies(i)){
    families(i, f, s, n){
      if(nchildren(f)){
        set(hasChildren, 1)
      }
    }
  }
  "<HR>\n"
  if (p, father(i)) {
    "<EM>" "Father</EM> : \n"
    href(p, "Lookup")
    do_info(p)
    "<BR>\n"
  }
  if (p, mother(i)) {
    "<EM>" "Mother</EM> : "
    href(p, "Lookup")
    do_info(p)
    "<BR>\n"
  }
  families(i, f, s, n) {
    "<P><EM>" "Spouse"
    if (gt(nfamilies(i), 1)){
      " "
      d(n) 
    }
    "</EM> : \n"
    if (s) {	/* family has a spouse */
      href(s, "Lookup")
      do_info(s)
      "<BR>\n"
    }else{
      "(unknown)<BR>"
    }
    if (e, marriage(f)) {"<EM>Married</EM> " long(e) "<BR>\n"}
    if (e, divorced(f)) {"<EM>Divorced</EM> " long(e) "<BR>\n"}
    if(LDS) {
      /* determine if sealed to parents */
      fornodes(fnode(f), node) {
        if (eq(0, strcmp(tag(node), "SLGS"))) {
          "LDS Ordinances: SS <BR>"
        }
      }
    }
    if(nchildren(f)){
    "<EM>Children</EM> :<OL>\n"
    children(f, c, nn) {
      "<LI>"
      href(c, "Lookup")
      do_info(c)
    }
    "</OL>\n"
    }else{
      "(no children)<BR>\n"
    }
  }
  call print_notes(i)
  "<HR>\n"
  if(parents(i)){
    "[<A HREF=\""
    cgi_script
    "/DB="
    database()
    "/INDEX=" 
    key(i) 
    "/?PedigreeInternal\">" 
    "Pedigree Chart</A>]<BR>\n"
  }
  if(hasChildren){
    "[<A HREF=\""
    cgi_script
    "/DB="
    database()
    "/INDEX=" 
    key(i) 
    "/?DescendantInternal\">" 
    "Descendant Chart</A>]<BR>\n"
  }
  call do_tail(i)
}

proc print_notes(indi){
  set(first, 1)
  traverse(inode(indi), node, l) {
    if (not(strcmp("NOTE", tag(node)))) {
      if(first) {
        "<EM>Notes</EM> : <BR>\n"
        set(first, 0)
      }
      "<P>"
      call show_path(node)
      value(node)
      "\n"
      fornodes(node, next) {
        value(next)
        "\n"
      }
      "</P>\n"
    }
  }
}

proc show_path (node){
  list(path)
  while (node) {
    push(path, tag(node))
    set(node, parent(node))
  }
  "("
  while (s, pop(path)) {
    if(not(strcmp(lower(s), "indi"))){
      "Individual "
    }elsif(not(strcmp(lower(s), "fam"))){
      "Family "
    }elsif(not(strcmp(lower(s), "famc"))){
      "family "
    }elsif(not(strcmp(lower(s), "fams"))){
      "family "
    }elsif(not(strcmp(lower(s), "note"))){
      "note"
    }elsif(not(strcmp(lower(s), "birt"))){
      "birth "
    }elsif(not(strcmp(lower(s), "deat"))){
      "death "
    }elsif(not(strcmp(lower(s), "buri"))){
      "burial "
    }elsif(not(strcmp(lower(s), "plac"))){
      "place "
    }else{
      lower(s)
      " "
    }
  }
  ") "
}

proc list_to_html (iset) {
  "<HTML><HEAD>\n"
  "<TITLE>Multiple Matches</TITLE>\n"
  "</HEAD><BODY>\n"
  "<H1>Multiple Matches</H1>\n"
  "More than one person in the database matched the name search. They are:\n"
  "<BR><HR>\n"
  forindiset(iset, i, v, n) {
    href(i, "Lookup")
    do_info(i)
    "<BR>\n"
  }
  call do_tail(0)
}

func do_info(me){
  if(not(me)){
    return("")
  }else{
    set(out, " -")
    if (evt, birth(me)) {
      set(out, concat(out, " born ", short(evt)))
    }
    else {
      if (evt, baptism(me)) {
        set(out, concat(out, " baptised ", short(evt)))
      }
      else {
        if (evt, bapt(me)) {
          set(out, concat(out, " baptised ", short(evt)))
        }
      }
    }
    if (evt, death(me)) {
      set(out, concat(out, " died ", short(evt)))
    }
    return(out)
  }
}

proc othernames(indi){
  if(indi){
    set(count, 0)
    fornodes(inode(indi), subnode){
      if(eqstr(tag(subnode), "NAME")){
        incr(count)
        if(eq(count, 2)){
          "<BR><EM>Other Names</EM>: \n<UL>"
          "<LI>"
          call nameval(subnode)
          "</LI>"
        }elsif(gt(count, 2)){
          "<LI>"
          call nameval(subnode)
          "</LI>\n"
        }
      }
    }
    if(gt(count, 1)){
      "</UL>\n"
    }
  }
}

proc nameval(namenode){
  list(np)
  extractnames(namenode, np, nc, sc)
  forlist(np, v, i){
    v
    " "
  }
}

proc afn(indi){
  if(indi){
    fornodes(inode(indi), subnode){
      if(eqstr(tag(subnode), "AFN")){
        "AFN "
        value(subnode)
        "<BR><BR>\n"
      }
    }
  }
}

func divorced(fam) {
  fornodes(fnode(fam), node) {
    if (eq(0, strcmp(tag(node), "DIV"))) {
      return(node)
    }
  }
  return(0)
}

proc print_html(indi){
  fornodes(inode(indi), node) {
    if (not(strcmp("REPORT", tag(node)))) {
      set(m, child(node))
      if (not(strcmp("TYPE", tag(m)))) {
        if (or(not(strcmp("HTML", value(m))), 
              not(strcmp("HTML-CGI", value(m))))) {
          "<BR>\n"
          fornodes(m, o) {
            if (not(strcmp("DATA", tag(o)))) {
              value(o)
              "\n"
            }
          }
        }
      }
    }
  }
}


func html_head(i){
  "<HTML><HEAD>\n"
  "<TITLE>" key(i) ": " name(i,0) "\n</TITLE>\n" "</HEAD><BODY>\n"
  if(use_image){
    "<IMG SRC=\""
    genweb_image
    "\" ALT = \"\"><BR><BR>\n"
  }
  "<H1>" 
  set(vn,givens(i))
  set(vn1,save(vn)) 
  givens(i)
  " " 
  set(nn,surname(i))
  set(nn1,save(nn))
  nn1
  "</H1>\n"
  set(path, get_picture(i))
  if (found) {
    "<IMG SRC =\""
    if(nestr(lower(trim(path, 4)), "http")) {
      if(nestr(lower(trim(path, 3)), "ftp")) {
        if(nestr(lower(trim(path, 5)), "file:")) {
          if(nestr(lower(trim(path, 6)), "gopher")) {
            localhost
          }
        }
      }
    }
    path
    "\" ALT = \"\"><BR><BR>\n"
  }
}