Files: 612b9afbdd5bbeaf56306ee43dd7e0d3d6599a16 / rendertools.js
921 bytesRaw
1 | var h = require('hyperscript') |
2 | var human = require('human-time') |
3 | var avatar = require('./avatar') |
4 | var ref = require('ssb-ref') |
5 | |
6 | |
7 | module.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 | |
19 | module.exports.messageLink = function (msglink) { |
20 | var link = h('span', h('a', {href: '#' + msglink}, msglink.substring(0, 8) + '...')) |
21 | return link |
22 | } |
23 | |
24 | module.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