git ssb

2+

ev / mvd



Tree: 612b9afbdd5bbeaf56306ee43dd7e0d3d6599a16

Files: 612b9afbdd5bbeaf56306ee43dd7e0d3d6599a16 / rendertools.js

921 bytesRaw
1var h = require('hyperscript')
2var human = require('human-time')
3var avatar = require('./avatar')
4var ref = require('ssb-ref')
5
6
7module.exports.header = function (msg) {
8 return h('div.header',
9 h('span.avatar',
10 h('a', {href: '#' + msg.value.author},
11 h('span.avatar--small', avatar.image(msg.value.author)),
12 avatar.name(msg.value.author)
13 )
14 ),
15 h('span.timestamp', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp)))),
16 )
17}
18
19module.exports.messageLink = function (msglink) {
20 var link = h('span', h('a', {href: '#' + msglink}, msglink.substring(0, 8) + '...'))
21 return link
22}
23
24module.exports.rawJSON = function (obj) {
25 return JSON.stringify(obj, null, 2)
26 .split(/([%@&][a-zA-Z0-9\/\+]{43}=*\.[\w]+)/)
27 .map(function (e) {
28 if(ref.isMsg(e) || ref.isFeed(e) || ref.isBlob(e)) {
29 return h('a', {href: '#' + e}, e)
30 }
31 return e
32 })
33}
34

Built with git-ssb-web