git ssb

2+

ev / mvd



Tree: 30b8296223f75e62735b9a3b804ff6d9f7c27697

Files: 30b8296223f75e62735b9a3b804ff6d9f7c27697 / render.js

1864 bytesRaw
1var h = require('hyperscript')
2var config = require('./config')()
3
4var pull = require('pull-stream')
5
6var sbot = require('./scuttlebot')
7var composer = require('./compose')
8
9var tools = require('./tools')
10
11module.exports = function (msg) {
12 var opts = {}
13 opts.root = null
14 var message = h('div.message')
15
16
17 if (msg.value.content.type == 'post') {
18
19
20 opts.type = 'post'
21 opts.branch = msg.key
22
23 message.appendChild(tools.header(msg))
24
25 if (msg.value.content.root) {
26 message.appendChild(h('span', 're: ', tools.messageLink(msg.value.content.root)))
27 opts.root = msg.value.content.root
28 } else { opts.root = msg.key }
29
30
31 message.appendChild(
32 h('div.message__body', tools.markdown(msg.value.content.text))
33 )
34
35 message.appendChild(h('button.btn', 'Reply', {
36 onclick: function () {
37 var compose = composer(opts)
38 message.replaceChild(compose, message.lastElementChild)
39 }
40 }))
41 return message
42 } else if (msg.value.content.type == 'vote') {
43 message.appendChild(tools.header(msg))
44 var embed = msg.value.content.vote.link
45
46 var embedded = h('div.embedded')
47 sbot.get(embed, function (err, msg) {
48 if (err) {console.log('could not find message locally, try ooo?') }
49 msg.value = msg
50 msg.key = embed
51 if (msg.value.content.text) {
52 message.appendChild(embedded)
53 embedded.appendChild(tools.header(msg))
54 embedded.appendChild(
55 h('div.message__body',
56 tools.markdown(msg.value.content.text.substring(0, 256) + '...'),
57 h('span', '[', h('a', {href: '#' + msg.key}, 'Full Post'), ']')
58 )
59 )
60 }
61 })
62 return message
63 } else {
64 //message.appendChild(tools.header(msg))
65 //message.appendChild(h('pre', tools.rawJSON(msg.value.content)))
66 //return message
67 return
68 }
69}
70

Built with git-ssb-web