From 7361fa236b9221f686e0dd58d7a9ae870a8c7c7e Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Thu, 2 May 2013 17:32:56 -0400 Subject: Forum: Add answering support --- forum/entryClass.ur | 9 +++++++++ forum/entryClass.urs | 11 +++++++++++ forum/forum.ur | 56 +++++++++++++++++++++++++++++++++++++++++++++++++--- forum/lib.urp | 1 + 4 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 forum/entryClass.ur create mode 100644 forum/entryClass.urs diff --git a/forum/entryClass.ur b/forum/entryClass.ur new file mode 100644 index 0000000..26f3c58 --- /dev/null +++ b/forum/entryClass.ur @@ -0,0 +1,9 @@ +type entryClass = int + +val eq_entryClass = eq_int + +val sql_entryClass = sql_prim + +val question = 0 + +val answer = 1 diff --git a/forum/entryClass.urs b/forum/entryClass.urs new file mode 100644 index 0000000..acd5c79 --- /dev/null +++ b/forum/entryClass.urs @@ -0,0 +1,11 @@ +type entryClass + +val question : entryClass +val answer : entryClass + + +(********************************* Instances *********************************) + +val eq_entryClass : eq entryClass + +val sql_entryClass : sql_injectable entryClass diff --git a/forum/forum.ur b/forum/forum.ur index 3c376ec..6dc451a 100644 --- a/forum/forum.ur +++ b/forum/forum.ur @@ -29,6 +29,7 @@ style entryTitle style entryBody table entry : { Id : int, + Class : EntryClass.entryClass, Title : string, Body : string, Author : author @@ -39,10 +40,53 @@ sequence entryIdS val getName : transaction (option string) = getenv (blessEnvVar "SSL_CLIENT_S_DN_CN") + +(***************************** Single questions ******************************) + +fun detail (id : int) : transaction page = + authorOpt <- getName; + queryX (SELECT * FROM entry + WHERE Entry.Class = {[EntryClass.question]} + AND Entry.Id = {[id]}) (fn q => + Template.generic (Some "Forum") +
+

{[q.Entry.Title]}

+

{[q.Entry.Body]}

+

Asked by {[q.Entry.Author]}

+ +

Your answer

+
+