git ssb

16+

Dominic / patchbay



Tree: 59ec50547ac8f97c3f287fc4854692b515223939

Files: 59ec50547ac8f97c3f287fc4854692b515223939 / modules / message.js

1283 bytesRaw
1var h = require('hyperscript')
2var u = require('../util')
3var pull = require('pull-stream')
4
5exports.message_render = function (msg, sbot) {
6 var el = u.first(exports.message_content, function (fn) {
7 return fn(msg, sbot)
8 })
9
10 function map (plugs, value) {
11 return plugs.map(function (plug) {
12 return plug(value, sbot)
13 }).filter(Boolean)
14 }
15
16 var backlinks = h('div.backlinks')
17
18 pull(
19 sbot.links({dest: msg.key, rel: 'mentions', keys: true}),
20 pull.collect(function (err, links) {
21 if(links.length)
22 backlinks.appendChild(h('label', 'backlinks:',
23 h('div', links.map(function (link) {
24 return u.decorate(exports.message_link, link.key, function (d, e, v) { return d(e, v, sbot) })
25 }))
26 ))
27 })
28 )
29
30 if(el)
31 return h('div.message.column',
32 h('div.title.row',
33 h('div.avatar', map(exports.avatar, msg.value.author)),
34 h('div.message_meta.row', map(exports.message_meta, msg))
35 ),
36 h('div.message_content', el),
37 h('div.message_actions.row',
38 h('div.actions', map(exports.message_action, msg))
39 ),
40 backlinks
41 )
42}
43
44exports.message_content = []
45exports.avatar = []
46exports.message_meta = []
47exports.message_action = []
48exports.message_link = []
49
50

Built with git-ssb-web