git ssb

0+

dangerousbeans / yap



forked from Dominic / yap

Tree: 8c686fb2b73c28246604759c61d6636e2812d871

Files: 8c686fb2b73c28246604759c61d6636e2812d871 / apis / messages / post.js

1072 bytesRaw
1var ref = require('ssb-ref')
2var niceAgo = require('nice-ago')
3var htmlEscape = require('html-escape')
4
5var u = require('../../util')
6var h = u.h
7toUrl = u.toUrl
8
9module.exports = u.createRenderer(function render (data, apply) {
10 var since = apply.since
11 var time = data.value.timestamp || data.timestamp
12 return h('div.Message',
13 u.cacheTag(toUrl('message', {id: data.key}), data.key, since),
14 h('div.MessageMeta',
15 apply('avatar', {id: data.value.author, name: true, image: true}),
16 h('a', {
17 href: toUrl('message', {id: data.key}),
18 title: new Date(time)+'\n'+data.key
19 },
20 ''+niceAgo(Date.now(), time)
21 ),
22 h('label.type', data.value.content.type),
23 h('label.msgId', data.key),
24
25 data.value.content.channel
26 ? h('a', {href: toUrl('public', {channel: data.value.content.channel})}, '#'+data.value.content.channel)
27 : '',
28
29 h('a', {href: toUrl('thread', {id: data.value.content.root || data.key})}, 'Thread')
30
31 ),
32 h('div.MessageContent', u.markdown(data.value.content))
33 )
34})
35
36
37

Built with git-ssb-web