git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: fa40e97eba905e02fa26262401aa38c50f6de16b

Files: fa40e97eba905e02fa26262401aa38c50f6de16b / modules / about.js

975 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') 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