From 83a790fd621bcdc4a8ecac5db3147b32b11fe61e Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Thu, 2 May 2013 22:02:24 -0400 Subject: Forum: Code style and licensing update --- forum/forum.ur | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'forum/forum.ur') diff --git a/forum/forum.ur b/forum/forum.ur index 23bbbd5..79e110e 100644 --- a/forum/forum.ur +++ b/forum/forum.ur @@ -52,7 +52,8 @@ fun queryColumn [tab ::: Name] [field ::: Name] [state ::: Type] : transaction state = query q (fn row state => return (f row.tab.field state)) initial -fun unless [m ::: Type -> Type] (_ : monad m) (cond : bool) (computation : m {}) = +fun unless [m ::: Type -> Type] (_ : monad m) + (cond : bool) (computation : m {}) = if cond then return () else computation @@ -70,9 +71,10 @@ fun recordVote (value : Score.score) (entryId : int) _formData : transaction pag in the first place. *) let val author = Author.nameError authorOpt in - existingVote <- oneOrNoRows1 (SELECT Vote.Value FROM vote - WHERE Vote.QuestionId = {[entryId]} - AND Vote.Author = {[author]}); + existingVote <- + oneOrNoRows1 (SELECT Vote.Value FROM vote + WHERE Vote.QuestionId = {[entryId]} + AND Vote.Author = {[author]}); (* This mimics Reddit's upvote/downvote behavior, which is a bizarrely complex state machine that is nonetheless totally intuitive, especially when you're using an AJAXy interface. TODO: Write an AJAXy @@ -114,7 +116,9 @@ and detail (id : int) : transaction page = return (

{[answer.Body]} - —{[answer.Author]} ({[Score.withUnits score "point"]}) + + —{[answer.Author]} ({[Score.withUnits score "point"]}) +

)); return ( Template.generic (Some "Forum") @@ -126,8 +130,12 @@ and detail (id : int) : transaction page =

{Author.whenIdentified authorOpt -
-
+
+ + +
+ +
}
{answerBlock}
@@ -137,7 +145,8 @@ and detail (id : int) : transaction page =