(* Forum -- forum subapp Copyright (C) 2013 Benjamin Barenblat This file is a part of 6.947. 6.947 is is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6.947 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with 6.947. If not, see . *) functor Make(Template : sig val generic : option string -> xbody -> page end) = struct open Styles table question : { Id : int, Title : string, Body : string, Asker : option string (* 'None' if anonymous *) } PRIMARY KEY Id sequence questionIdS fun showAskerOpt (askerOpt : option string) : string = case askerOpt of None => "Anonymous" | Some nam => nam fun readAskerOpt (text : string) : option string = case text of "Anonymous" => None | nam => Some nam (* Grabs real name out of MIT certificate. *) val getName = getenv (blessEnvVar "SSL_CLIENT_S_DN_CN") fun prettyPrintQuestion row : xbody =

{[row.Question.Title]}: {[row.Question.Body]} (asked by {[showAskerOpt row.Question.Asker]})

fun main () : transaction page = newestQuestions <- queryX (SELECT * FROM question) prettyPrintQuestion; askerOpt <- getName; return ( Template.generic (Some "Forum")

All questions:

{newestQuestions}

Ask a new question: