Begin generation of public pages
authorAdam Chlipala <adamc@hcoop.net>
Tue, 26 Apr 2005 16:58:04 +0000 (16:58 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Tue, 26 Apr 2005 16:58:04 +0000 (16:58 +0000)
12 files changed:
TODO
list.mlt
pref.mlt [new file with mode: 0644]
pref.sig [new file with mode: 0644]
pref.sml [new file with mode: 0644]
static/.cvsignore [new file with mode: 0644]
static/Makefile [new file with mode: 0644]
static/gen.sh [new file with mode: 0755]
static/gen.sig [new file with mode: 0644]
static/gen.sml [new file with mode: 0644]
static/sources.cm [new file with mode: 0644]
tables.sql

diff --git a/TODO b/TODO
index d2e1f0d..c1fc465 100644 (file)
--- a/TODO
+++ b/TODO
@@ -3,3 +3,5 @@ Member data
 
 Specific requests
        - Join, with display of pending applications for all members to read
+
+Manage mailing list subscriptions
\ No newline at end of file
index 44ffab0..fc59214 100644 (file)
--- a/list.mlt
+++ b/list.mlt
@@ -113,7 +113,9 @@ elseif $"mod" <> "" then
 
 <h3><b>Request new mailing list</b></h3>
 
-Enter here the e-mail address you would like for your list.  Please keep in mind that the part of your list address before the "@" must be unique across all mailing lists we run.  We may reject applications with overly general names here, especially names of current users or UNIX usernames that are likely to be chosen by future members.  The "Reason" field is optional.
+<p>Enter here the e-mail address you would like for your list.  Please keep in mind that the part of your list address before the "@" must be unique across all mailing lists we run.  We may reject applications with overly general names here, especially names of current users or UNIX usernames that are likely to be chosen by future members.  The "Reason" field is optional.</p>
+
+<p>If you want to use the Mailman web interface on your new list, and you want this to appear on a different web virtual host than hcoop.net, you should create a file <tt>.mailman</tt> in the domtool directory for this domain, before submitting a request. In that file, put the hostname of the vhost you want to use.</p>
 
 <form action="list">
 <table>
diff --git a/pref.mlt b/pref.mlt
new file mode 100644 (file)
index 0000000..f4ba6fb
--- /dev/null
+++ b/pref.mlt
@@ -0,0 +1,22 @@
+<% val you = Init.getUserId ();
+
+@header [("title", ["Member preferences"])];
+
+if $"cmd" = "mod" then
+       if $"dir" = "on" then
+               Pref.setDirectory you
+       else
+               Pref.unsetDirectory you
+       end
+
+       %><h3><b>Preferences updated</b></h3><%
+end %>
+
+<form action="pref">
+<input type="hidden" name="cmd" value="mod">
+<table>
+<tr> <td align="right"><input type="checkbox" name="dir"<% if Pref.hasDirectory you then %> checked<% end %>></td> <td>Include me in the public member directory</td> </tr>
+<tr> <td><input type="submit" value="Save"></td> </tr>
+</table>
+
+<% @footer[] %>
\ No newline at end of file
diff --git a/pref.sig b/pref.sig
new file mode 100644 (file)
index 0000000..1bf518a
--- /dev/null
+++ b/pref.sig
@@ -0,0 +1,6 @@
+signature PREF =
+sig
+    val hasDirectory : int -> bool
+    val setDirectory : int -> unit
+    val unsetDirectory : int -> unit
+end
\ No newline at end of file
diff --git a/pref.sml b/pref.sml
new file mode 100644 (file)
index 0000000..9deb6fe
--- /dev/null
+++ b/pref.sml
@@ -0,0 +1,20 @@
+structure Pref :> PREF =
+struct
+
+open Util Sql Init
+
+fun hasDirectory usr =
+    case C.oneOrNoRows (getDb ()) ($`SELECT * FROM DirectoryPref WHERE usr = ^(C.intToSql usr)`) of
+       NONE => false
+      | _ => true
+
+fun setDirectory usr =
+    if hasDirectory usr then
+       ()
+    else
+       ignore (C.dml (getDb ()) ($`INSERT INTO DirectoryPref (usr) VALUES (^(C.intToSql usr))`))
+
+fun unsetDirectory usr =
+    ignore (C.dml (getDb ()) ($`DELETE FROM DirectoryPref WHERE usr = ^(C.intToSql usr)`))
+
+end
\ No newline at end of file
diff --git a/static/.cvsignore b/static/.cvsignore
new file mode 100644 (file)
index 0000000..7e287ab
--- /dev/null
@@ -0,0 +1,3 @@
+.cm
+CM
+gen.x86-linux
diff --git a/static/Makefile b/static/Makefile
new file mode 100644 (file)
index 0000000..73c276e
--- /dev/null
@@ -0,0 +1,4 @@
+SMLBIN=/usr/local/sml/bin
+
+all:
+       $(SMLBIN)/ml-build sources.cm Gen.main gen
diff --git a/static/gen.sh b/static/gen.sh
new file mode 100755 (executable)
index 0000000..416d1b7
--- /dev/null
@@ -0,0 +1 @@
+/usr/local/sml/bin/sml @SMLload=/home/hcoop/portal/static/gen.x86-linux
\ No newline at end of file
diff --git a/static/gen.sig b/static/gen.sig
new file mode 100644 (file)
index 0000000..6c8bf4f
--- /dev/null
@@ -0,0 +1,4 @@
+signature GEN =
+sig
+    val main : string * string list -> OS.Process.status
+end
\ No newline at end of file
diff --git a/static/gen.sml b/static/gen.sml
new file mode 100644 (file)
index 0000000..6b82758
--- /dev/null
@@ -0,0 +1,68 @@
+structure Gen :> GEN =
+struct
+
+structure C = PgClient
+
+val outputDir = "/var/www/home/html/static/"
+
+fun generate () =
+    let
+       val db = C.conn "dbname='hcoop'"
+
+       fun header (outf, title) =
+           (TextIO.output (outf, "<html><head>\n<title>");
+            TextIO.output (outf, title);
+            TextIO.output (outf, "</title></head>\n<body>\n<h2><b>");
+            TextIO.output (outf, title);
+            TextIO.output (outf, "</b></h2>\n"))
+
+       fun footer outf =
+           TextIO.output (outf, "\n</body></html>")
+
+       fun genMemberList () =
+           let
+               val outf = TextIO.openOut (outputDir ^ "members.html")
+
+               fun printOne ([name, rname, usr], (total, anon)) =
+                   let
+                       val name = C.stringFromSql name
+                       val rname = C.stringFromSql rname
+                       val isAnon = C.isNull usr
+                   in
+                       if not isAnon then
+                           (TextIO.output (outf, "<tr> <td><a href=\"member/");
+                            TextIO.output (outf, name);
+                            TextIO.output (outf, ".html\">");
+                            TextIO.output (outf, name);
+                            TextIO.output (outf, "</a></td> <td>");
+                            TextIO.output (outf, rname);
+                            TextIO.output (outf, "</td> </tr>\n"))
+                       else
+                           ();
+                       (total + 1, (if C.isNull usr then anon + 1 else anon))
+                   end
+                 | printOne _ = raise Fail "Bad printOne line"
+
+               val _ = header (outf, "Member list")
+               val _ = TextIO.output (outf, "<table>\n")
+               val (total, anon) = C.fold db printOne (0, 0)
+                                          "SELECT name, rname, usr FROM WebUser LEFT OUTER JOIN DirectoryPref ON id = usr ORDER BY name"
+           in
+               TextIO.output (outf, "</table><br><br>\n\nUnlisted members: ");
+               TextIO.output (outf, Int.toString anon);
+               TextIO.output (outf, " out of ");
+               TextIO.output (outf, Int.toString total);
+               TextIO.output (outf, " total.\n");
+               footer outf;
+               TextIO.closeOut outf
+           end
+    in
+       genMemberList ();
+       OS.Process.success
+    end
+
+fun main _ = (generate ())
+    handle ex => (print "Exception!\n";
+                 OS.Process.failure)
+
+end
\ No newline at end of file
diff --git a/static/sources.cm b/static/sources.cm
new file mode 100644 (file)
index 0000000..6ddad86
--- /dev/null
@@ -0,0 +1,6 @@
+Group is
+       $/basis.cm
+       /usr/local/share/smlsql/libpq/sources.cm
+
+       gen.sig
+       gen.sml
index 20419d3..f1c980d 100644 (file)
@@ -206,3 +206,7 @@ CREATE TABLE MailingList(
        FOREIGN KEY (usr) REFERENCES WebUser(id) ON DELETE CASCADE);
 
 CREATE SEQUENCE MailingListSeq START 1;
+
+CREATE TABLE DirectoryPref(
+       usr INTEGER PRIMARY KEY,
+       FOREIGN KEY (usr) REFERENCES WebUser(id) ON DELETE CASCADE);