Debian Codegraph @

reports/name2html.ll

raw
1 /*
2 * @progname name2html.ll
3 * @version 1.5
4 * @author Scott McGee
5 * @category
6 * @output HTML
7 * @description
8
9 Converts the selected indi record to an HTML file.
10
11 This program is based primarily on my version of indi2html with additions
12 (based on suggestions by Tom Westmore) to handle name lookup and possible
13 multiple matches.
14
15 @(#)name2html.ll 1.5 10/6/95
16 */
17
18 include("cgi_html.li")
19 include("tools.li")
20
21 global(found) /* external file to inline found */
22 global(path) /* path to external file to inline */
23 global(LDS) /* report LDS ordinaces (1=yes 0=no) */
24
25 proc main (){
26 call set_cgi_html_globals()
27 set(is_indi_html, 1)
28
29 set(LDS, 1)
30 getindiset(iset, "What name to you want an HTML file for?")
31 if (eq(1, lengthset(iset))) {
32 forindiset(iset, i, v, n) {
33 set(indi, i)
34 }
35 call genhtml(indi)
36 } elsif (ne(0, lengthset(iset))) {
37 call list_to_html(iset)
38 }
39 else {
40 "<HTML><HEAD>\n"
41 "<TITLE>No Match</TITLE>\n"
42 "</HEAD><BODY>\n"
43 if(use_image){
44 "<IMG SRC=\""
45 genweb_image
46 "\" ALT = \"\"><BR><BR>\n"
47 }
48 "<H1>No Match</H1>\n"
49 "Sorry, no match was found for the requested name!\n"
50 "</BODY></HTML>\n"
51 }
52 }
53
54 proc genhtml (i){
55 html_head(i)
56
57 call afn(i)
58 if (e, birth(i)) {
59 "<EM>Born</EM> : " long(e) "<BR>\n"
60 }
61 if (e, baptism(i)) {
62 "<EM>Baptised</EM> : " long(e) "<BR>\n"
63 }
64 elsif (e, bapt(i)) {
65 "<EM>Baptised</EM> : " long(e) "<BR>\n"
66 }
67 if (e, death(i)) {
68 "<EM>Died</EM> : " long(e) "<BR>\n"
69 }
70 if (e, burial(i)) {
71 "<EM>Buried</EM> : " long(e) "<BR> \n"
72 }
73 if(LDS) {
74 /* LDS ordinances */
75 set(started, 0)
76 fornodes(inode(i), node) {
77 if (eq(0, strcmp(tag(node), "BAPL"))) {
78 if(not(started)) {
79 set(started, 1)
80 "<BR>LDS Ordinances: B "
81 }
82 }
83 /* determine if endowed */
84 if (eq(0, strcmp(tag(node), "ENDL"))) {
85 if(not(started)) {
86 set(started, 1)
87 "<BR>LDS Ordinances: "
88 }
89 "E "
90 }
91 }
92 /* determine if sealed to parents */
93 set(fam, parents(i))
94 if(fam){
95 set(val, concat("@", key(i), "@"))
96 fornodes(fnode(fam), node) {
97 if (eq(0, strcmp(tag(node), "CHIL"))) {
98 if (eq(0, strcmp(value(node), val))) {
99 fornodes(node, next) {
100 if (eq(0, strcmp(tag(next), "SLGC"))) {
101 if(not(started)) {
102 set(started, 1)
103 "<BR>LDS Ordinances: "
104 }
105 "SC "
106 }
107 }
108 }
109 }
110 }
111 }
112 if(started){
113 "<BR>\n"
114 }
115 }
116 call othernames(i)
117 call print_html(i)
118 set(hasChildren, 0)
119 if(nfamilies(i)){
120 families(i, f, s, n){
121 if(nchildren(f)){
122 set(hasChildren, 1)
123 }
124 }
125 }
126 "<HR>\n"
127 if (p, father(i)) {
128 "<EM>" "Father</EM> : \n"
129 href(p, "Lookup")
130 do_info(p)
131 "<BR>\n"
132 }
133 if (p, mother(i)) {
134 "<EM>" "Mother</EM> : "
135 href(p, "Lookup")
136 do_info(p)
137 "<BR>\n"
138 }
139 families(i, f, s, n) {
140 "<P><EM>" "Spouse"
141 if (gt(nfamilies(i), 1)){
142 " "
143 d(n)
144 }
145 "</EM> : \n"
146 if (s) { /* family has a spouse */
147 href(s, "Lookup")
148 do_info(s)
149 "<BR>\n"
150 }else{
151 "(unknown)<BR>"
152 }
153 if (e, marriage(f)) {"<EM>Married</EM> " long(e) "<BR>\n"}
154 if (e, divorced(f)) {"<EM>Divorced</EM> " long(e) "<BR>\n"}
155 if(LDS) {
156 /* determine if sealed to parents */
157 fornodes(fnode(f), node) {
158 if (eq(0, strcmp(tag(node), "SLGS"))) {
159 "LDS Ordinances: SS <BR>"
160 }
161 }
162 }
163 if(nchildren(f)){
164 "<EM>Children</EM> :<OL>\n"
165 children(f, c, nn) {
166 "<LI>"
167 href(c, "Lookup")
168 do_info(c)
169 }
170 "</OL>\n"
171 }else{
172 "(no children)<BR>\n"
173 }
174 }
175 call print_notes(i)
176 "<HR>\n"
177 if(parents(i)){
178 "[<A HREF=\""
179 cgi_script
180 "/DB="
181 database()
182 "/INDEX="
183 key(i)
184 "/?PedigreeInternal\">"
185 "Pedigree Chart</A>]<BR>\n"
186 }
187 if(hasChildren){
188 "[<A HREF=\""
189 cgi_script
190 "/DB="
191 database()
192 "/INDEX="
193 key(i)
194 "/?DescendantInternal\">"
195 "Descendant Chart</A>]<BR>\n"
196 }
197 call do_tail(i)
198 }
199
200 proc print_notes(indi){
201 set(first, 1)
202 traverse(inode(indi), node, l) {
203 if (not(strcmp("NOTE", tag(node)))) {
204 if(first) {
205 "<EM>Notes</EM> : <BR>\n"
206 set(first, 0)
207 }
208 "<P>"
209 call show_path(node)
210 value(node)
211 "\n"
212 fornodes(node, next) {
213 value(next)
214 "\n"
215 }
216 "</P>\n"
217 }
218 }
219 }
220
221 proc show_path (node){
222 list(path)
223 while (node) {
224 push(path, tag(node))
225 set(node, parent(node))
226 }
227 "("
228 while (s, pop(path)) {
229 if(not(strcmp(lower(s), "indi"))){
230 "Individual "
231 }elsif(not(strcmp(lower(s), "fam"))){
232 "Family "
233 }elsif(not(strcmp(lower(s), "famc"))){
234 "family "
235 }elsif(not(strcmp(lower(s), "fams"))){
236 "family "
237 }elsif(not(strcmp(lower(s), "note"))){
238 "note"
239 }elsif(not(strcmp(lower(s), "birt"))){
240 "birth "
241 }elsif(not(strcmp(lower(s), "deat"))){
242 "death "
243 }elsif(not(strcmp(lower(s), "buri"))){
244 "burial "
245 }elsif(not(strcmp(lower(s), "plac"))){
246 "place "
247 }else{
248 lower(s)
249 " "
250 }
251 }
252 ") "
253 }
254
255 proc list_to_html (iset) {
256 "<HTML><HEAD>\n"
257 "<TITLE>Multiple Matches</TITLE>\n"
258 "</HEAD><BODY>\n"
259 "<H1>Multiple Matches</H1>\n"
260 "More than one person in the database matched the name search. They are:\n"
261 "<BR><HR>\n"
262 forindiset(iset, i, v, n) {
263 href(i, "Lookup")
264 do_info(i)
265 "<BR>\n"
266 }
267 call do_tail(0)
268 }
269
270 func do_info(me){
271 if(not(me)){
272 return("")
273 }else{
274 set(out, " -")
275 if (evt, birth(me)) {
276 set(out, concat(out, " born ", short(evt)))
277 }
278 else {
279 if (evt, baptism(me)) {
280 set(out, concat(out, " baptised ", short(evt)))
281 }
282 else {
283 if (evt, bapt(me)) {
284 set(out, concat(out, " baptised ", short(evt)))
285 }
286 }
287 }
288 if (evt, death(me)) {
289 set(out, concat(out, " died ", short(evt)))
290 }
291 return(out)
292 }
293 }
294
295 proc othernames(indi){
296 if(indi){
297 set(count, 0)
298 fornodes(inode(indi), subnode){
299 if(eqstr(tag(subnode), "NAME")){
300 incr(count)
301 if(eq(count, 2)){
302 "<BR><EM>Other Names</EM>: \n<UL>"
303 "<LI>"
304 call nameval(subnode)
305 "</LI>"
306 }elsif(gt(count, 2)){
307 "<LI>"
308 call nameval(subnode)
309 "</LI>\n"
310 }
311 }
312 }
313 if(gt(count, 1)){
314 "</UL>\n"
315 }
316 }
317 }
318
319 proc nameval(namenode){
320 list(np)
321 extractnames(namenode, np, nc, sc)
322 forlist(np, v, i){
323 v
324 " "
325 }
326 }
327
328 proc afn(indi){
329 if(indi){
330 fornodes(inode(indi), subnode){
331 if(eqstr(tag(subnode), "AFN")){
332 "AFN "
333 value(subnode)
334 "<BR><BR>\n"
335 }
336 }
337 }
338 }
339
340 func divorced(fam) {
341 fornodes(fnode(fam), node) {
342 if (eq(0, strcmp(tag(node), "DIV"))) {
343 return(node)
344 }
345 }
346 return(0)
347 }
348
349 proc print_html(indi){
350 fornodes(inode(indi), node) {
351 if (not(strcmp("REPORT", tag(node)))) {
352 set(m, child(node))
353 if (not(strcmp("TYPE", tag(m)))) {
354 if (or(not(strcmp("HTML", value(m))),
355 not(strcmp("HTML-CGI", value(m))))) {
356 "<BR>\n"
357 fornodes(m, o) {
358 if (not(strcmp("DATA", tag(o)))) {
359 value(o)
360 "\n"
361 }
362 }
363 }
364 }
365 }
366 }
367 }
368
369
370 func html_head(i){
371 "<HTML><HEAD>\n"
372 "<TITLE>" key(i) ": " name(i,0) "\n</TITLE>\n" "</HEAD><BODY>\n"
373 if(use_image){
374 "<IMG SRC=\""
375 genweb_image
376 "\" ALT = \"\"><BR><BR>\n"
377 }
378 "<H1>"
379 set(vn,givens(i))
380 set(vn1,save(vn))
381 givens(i)
382 " "
383 set(nn,surname(i))
384 set(nn1,save(nn))
385 nn1
386 "</H1>\n"
387 set(path, get_picture(i))
388 if (found) {
389 "<IMG SRC =\""
390 if(nestr(lower(trim(path, 4)), "http")) {
391 if(nestr(lower(trim(path, 3)), "ftp")) {
392 if(nestr(lower(trim(path, 5)), "file:")) {
393 if(nestr(lower(trim(path, 6)), "gopher")) {
394 localhost
395 }
396 }
397 }
398 }
399 path
400 "\" ALT = \"\"><BR><BR>\n"
401 }
402 }