1 structure Contact
:> CONTACT
=
8 val db
= C
.conn
"dbname='hcoop_hcoop' host='postgres'"
12 fun s
[v
] = C
.stringFromSql v
13 | s _
= raise Fail
"Bad allEmails row"
16 "SELECT v FROM Contact JOIN ContactKind ON knd = ContactKind.id AND ContactKind.name = 'Non-HCoop e-mail' ORDER BY v"
19 fun kindRow
[id
, name
, url
, urlPrefix
, urlPostfix
] =
20 {id
= C
.intFromSql id
,
21 name
= C
.stringFromSql name
,
22 url
= if C
.boolFromSql url
then
23 SOME (C
.stringFromSql urlPrefix
,
24 C
.stringFromSql urlPostfix
)
27 | kindRow _
= raise Fail
"Bad ContactKind row"
29 val kinds
= C
.map db kindRow
"SELECT id, name, url, urlPrefix, urlPostfix FROM ContactKind ORDER BY name"
31 fun doOne (kind
: {id
: int, name
: string, url
: (string * string) option
}) =
35 val name
= C
.stringFromSql name
36 val v
= C
.stringFromSql v
39 print (Web
.html name
);
42 NONE
=> print (Web
.html v
)
45 print (Web
.html (pre ^ v ^ post
));
51 | doOne _
= raise Fail
"Bad Contact row"
55 print
"</h2>\n<ol>\n";
57 C
.app db
doOne ("SELECT name, v FROM Contact JOIN WebUserActive ON usr = WebUserActive.id"
58 ^
" WHERE knd = " ^ C
.intToSql (#id kind
)
59 ^
" ORDER BY name, v");
66 val inf
= TextIO.openIn
"/afs/hcoop.net/user/h/hc/hcoop/contact/peer1.html"
69 case TextIO.inputLine inf
of
71 | SOME line
=> (print line
;
78 print
"<html><head><title>HCoop Emergency Contact Information</title></head><body><h1>HCoop Emergency Contact Information</h1>\n";
80 print
"<h2><a href=\"mailto:?Bcc=";
81 print (String.concatWith
"," (allEmails ()));
82 print
"\">E-mail everyone (off-HCoop addresses)</a></h2>\n\n";
86 print
"<h2>Peer 1 phone numbers</h2>\n\n";
89 print
"</body></html>\n";
92 end handle C
.Sql s
=> (print ("SQL failure: " ^ s ^
"\n");