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