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