git ssb

2+

ev / mvd



Commit c6c1604992a6dd8231bbb8bf42a6957286330677

render markdown and raw messages

Ev Bogue committed on 4/21/2018, 2:41:56 AM
Parent: 50f7c8870ccd7ef8771ac98be8f27c62fea59e60

Files changed

render.jschanged
render.jsView
@@ -3,13 +3,40 @@
33 var human = require('human-time')
44
55 var avatar = require('./avatar')
66
7 +var markdown = require('ssb-markdown')
8 +var config = require('./config')()
9 +
10 +var rawJSON = require('patchapp-raw/json')
11 +
712 module.exports = function (msg) {
813 if (msg.value.content.type == 'post') {
914 return h('div.message__content',
10- h('span.avatar', h('a', {href: '#' + msg.value.author}, avatar.name(msg.value.author))),
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 + ),
1121 h('span.timestamp', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp)))),
12- h('div.message__body', msg.value.content.text)
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 + )
1329 )
14- } else { return }
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 + }
1542 }

Built with git-ssb-web