git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 9fdc650f04f0bea7982659a5d5de3ce799b8ad6a

about message: show name instead of id when only specifying a picture

Matt McKegg committed on 11/2/2016, 9:55:56 PM
Parent: 93c8acc3bef1de08c2824be1d2c5d39c33ec499d

Files changed

modules/about.jsadded
modules/about.jsView
@@ -1,0 +1,37 @@
1+var h = require('hyperscript')
2+
3+function idLink (id) {
4+ return h('a', {href:'#'+id}, id.slice(0, 10))
5+}
6+
7+function asLink (ln) {
8+ return 'string' === typeof ln ? ln : ln.link
9+}
10+
11+var plugs = require('patchbay/plugs')
12+var blob_url = plugs.first(exports.blob_url = [])
13+var avatar_name = plugs.first(exports.avatar_name = [])
14+var avatar_link = plugs.first(exports.avatar_link = [])
15+
16+exports.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+}

Built with git-ssb-web