-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdata.opa
60 lines (47 loc) · 1.52 KB
/
data.opa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Twopenny. (C) MLstate - 2011
* @author Adam Koprowski
**/
package mlstate.twopenny
/** Users in the system */
db /users : stringmap(User.t)
db /users[_]/photo full
db /users[_]/wallpaper full
/** Messages posted by the users */
// msg_ref -> msg
db /msgs : Msg.map(Msg.t)
/** Messages posted by users */
// user -> date -> msg_ref
db /user_msg : User.map(Date.map(Msg.ref))
/** References to messages mentioning given users */
// user -> date -> msg_ref
db /user_mentions : User.map(Date.map(Msg.ref))
@both_implem Data = {{
new_message(msg) =
debug("New message: {msg}")
new_user_mention(user, msg) =
debug("New user mention: '{user}' in '{msg}'")
new_label_msg(label, msg) =
debug("New label occurrence: '{label}' -> '{msg}'")
}}
init_data_store() =
match ?/users["mlstate"] with
| {none} ->
mlstate : User.t =
{ name = "OPA by MLstate"
; location = "Paris, France"
; motto = "MLstate, creators of the OPA platform for web-development"
; email = Email.of_string("[email protected]")
; url = "http://mlstate.com"
; photo = some({png = @static_binary_content("img/mlstate.png")})
; passwd = "9d62e4f6d08f780e5d5e4f30ca3419d6"
; wallpaper =
{ img = some({png = @static_binary_content("img/mlstate-bg.png")})
; tile = false
; color = Color.of_string("#155B9C")
}
}
/users["mlstate"] <- mlstate
| _ ->
void
@server _ = init_data_store()