diff options
author | Benjamin Barenblat <bbaren@mit.edu> | 2013-04-22 13:42:24 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@mit.edu> | 2013-04-22 13:42:24 -0400 |
commit | 6c313e88105bbaf6d0bb44d8a8ea4cf600acaa83 (patch) | |
tree | d7359e3c638360d05168bdef56471635bed7b47e | |
parent | 10698a19eeb4f6fbda18d601c0f8fd878734ab21 (diff) |
Forum: Add title, body, and (incomplete) asker support
-rw-r--r-- | forum/forum.ur | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/forum/forum.ur b/forum/forum.ur index 6579e56..df53603 100644 --- a/forum/forum.ur +++ b/forum/forum.ur @@ -23,30 +23,38 @@ end) = struct open Styles table question : { Id : int, - Body : string + Title : string, + Body : string, + Asker : option string (* 'None' if anonymous *) } PRIMARY KEY Id sequence questionIdS +fun prettyPrintQuestion row : xbody = + <xml> + <p>{[row.Question.Title]}: {[row.Question.Body]} (asked by {[row.Question.Asker]})</p> + </xml> + fun main () : transaction page = - newestQuestions <- queryX (SELECT * FROM question) (fn row => - <xml> - <p>{[row.Question.Body]}</p> - </xml>); + newestQuestions <- queryX (SELECT * FROM question) prettyPrintQuestion; return ( Template.generic (Some "Forum") <xml> <div class={content}> <p>All questions:</p> {newestQuestions} <p>Ask a new question:</p> - <form><textbox {#Body} /><submit action={ask} value="Ask" /></form> + <form> + <textbox {#Title} size=80 /><br /> + <textarea {#Body} rows=12 cols=80 /><br /> + <submit action={ask} value="Ask" /> + </form> </div> </xml> ) and ask submission = id <- nextval questionIdS; - dml (INSERT INTO question (Id, Body) - VALUES ({[id]}, {[submission.Body]})); + dml (INSERT INTO question (Id, Title, Body, Asker) + VALUES ({[id]}, {[submission.Title]}, {[submission.Body]}, {[Some "test user"]})); main () end |