More describers
[hcoop/domtool2.git] / src / plugins / mailman.sml
1 (* HCoop Domtool (http://hcoop.sourceforge.net/)
2 * Copyright (c) 2006, Adam Chlipala
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *)
18
19 (* Mailman mailing list handling *)
20
21 structure Mailman :> MAILMAN = struct
22
23 val files = ref ([] : TextIO.outstream list)
24 val write = ref (fn _ : string => ())
25
26 val () = Env.action_one "mailmanWebHost"
27 ("hostname", Env.string)
28 (fn host =>
29 let
30 val {write, writeDom, close} = Domain.domainsFile {node = Config.Mailman.node,
31 name = "mailman"}
32 in
33 write "\t'";
34 write host;
35 write "' : '";
36 writeDom ();
37 write "',\n";
38 close ()
39 end)
40
41 val mailmanChanged = ref false
42
43 val () = Slave.registerPreHandler (fn () => mailmanChanged := false)
44
45 val () = Slave.registerFileHandler (fn fs =>
46 let
47 val spl = OS.Path.splitDirFile (#file fs)
48 in
49 case #file spl of
50 "mailman" => mailmanChanged := true
51 | _ => ()
52 end)
53
54 val () = Slave.registerPostHandler (fn () =>
55 if !mailmanChanged then
56 (Slave.concatTo (fn s => s = "mailman")
57 Config.Mailman.mapFile;
58 Slave.enumerateTo (fn s => s = "mailman") ":"
59 Config.Mailman.handleDomains;
60 Slave.shellF ([Config.Mailman.reload],
61 fn cl => "Error reloading Mailman with " ^ cl))
62 else
63 ())
64
65 val () = Domain.registerDescriber (Domain.considerAll
66 [Domain.Filename {filename = "mailman",
67 heading = "Mailman web host mapping",
68 showEmpty = false}])
69
70 end