Files: d2fc80d053b60b029fe06052bffd46c21ec9caa2 / modules_basic / avatar-name.js
733 bytesRaw
1 | |
2 | var signifier = require('../plugs').first(exports.signifier = []) |
3 | var h = require('hyperscript') |
4 | |
5 | exports.needs = { signifier: 'first' } |
6 | |
7 | exports.gives = 'avatar_name' |
8 | |
9 | exports.create = function (api) { |
10 | |
11 | return function name (id) { |
12 | var n = h('span', id ? id.substring(0, 10) : "") |
13 | |
14 | //choose the most popular name for this person. |
15 | //for anything like this you'll see I have used sbot.links2 |
16 | //which is the ssb-links plugin. as you'll see the query interface |
17 | //is pretty powerful! |
18 | //TODO: "most popular" name is easily gameable. |
19 | //must come up with something better than this. |
20 | |
21 | api.signifier(id, function (_, names) { |
22 | if(names.length) n.textContent = names[0].name |
23 | }) |
24 | |
25 | return n |
26 | } |
27 | |
28 | } |
29 | |
30 |
Built with git-ssb-web