-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmessage-layout.js
28 lines (27 loc) · 910 Bytes
/
message-layout.js
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
var u = require('yap-util')
var ref = require('ssb-ref')
var niceAgo = require('nice-ago')
var toUrl = u.toUrl
module.exports = function (opts, apply) {
return ['div.Message',
apply.cacheAttrs(toUrl('message', {id: opts.key}), opts.key, apply.since),
['div.MessageSide',
apply('avatar', {id: opts.author, name: false, image: true}),
['a', {
href: toUrl('message', {id: opts.id || opts.key}),
title: new Date(opts.ts)+'\n'+opts.key
},
''+niceAgo(Date.now(), opts.ts)
]
],
['div.MessageMain',
['div.MessageMeta',
apply('avatar', {id: opts.author, name: true, image: false}),
['label.msgId', opts.id],
opts.meta ? opts.meta : ''
],
['div.MessageContent', opts.content],
opts.extra && ['div.MessageExtra', apply('extra', {id: opts.key || opts.id, root: opts.root, branch: opts.branch})]
]
]
}