Files: b58dd46b8f88f0917c480faf8286bdd209933739 / plugs / message_render / vote.js
695 bytesRaw
1 | var h = require('mutant/h') |
2 | |
3 | exports.needs = { |
4 | message_layout: 'first', |
5 | message_decorate: 'reduce', |
6 | message_link: 'first', |
7 | markdown: 'first' |
8 | } |
9 | |
10 | exports.gives = { |
11 | message_render: true |
12 | } |
13 | |
14 | exports.create = function (api) { |
15 | return { |
16 | message_render |
17 | } |
18 | |
19 | function message_render (msg) { |
20 | if (msg.value.content.type !== 'vote') return |
21 | var element = api.message_layout(msg, { |
22 | content: render_vote(msg), |
23 | layout: 'mini' |
24 | }) |
25 | |
26 | return api.message_decorate(element, { msg }) |
27 | } |
28 | |
29 | function render_vote (msg) { |
30 | var link = msg.value.content.vote.link |
31 | return [ |
32 | msg.value.content.vote.value > 0 ? 'dug' : 'undug', ' ', api.message_link(link) |
33 | ] |
34 | } |
35 | } |
36 |
Built with git-ssb-web