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