Files: 8dc25143a3f37f1618f7a92b3c46dec512b43bfd / modules / about.js
858 bytesRaw
1 | var h = require('hyperscript') |
2 | var ref = require('ssb-ref') |
3 | |
4 | function idLink (id) { |
5 | if (ref.isLink(id)) { |
6 | return h('a', {href:'#'+id}, id.substring(0, 10)+'...') |
7 | } |
8 | } |
9 | |
10 | exports.needs = { |
11 | blob_url: 'first' |
12 | } |
13 | |
14 | exports.gives = 'message_content' |
15 | |
16 | exports.create = function (api) { |
17 | return function (msg) { |
18 | if(msg.value.content.type !== 'about') return |
19 | |
20 | if(!msg.value.content.image && !msg.value.content.name) |
21 | return |
22 | |
23 | var about = msg.value.content |
24 | var id = msg.value.content.about |
25 | return h('p', |
26 | about.about === msg.value.author |
27 | ? h('span', 'self-identifies ') |
28 | : h('span', 'identifies ', idLink(id)), |
29 | ' as ', |
30 | h('a', {href:"#"+about.about}, |
31 | about.name || null, |
32 | about.image |
33 | ? h('img.avatar--thumbnail', {src: api.blob_url(about.image)}) |
34 | : null |
35 | ) |
36 | ) |
37 | } |
38 | } |
39 |
Built with git-ssb-web