git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 7c4d6df66f14e6f9d83ca2763a2fcd102369592e

Files: 7c4d6df66f14e6f9d83ca2763a2fcd102369592e / message / html / render / post.js

1237 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({
15 'message.html': {
16 canRender: true,
17 render: true
18 }
19})
20
21exports.create = function (api) {
22 return nest('message.html', {
23 canRender: isRenderable,
24 render: function (msg, opts) {
25 if (!isRenderable(msg)) return
26 var element = api.message.html.layout(msg, extend({
27 title: messageTitle(msg),
28 content: msg.isBlocked ? 'Content of a blocked user' : messageContent(msg),
29 layout: 'default'
30 }, opts))
31
32 return api.message.html.decorate(element, {
33 msg
34 })
35 }
36 })
37
38 function isRenderable (msg) {
39 return (msg.value.content.type === 'post') ? true : undefined
40 }
41
42 function messageContent (data) {
43 if (!data.value.content || !data.value.content.text) return
44 return h('div', {}, api.message.html.markdown(data.value.content))
45 }
46
47 function messageTitle (data) {
48 var root = data.value.content && data.value.content.root
49 return !root ? null : h('span', ['re: ', api.message.html.link(root)])
50 }
51}
52

Built with git-ssb-web