git ssb

2+

ev / mvd



Tree: 22845e6da7a120adb2b33163b4a7f46979fcc97b

Files: 22845e6da7a120adb2b33163b4a7f46979fcc97b / render.js

1295 bytesRaw
1var h = require('hyperscript')
2
3var human = require('human-time')
4
5var avatar = require('./avatar')
6
7var markdown = require('ssb-markdown')
8var config = require('./config')()
9
10var rawJSON = require('patchapp-raw/json')
11
12module.exports = function (msg) {
13 if (msg.value.content.type == 'post') {
14 return h('div.message__content',
15 h('span.avatar',
16 h('a', {href: '#' + msg.value.author},
17 h('span.avatar--small', avatar.image(msg.value.author)),
18 avatar.name(msg.value.author)
19 )
20 ),
21 h('span.timestamp', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp)))),
22 h('div.message__body',
23 {innerHTML: markdown.block(msg.value.content.text, {toUrl: function (url, image) {
24 if(!image) return url
25 if(url[0] !== '&') return url
26 return config.blobsurl + url
27 }})}
28 )
29 )
30 } else {
31 return h('div.message__content',
32 h('span.avatar',
33 h('a', {href: '#' + msg.value.author},
34 h('span.avatar--small', avatar.image(msg.value.author)),
35 avatar.name(msg.value.author)
36 )
37 ),
38 h('span.timestamp', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp)))),
39 h('pre.raw__json', {id: msg.key}, rawJSON(msg))
40 )
41 }
42}
43

Built with git-ssb-web