Files: 23576a5dca023c72b5a92bf3c1f5b35bb4f22744 / modules / message.js
1283 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.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 | |
44 | exports.message_content = [] |
45 | exports.avatar = [] |
46 | exports.message_meta = [] |
47 | exports.message_action = [] |
48 | exports.message_link = [] |
49 | |
50 |
Built with git-ssb-web