Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improved message visuals.

  • Loading branch information...
commit 12d1dcb36448a6947415eb15b567e99892970176 1 parent ee573dc
@akoprow akoprow authored
View
2  src/Makefile
@@ -16,4 +16,4 @@ run.debug: main.exe
./main.exe --debug-editable-js --js-cleaning no --js-renaming no
clean:
- rm -rf *.opx *.opx.broken *.exe _tracks
+ rm -rf *.opx *.opx.broken *.exe _tracks _build opa-debug *.log
View
BIN  src/img/user.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
71 src/msg.opa
@@ -5,6 +5,8 @@
package mlstate.twopenny
+import widgets.dateprinter
+
type Msg.t = private(
{ author: User.ref
; content : string
@@ -23,6 +25,15 @@ Msg = {{
msg = { ~author ~content created_at=Date.now() }
@wrap(msg)
+ get_creation_date(msg : Msg.t) : Date.date =
+ @unwrap(msg).created_at
+
+ get_author(msg : Msg.t) : User.ref =
+ @unwrap(msg).author
+
+ get_content(msg : Msg.t) : string =
+ @unwrap(msg).content
+
parse(msg : Msg.t) : list(Msg.segment) =
word = parser
/* FIXME we probably want to extend the character set
@@ -44,10 +55,10 @@ Msg = {{
| txt=((!special_prefix (. word))+) -> // Warning! + not * ; otherwise it will loop
{ text = Text.to_string(txt) }
msg_parser = parser res=segment_parser* -> res
- Parser.parse(msg_parser, @unwrap(msg).content)
+ Parser.parse(msg_parser, Msg.get_content(msg))
- render(msg : Msg.t) : xhtml =
- render_segment =
+ render(msg : Msg.t, mode : {preview} / {final}) : xhtml =
+ render_segment =
| ~{ text } -> <>{text}</>
| ~{ url } ->
// we add spaces around URLs to avoid collapsing them together with adjacent text
@@ -55,6 +66,58 @@ Msg = {{
| ~{ label } -> Label.to_anchor(label)
| ~{ user } -> User.to_anchor(user)
content = List.map(render_segment, parse(msg))
- <div class="msg">{content}</>
+ date = WDatePrinter.html(WDatePrinter.default_config,
+ uniq(), Msg.get_creation_date(msg))
+ <div class="msg">
+ <img class="image" src="/img/user.png" />
+ <div class="content">
+ <div class="user">{Msg.get_author(msg) |> User.to_anchor}</>
+ <div class="text">{content}</>
+ {match mode with
+ | {final} -> <div class="date">{date}</>
+ | {preview} -> <></> // don't display date in preview
+ }
+ </>
+ </>
+ // FIXME WDatePrinter -> "now ago" -> "now"
}}
+
+css = css
+ .msg {
+ border-top: 1px dotted black;
+ border-bottom: 1px dotted black;
+ width: 540px;
+ min-height: 48px;
+ font-size: 15px;
+ font-family: Helvetica;
+ background: #F0FFF9;
+ padding: 15px 0px;
+ }
+ .msg:hover {
+ background: #D9FFF6;
+ border-top: 1px solid black;
+ border-bottom: 1px solid black;
+ }
+ .msg .image {
+ width: 48px;
+ height: 48px;
+ margin-left: 3px;
+ float: left;
+ }
+ .msg .content {
+ margin-left: 60px;
+ }
+ .msg .user {
+ line-height: 15px;
+ color: #333;
+ font-weight: bold;
+ }
+ .msg .text {
+ line-height: 19px;
+ color: #444;
+ }
+ .msg .date {
+ font-size: 11px;
+ color: #999;
+ }
View
2  src/msg_box.opa
@@ -46,7 +46,7 @@ WMsgBox =
do exec([#{get_counter_id(id)} <- counter_xhtml])
preview =
if remaining > 0 then
- mk_msg(content) |> Msg.render(_)
+ mk_msg(content) |> Msg.render(_, {preview})
else
MSG_TOO_LONG_WARNING
do exec([#{get_preview_id(id)} <- preview])
View
2  src/pages.opa
@@ -21,7 +21,7 @@ Pages = {{
@client setup_msg_updates(_) =
show_new_message(msg) =
- exec([#msgs -<- Msg.render(msg)])
+ exec([#msgs -<- Msg.render(msg, {final})])
do MsgFactory.subscribe_to_all(show_new_message)
void
View
3  src/user.opa
@@ -16,4 +16,7 @@ User = {{
user = @unwrap(user_ref)
<a href="/user/{user}">@{user}</>
+ to_string(user_ref : User.ref) : string =
+ @unwrap(user_ref)
+
}}
Please sign in to comment.
Something went wrong with that request. Please try again.