summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Barenblat <bbaren@mit.edu>2013-04-30 17:54:40 -0400
committerBenjamin Barenblat <bbaren@mit.edu>2013-04-30 17:54:40 -0400
commit8eeb0838dd232592ea4bc0e6478f38cd6a68049d (patch)
tree71efaaeb5e49b46b28b868f0f28494a763bf2999
parent7361fa236b9221f686e0dd58d7a9ae870a8c7c7e (diff)
Forum: Actually display answers
-rw-r--r--forum/forum.ur32
-rw-r--r--site.css2
2 files changed, 26 insertions, 8 deletions
diff --git a/forum/forum.ur b/forum/forum.ur
index 6dc451a..49acd18 100644
--- a/forum/forum.ur
+++ b/forum/forum.ur
@@ -29,6 +29,7 @@ style entryTitle
style entryBody
table entry : { Id : int,
+ References : option int,
Class : EntryClass.entryClass,
Title : string,
Body : string,
@@ -45,14 +46,29 @@ val getName : transaction (option string) =
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") <xml>
- <div class={content}>
+ questionBlock <- queryX (SELECT * FROM entry
+ WHERE Entry.Class = {[EntryClass.question]}
+ AND Entry.Id = {[id]}) (fn q =>
+ <xml>
<h2>{[q.Entry.Title]}</h2>
<p>{[q.Entry.Body]}</p>
<p class={entryMetadata}>Asked by {[q.Entry.Author]}</p>
+ </xml>);
+ answerBlock <- queryX (SELECT * FROM entry
+ WHERE Entry.Class = {[EntryClass.answer]}
+ AND Entry.References = {[Some id]}) (fn a =>
+ <xml>
+ <p>
+ {[a.Entry.Body]}
+ <span class={entryMetadata}>&mdash;{[a.Entry.Author]}</span>
+ </p>
+ </xml>);
+ return (
+ Template.generic (Some "Forum") <xml>
+ <div class={content}>
+ {questionBlock}
+
+ <div>{answerBlock}</div>
<h3>Your answer</h3>
<form>
@@ -72,8 +88,9 @@ fun detail (id : int) : transaction page =
and reply qId submission =
id <- nextval entryIdS;
- dml (INSERT INTO entry (Id, Class, Title, Body, Author)
+ dml (INSERT INTO entry (Id, References, Class, Title, Body, Author)
VALUES ({[id]},
+ {[Some qId]},
{[EntryClass.answer]},
{[""]},
{[submission.Body]},
@@ -143,8 +160,9 @@ fun main () : transaction page =
and ask submission =
id <- nextval entryIdS;
- dml (INSERT INTO entry (Id, Class, Title, Body, Author)
+ dml (INSERT INTO entry (Id, References, Class, Title, Body, Author)
VALUES ({[id]},
+ {[None]},
{[EntryClass.question]},
{[submission.Title]},
{[submission.Body]},
diff --git a/site.css b/site.css
index 4418d44..48f2d0f 100644
--- a/site.css
+++ b/site.css
@@ -102,7 +102,7 @@ h3 {
margin: 0;
}
-.content p:first-child:first-letter {
+.dropcap:first-letter {
color: hsl(0, 90%, 35%);
font-size: 3.3em;
padding-right: 0.03em;