git ssb

16+

Dominic / patchbay



Tree: 108d820b09fd85d159865f851eac43f82f21766f

Files: 108d820b09fd85d159865f851eac43f82f21766f / modules_basic / about.js

1152 bytesRaw
1var h = require('../h')
2
3//var blob_url = require('../plugs').first(exports.blob_url = [])
4
5exports.needs = {
6 blob_url: 'first'
7}
8
9exports.gives = 'message_content'
10
11exports.create = function (api) {
12 return function (msg) {
13 if(msg.value.content.type !== 'about') return
14
15 var about = msg.value.content
16 var { about: aboutId, name, image, description } = about
17
18 // if(!image && !name) return
19
20 return h('.About', {}, [
21 verb({ aboutId, authorId: msg.value.author }),
22 profile({ aboutId, name, image, description })
23 ])
24 }
25}
26
27
28function verb ({ aboutId, authorId }) {
29 return authorId === aboutId
30 ? h('span', 'self-identifies as')
31 : h('span', ['identifies ', idLink(aboutId), ' as '])
32}
33
34function profile ({ aboutId, name, image, description }) {
35 return h('div', [
36 name
37 ? h('a', {href:'#'+aboutId}, name)
38 : null,
39 image
40 ? h('a', {href:'#'+aboutId}, h('img.avatar--fullsize', {src: api.blob_url(image)}))
41 : null,
42 description || null
43 ])
44}
45
46function idLink (id) {
47 return h('a', {href:'#'+id}, id)
48}
49
50function asLink (ln) {
51 return typeof ln === 'string' ? ln : ln.link
52}
53
54

Built with git-ssb-web