summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.hgignore1
-rw-r--r--forum/forum.ur22
-rw-r--r--site.urp1
3 files changed, 21 insertions, 3 deletions
diff --git a/.hgignore b/.hgignore
index 6ceff3e..a2c2ad8 100644
--- a/.hgignore
+++ b/.hgignore
@@ -22,4 +22,5 @@ syntax: glob
*~
# Generated by the Ur/Web compiler
+setup.sql
*.exe
diff --git a/forum/forum.ur b/forum/forum.ur
index 8cb11da..6579e56 100644
--- a/forum/forum.ur
+++ b/forum/forum.ur
@@ -22,15 +22,31 @@ end) = struct
open Styles
+table question : { Id : int,
+ Body : string
+ } PRIMARY KEY Id
+sequence questionIdS
+
fun main () : transaction page =
+ newestQuestions <- queryX (SELECT * FROM question) (fn row =>
+ <xml>
+ <p>{[row.Question.Body]}</p>
+ </xml>);
return (
Template.generic (Some "Forum") <xml>
<div class={content}>
- <p>
- Coming soon!
- </p>
+ <p>All questions:</p>
+ {newestQuestions}
+ <p>Ask a new question:</p>
+ <form><textbox {#Body} /><submit action={ask} value="Ask" /></form>
</div>
</xml>
)
+and ask submission =
+ id <- nextval questionIdS;
+ dml (INSERT INTO question (Id, Body)
+ VALUES ({[id]}, {[submission.Body]}));
+ main ()
+
end
diff --git a/site.urp b/site.urp
index 6c754b2..e22de9e 100644
--- a/site.urp
+++ b/site.urp
@@ -16,6 +16,7 @@ rewrite url Main/main index
rewrite url Main/*
library meta
library forum
+sql setup.sql
config
styles