From 8eeb0838dd232592ea4bc0e6478f38cd6a68049d Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Tue, 30 Apr 2013 17:54:40 -0400 Subject: Forum: Actually display answers --- forum/forum.ur | 32 +++++++++++++++++++++++++------- site.css | 2 +- 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") -
+ questionBlock <- queryX (SELECT * FROM entry + WHERE Entry.Class = {[EntryClass.question]} + AND Entry.Id = {[id]}) (fn q => +

{[q.Entry.Title]}

{[q.Entry.Body]}

Asked by {[q.Entry.Author]}

+
); + answerBlock <- queryX (SELECT * FROM entry + WHERE Entry.Class = {[EntryClass.answer]} + AND Entry.References = {[Some id]}) (fn a => + +

+ {[a.Entry.Body]} + —{[a.Entry.Author]} +

+
); + return ( + Template.generic (Some "Forum") +
+ {questionBlock} + +
{answerBlock}

Your answer

@@ -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; -- cgit v1.2.3