git ssb

16+

Dominic / patchbay



Tree: 7cf35de753155a880bece2498dee7cb02c01f251

Files: 7cf35de753155a880bece2498dee7cb02c01f251 / modules / message.js

1263 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 if(el) console.log(el)
11
12 function map (plugs, value) {
13 return plugs.map(function (plug) {
14 return plug(value, sbot)
15 }).filter(Boolean)
16 }
17
18 var backlinks = h('div.backlinks')
19
20 pull(
21 sbot.links({dest: msg.key, rel: 'mentions', keys: true}),
22 pull.collect(function (err, links) {
23 if(links.length)
24 backlinks.appendChild(h('label', 'backlinks:',
25 h('div', links.map(function (link) {
26 return u.decorate(exports.message_link, link.key, function (d, e, v) { return d(e, v, sbot) })
27 }))
28 ))
29 })
30 )
31
32 if(el)
33 return h('div.message',
34 h('div.title',
35 h('div.avatar', map(exports.avatar, msg.value.author)),
36 h('div.metadata', map(exports.message_meta, msg))
37 ),
38 h('div.content', el),
39 h('div.footer',
40 h('div.actions', map(exports.message_action))
41 ),
42 backlinks
43 )
44}
45
46exports.message_content = []
47exports.avatar = []
48exports.message_meta = []
49exports.message_action = []
50exports.message_link = []
51

Built with git-ssb-web