File: html.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 (219 lines) | stat: -rw-r--r-- 6,114 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
/*
 * @progname       html.ll
 * @version        1.0
 * @author         Dave Close, <dave@compata.com>
 * @category
 * @output         HTML
 * @description
 *
 *                 Produces a set of interlinked HTML files, one for each
 *                 person in the data base, and a master name index file.

Here is a report program I've been using to
generate HTML to allow browsing of my data base. It produces one HTML
file for each person in the data base, and a master index file with
links to each of the other files. Each person's file is hyperlinked
to all his direct relatives. I believe the output is standard HTML and
does not use any peculiar extensions, so it should be viewable with
nearly any browser.
Permission is granted to anyone to use this code for any purpose.

It does call the divorce() function which I added to my copy of
Lifelines and posted to this list 2002 November 12.

See:
http://listserv.nodak.edu/cgi-bin/wa.exe?A2=ind0211b&L=lines-l&T=0&F=&S=&P=356
 */

global ( page_width )
global ( left_margin )

proc main ()
{
  set ( page_width, 500 )
  set ( left_margin, 0 )
  indiset ( iset )

  forindi ( indi, ni )
  {
    addtoset ( iset, indi, 1 )

    newfile ( concat ( key ( indi ), ".html" ), 0 )
    "<html>" nl () "<head>" nl ()
    "<title>" name ( indi ) "</title>" nl ()
    "</head>" nl () "<body bgcolor=white>" nl ()
    "<h1>" name ( indi ) "</h1>" nl ()

    /* person */
    if ( male ( indi ) )
    {
      "Male<br>" nl ()
    }
    else
    {
      "Female<br>" nl ()
    }
    dayformat ( 1 ) monthformat ( 1 ) dateformat ( 11 )
    set ( dat, atoi ( stddate ( birth ( indi ) ) ) )
    if ( ne ( dat, 0 ) )
    {
      dayformat ( 2 ) monthformat ( 4 ) dateformat ( 8 )
      "Born: " stddate ( birth ( indi ) ) ", "
      place ( birth ( indi ) ) "<br>" nl ()
    }
    else
    {
      "<font color=red> Birth information missing </font><br>" nl ()
    }
    dayformat ( 1 ) monthformat ( 1 ) dateformat ( 11 )
    set ( dat, atoi ( stddate ( death ( indi ) ) ) )
    if ( ne ( dat, 0 ) )
    {
      dayformat ( 2 ) monthformat ( 4 ) dateformat ( 8 )
      "Died: " stddate ( death ( indi ) ) ", "
      place ( death ( indi ) ) "<br>" nl ()
    }
    "<br>" nl ()

    /* parents */
    set ( pa, father ( indi ) )
    set ( ma, mother ( indi ) )
    if ( eqstr ( key ( pa ), "" ) )
    {
      "<font color=red> Father unknown </font><br>" nl ()
    }
    else
    {
      "Father: <a href=" key ( pa ) ".html>" name ( pa ) "</a><br>" nl ()
    }
    if ( eqstr ( key ( ma ), "" ) )
    {
      "<font color=red> Mother unknown </font><br>" nl ()
    }
    else
    {
      "Mother: <a href=" key ( ma ) ".html>" name ( ma ) "</a><br>" nl ()
    }
    "<br>" nl ()

    /* families */
    if ( gt ( nfamilies ( indi ), 0 ) )
    {
      if ( eq ( nfamilies ( indi ), 1 ) )
      {
        "Family:"
      }
      else
      {
        "Families:"
      }
      "<table border=1>" nl ()
      families ( indi, fam, sp, num )
      {
        "<tr><td valign=top>Spouse: <a href=" key ( sp ) ".html>"
        name ( sp ) "</a><br>" nl ()
        if ( marriage ( fam ) )
        {
          "Married: "
          dayformat ( 1 ) monthformat ( 1 ) dateformat ( 11 )
          set ( dat, atoi ( stddate ( marriage ( fam ) ) ) )
          if ( ne ( dat, 0 ) )
	  {
            dayformat ( 2 ) monthformat ( 4 ) dateformat ( 8 )
            stddate ( marriage ( fam ) ) ", "
	  }
	  else
	  {
	    "<font color=red>Date unknown, </font>"
	  }
	  if ( eqstr ( place ( marriage ( fam ) ), "" ) )
	  {
	    "<font color=red>Place unknown</font><br>" nl ()
	  }
	  else
	  {
            place ( marriage ( fam ) ) "<br>" nl ()
	  }
        }
        if ( divorce ( fam ) )
        {
          "Divorced: "
          dayformat ( 1 ) monthformat ( 1 ) dateformat ( 11 )
          set ( dat, atoi ( stddate ( divorce ( fam ) ) ) )
          if ( ne ( dat, 0 ) )
	  {
            dayformat ( 2 ) monthformat ( 4 ) dateformat ( 8 )
            stddate ( divorce ( fam ) ) ", "
	  }
	  else
	  {
	    "<font color=red>Date unknown, </font>"
	  }
	  if ( eqstr ( place ( divorce ( fam ) ), "" ) )
	  {
	    "<font color=red>Place unknown</font><br>" nl ()
	  }
	  else
	  {
            place ( divorce ( fam ) ) "<br>" nl ()
	  }
        }
        dayformat ( 1 ) monthformat ( 1 ) dateformat ( 11 )
        set ( dsp, atoi ( stddate ( death ( sp ) ) ) )
        set ( din, atoi ( stddate ( death ( indi ) ) ) )
        set ( ddv, atoi ( stddate ( divorce ( fam ) ) ) )
        if ( ne ( dsp, 0 ) )
        {
          if ( lt ( dsp, din ) )
          {
            dayformat ( 2 ) monthformat ( 4 ) dateformat ( 8 )
            "Widowed: " stddate ( death ( sp ) ) "<br>" nl ()
          }
        }
        "</td><td valign=top>"
        if ( eq ( nchildren ( fam ), 0 ) )
        {
          "No children" nl ()
        }
        else
        {
          "Children:<br>" nl () children ( fam, child, no )
          {
            "<a href=" key ( child ) ".html>" name ( child ) "</a><br>" nl ()
          }
        }
        "</td></tr>" nl ()
      }
      "</table>" nl ()
    }
    else
    {
      "<font color=red>No family information known</font><br>" nl ()
    }
    "<br><a href=tree.html> Return to complete list of persons </a>" nl ()
    "</body>" nl () "</html>" nl ()
  }

  newfile ( "tree.html", 0 )
  "<html>" nl () "<head>" nl ()
  "<title> Persons </title>" nl ()
  "</head>" nl () "<body bgcolor=white>" nl ()
  "<p>The following persons are recorded in this data base." nl ()
  "After selecting any one of them, you may proceed directly to their" nl ()
  "direct relatives through additional links, or return to this page.</p>" nl ()
  "<table valign=top><tr><td valign=top>" nl ()
  namesort ( iset )
  set ( n1, lengthset ( iset ) )
  incr ( n1 ) incr ( n1 )
  set ( n2, div ( n1, 3 ) )
  forindiset ( iset, indi, a, b )
  {
    "<a href=" key ( indi ) ".html>"
    surname ( indi ) ", " givens ( indi ) "</a><br>" nl ()
    if ( eq ( mod ( b, n2 ), 0 ) )
    {
      "</td><td valign=top>" nl ()
    }
  }
  "</td></tr></table></body></html>" nl ()
}