Files: 713b01f06481ca81d7010c0fc836efdc718aca76 / modules_basic / about.js
1300 bytesRaw
1 | var h = require('../h') |
2 | |
3 | //var blob_url = require('../plugs').first(exports.blob_url = []) |
4 | |
5 | exports.needs = { |
6 | blob_url: 'first' |
7 | } |
8 | |
9 | exports.gives = { |
10 | 'mcss': true, |
11 | 'message_content': true |
12 | } |
13 | |
14 | var style = ` |
15 | About { |
16 | background-color: red |
17 | } |
18 | ` |
19 | |
20 | exports.create = function (api) { |
21 | return { |
22 | message_content, |
23 | mcss: style |
24 | } |
25 | |
26 | function message_content (msg) { |
27 | if(msg.value.content.type !== 'about') return |
28 | |
29 | var about = msg.value.content |
30 | var { about: aboutId, name, image, description } = about |
31 | |
32 | // if(!image && !name) return |
33 | |
34 | return h('.About', {}, [ |
35 | verb({ aboutId, authorId: msg.value.author }), |
36 | profile({ aboutId, name, image, description }) |
37 | ]) |
38 | } |
39 | } |
40 | |
41 | |
42 | function verb ({ aboutId, authorId }) { |
43 | return authorId === aboutId |
44 | ? h('span', 'self-identifies as') |
45 | : h('span', ['identifies ', idLink(aboutId), ' as ']) |
46 | } |
47 | |
48 | function profile ({ aboutId, name, image, description }) { |
49 | return h('div', [ |
50 | name |
51 | ? h('a', {href:'#'+aboutId}, name) |
52 | : null, |
53 | image |
54 | ? h('a', {href:'#'+aboutId}, h('img.avatar--fullsize', {src: api.blob_url(image)})) |
55 | : null, |
56 | description || null |
57 | ]) |
58 | } |
59 | |
60 | function idLink (id) { |
61 | return h('a', {href:'#'+id}, id) |
62 | } |
63 | |
64 | function asLink (ln) { |
65 | return typeof ln === 'string' ? ln : ln.link |
66 | } |
67 | |
68 |
Built with git-ssb-web