Files: bddd616e485c10d52e676f3f90f53d6a6efea64b / modules_basic / avatar / name.js
668 bytesRaw
1 | var h = require('hyperscript') |
2 | |
3 | exports.needs = { |
4 | signifier: 'first' |
5 | } |
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