git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 12f9e4861605413f2f160d9b2f15e4810a1c17b0

Files: 12f9e4861605413f2f160d9b2f15e4810a1c17b0 / message / html / render / vote.js

808 bytesRaw
1var h = require('mutant/h')
2var nest = require('depnest')
3var extend = require('xtend')
4
5exports.needs = nest({
6 'message.html': {
7 decorate: 'reduce',
8 layout: 'first',
9 link: 'first',
10 markdown: 'first'
11 }
12})
13
14exports.gives = nest('message.html.render')
15
16exports.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