Skip to content
Browse files

Introducing MsgFactory.

Responsible for submitting new messages and tracking old ones.
  • Loading branch information...
1 parent 0cf1c12 commit aee5d31df8544a2a5f177c73e9cff424a46a013c @akoprow akoprow committed Mar 31, 2011
Showing with 26 additions and 16 deletions.
  1. +1 −13 src/msg.opa
  2. 0 src/{msgbox.opa → msg_box.opa}
  3. +21 −0 src/msg_factory.opa
  4. +1 −1 src/pages.opa
  5. +3 −2 src/twopenny.opack
View
14 src/msg.opa
@@ -18,7 +18,7 @@ Msg = {{
create(s : string) : Msg.t =
@wrap(s)
- @private parse(msg : Msg.t) : list(Msg.segment) =
+ parse(msg : Msg.t) : list(Msg.segment) =
word = parser
/* FIXME we probably want to extend the character set
below. */
@@ -52,16 +52,4 @@ Msg = {{
content = List.map(render_segment, parse(msg))
<div class="msg">{content}</>
- submit_msg(user : User.ref)(content : string) =
- msg = create(content)
- do Data.new_message(user, msg)
- index =
- | ~{user} -> Data.new_user_mention(user, msg)
- | ~{label} -> Data.new_label_msg(label, msg)
- | {url=_}
- | {text=_} -> void
- do List.iter(index, parse(msg))
- do exec([#msgs +<- <>{render(msg)}</>])
- void
-
}}
View
0 src/msgbox.opa → src/msg_box.opa
File renamed without changes.
View
21 src/msg_factory.opa
@@ -0,0 +1,21 @@
+/*
+ * Twopenny. (C) MLstate - 2011
+ * @author Adam Koprowski
+**/
+
+package mlstate.twopenny
+
+MsgFactory = {{
+
+ submit(user : User.ref)(content : string) =
+ msg = Msg.create(content)
+ do Data.new_message(user, msg)
+ index =
+ | ~{user} -> Data.new_user_mention(user, msg)
+ | ~{label} -> Data.new_label_msg(label, msg)
+ | {url=_}
+ | {text=_} -> void
+ do List.iter(index, Msg.parse(msg))
+ void
+
+}}
View
2 src/pages.opa
@@ -23,7 +23,7 @@ Pages = {{
content =
<>
<h1>User: {@unwrap(user)}</>
- {WMsgBox.html("msgbox", Msg.submit_msg(user))}
+ {WMsgBox.html("msgbox", MsgFactory.submit(user))}
</>
html("Twopenny :: {user}", content)
View
5 src/twopenny.opack
@@ -1,8 +1,9 @@
main.opa
pages.opa
-msg.opa
-msgbox.opa
data.opa
+msg.opa
+msg_box.opa
+msg_factory.opa
user.opa
label.opa
utils.opa

0 comments on commit aee5d31

Please sign in to comment.
Something went wrong with that request. Please try again.