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/author.ur | 19 +++++++++++++++++++ forum/author.urs | 19 +++++++++++++++++++ forum/entryClass.ur | 27 +++++++++++++++++++++++---- forum/entryClass.urs | 18 ++++++++++++++++++ forum/forum.ur | 49 +++++++++++++++++++++++++++++++------------------ forum/myOption.ur | 18 ++++++++++++++++++ forum/myOption.urs | 18 ++++++++++++++++++ forum/score.ur | 38 ++++++++++++++++++++++++++++++++++---- forum/score.urs | 18 ++++++++++++++++++ 9 files changed, 198 insertions(+), 26 deletions(-) diff --git a/forum/author.ur b/forum/author.ur index 5cbc136..6cec6e9 100644 --- a/forum/author.ur +++ b/forum/author.ur @@ -1,3 +1,22 @@ +(* Forum.User -- User information +Copyright (C) 2013 Benjamin Barenblat + +This file is a part of 6.947. + +6.947 is is free software: you can redistribute it and/or modify it under the +terms of the GNU Affero General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your option) any +later version. + +6.947 is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU Affero General Public License for more +details. + +You should have received a copy of the GNU Affero General Public License along +with 6.947. If not, see . *) + + (********************************** A user ***********************************) type usernameOrAnonymous = option string diff --git a/forum/author.urs b/forum/author.urs index db6e7a8..8b15a23 100644 --- a/forum/author.urs +++ b/forum/author.urs @@ -1,3 +1,22 @@ +(* Forum.User -- User information +Copyright (C) 2013 Benjamin Barenblat + +This file is a part of 6.947. + +6.947 is is free software: you can redistribute it and/or modify it under the +terms of the GNU Affero General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your option) any +later version. + +6.947 is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU Affero General Public License for more +details. + +You should have received a copy of the GNU Affero General Public License along +with 6.947. If not, see . *) + + (********************************** A user ***********************************) type usernameOrAnonymous diff --git a/forum/entryClass.ur b/forum/entryClass.ur index 26f3c58..059c80c 100644 --- a/forum/entryClass.ur +++ b/forum/entryClass.ur @@ -1,9 +1,28 @@ -type entryClass = int +(* Forum.EntryClass -- Questions, answers, etc. +Copyright (C) 2013 Benjamin Barenblat -val eq_entryClass = eq_int +This file is a part of 6.947. -val sql_entryClass = sql_prim +6.947 is is free software: you can redistribute it and/or modify it under the +terms of the GNU Affero General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your option) any +later version. -val question = 0 +6.947 is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU Affero General Public License for more +details. + +You should have received a copy of the GNU Affero General Public License along +with 6.947. If not, see . *) + +type entryClass = int +val question = 0 val answer = 1 + +(********************************* Instances *********************************) + +val eq_entryClass = eq_int + +val sql_entryClass = sql_prim diff --git a/forum/entryClass.urs b/forum/entryClass.urs index acd5c79..120d7b5 100644 --- a/forum/entryClass.urs +++ b/forum/entryClass.urs @@ -1,3 +1,21 @@ +(* Forum.EntryClass -- Questions, answers, etc. +Copyright (C) 2013 Benjamin Barenblat + +This file is a part of 6.947. + +6.947 is is free software: you can redistribute it and/or modify it under the +terms of the GNU Affero General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your option) any +later version. + +6.947 is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU Affero General Public License for more +details. + +You should have received a copy of the GNU Affero General Public License along +with 6.947. If not, see . *) + type entryClass val question : entryClass 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 =