git ssb

10+

Matt McKegg / patchwork



Tree: 38b0812f2f3a84faff8a7c371f0d54fe34ad12c8

Files: 38b0812f2f3a84faff8a7c371f0d54fe34ad12c8 / modules / about.js

1003 bytesRaw
1var h = require('hyperscript')
2
3function idLink (id) {
4 return h('a', {href:'#'+id}, id.slice(0, 10))
5}
6
7function asLink (ln) {
8 return 'string' === typeof ln ? ln : ln.link
9}
10
11var plugs = require('patchbay/plugs')
12var blob_url = plugs.first(exports.blob_url = [])
13var avatar_name = plugs.first(exports.avatar_name = [])
14var avatar_link = plugs.first(exports.avatar_link = [])
15
16exports.message_content = function (msg) {
17 if(msg.value.content.type !== 'about' || !msg.value.content.about) return
18
19 if(!msg.value.content.image && !msg.value.content.name)
20 return
21
22 var about = msg.value.content
23 var id = msg.value.content.about
24 return h('p',
25 about.about === msg.value.author
26 ? h('span', 'self-identifies ')
27 : h('span', 'identifies ', about.name ? idLink(id) : avatar_link(id, avatar_name(id))),
28 ' as ',
29 h('a', {href:"#"+about.about},
30 about.name || null,
31 about.image
32 ? h('img.avatar--fullsize', {src: blob_url(about.image)})
33 : null
34 )
35 )
36
37}
38

Built with git-ssb-web