Generate public link directory
authoradamch <adamch>
Tue, 26 Apr 2005 18:09:12 +0000 (18:09 +0000)
committeradamch <adamch>
Tue, 26 Apr 2005 18:09:12 +0000 (18:09 +0000)
static/gen.sml

index 2310ca3..9844e2d 100644 (file)
@@ -259,10 +259,44 @@ fun generate () =
                footer outf;
                TextIO.closeOut outf
            end
+
+       fun genLinks () =
+           let
+               val outf = TextIO.openOut (outputDir ^ "sites.html")
+
+               val _ = header (outf, "Hosted sites")
+
+               fun doLink [url, title, descr, name] = (C.stringFromSql url, C.stringFromSql title, C.stringFromSql descr, C.stringFromSql name)
+                 | doLink _ = raise Fail "Bad link' row"
+
+               val links = C.map db doLink (String.concat ["SELECT url, title, descr, name FROM Link",
+                                                           " JOIN WebUser ON WebUser.id = usr",
+                                                           " JOIN DirectoryPref ON WebUser.id = DirectoryPref.usr",
+                                                           " ORDER BY title"])
+
+               fun appLink (url, title, descr, name) = 
+                   (TextIO.output (outf, "<tr> <td><b><a href=\"");
+                    TextIO.output (outf, Web.html url);
+                    TextIO.output (outf, "\">");
+                    TextIO.output (outf, Web.html title);
+                    TextIO.output (outf, "</a></b></td> <td>");
+                    TextIO.output (outf, Web.html descr);
+                    TextIO.output (outf, "</td> <td><a href=\"member/");
+                    TextIO.output (outf, name);
+                    TextIO.output (outf, ".html\">");
+                    TextIO.output (outf, name);
+                    TextIO.output (outf, "</a></td> </tr>\n"))
+           in
+               TextIO.output (outf, "<table>\n");
+               app appLink links;
+               footer outf;
+               TextIO.closeOut outf
+           end
     in
        genMemberList ();
        genMemberPages ();
        genLocations ();
+       genLinks ();
        OS.Process.success
     end