From 5bc9450c1990b26133e34d7a8a8b9d43a7377d6c Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Thu, 2 May 2013 17:54:56 -0400 Subject: Style fixes --- forum/forum.ur | 83 +++++++++++++++++++++++++--------------------------------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/forum/forum.ur b/forum/forum.ur index 592b126..e1bf577 100644 --- a/forum/forum.ur +++ b/forum/forum.ur @@ -58,34 +58,30 @@ fun queryColumn [tab ::: Name] [field ::: Name] [state ::: Type] fun getScore (questionId : int) : transaction Score.score = queryColumn (SELECT Vote.Value FROM vote WHERE Vote.QuestionId = {[questionId]}) - Score.update - Score.undecided + Score.update + Score.undecided (***************************** Single questions ******************************) fun detail (id : int) : transaction page = authorOpt <- getName; - 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]} -

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

+ {[answer.Body]} + —{[answer.Author]} +

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

{[question.Title]}

+

{[question.Body]}

+

Asked by {[question.Author]}

{answerBlock}
@@ -102,8 +98,7 @@ fun detail (id : int) : transaction page =
-
- ) + ) and reply qId submission = id <- nextval entryIdS; @@ -119,22 +114,20 @@ and reply qId submission = (**************************** Lists of questions *****************************) -fun prettyPrintQuestion row score : xbody = - -
  • -

    {[row.Entry.Title]}

    - {[row.Entry.Body]} - Asked by {[row.Entry.Author]}; score {[score]} -
  • -
    +fun prettyPrintQuestion entry : transaction xbody = + score <- getScore entry.Id; + return ( +
  • +

    {[entry.Title]}

    + {[entry.Body]} + Asked by {[entry.Author]}; score {[score]} +
  • ) val allQuestions : transaction page = - questionsList <- queryX' (SELECT * FROM entry - WHERE Entry.Class = {[EntryClass.question]} - ORDER BY Entry.Id DESC) - (fn q => - score <- getScore q.Entry.Id; - return (prettyPrintQuestion q score)); + questionsList <- queryX1' (SELECT * FROM entry + WHERE Entry.Class = {[EntryClass.question]} + ORDER BY Entry.Id DESC) + prettyPrintQuestion; return ( Template.generic (Some "Forum – All questions")
    @@ -143,17 +136,14 @@ val allQuestions : transaction page = {questionsList}
    -
    - ) + ) fun main () : transaction page = - newestQuestions <- queryX' (SELECT * FROM entry - WHERE Entry.Class = {[EntryClass.question]} - ORDER BY Entry.Id DESC - LIMIT 5) - (fn q => - score <- getScore q.Entry.Id; - return (prettyPrintQuestion q score)); + newestQuestions <- queryX1' (SELECT * FROM entry + WHERE Entry.Class = {[EntryClass.question]} + ORDER BY Entry.Id DESC + LIMIT 5) + prettyPrintQuestion; askerOpt <- getName; return ( Template.generic (Some "Forum") @@ -178,8 +168,7 @@ fun main () : transaction page = - - ) + ) and ask submission = id <- nextval entryIdS; -- cgit v1.2.3