git ssb

2+

ev / mvd



Commit a3aae45576351f9d55af56565c63152b46aeb727

clean up

Ev Bogue committed on 4/25/2018, 8:43:27 PM
Parent: 2c8fcfab04922a4ef2dbb7c289f7f76e164b4f90

Files changed

render.jschanged
style.csschanged
style.css.jsonchanged
render.jsView
@@ -1,15 +1,12 @@
11 var h = require('hyperscript')
2-
32 var human = require('human-time')
43 var ref = require('ssb-ref')
54 var avatar = require('./avatar')
65
76 var markdown = require('ssb-markdown')
87 var config = require('./config')()
98
10-var render = require('./render')
11-
129 function rawJSON (obj) {
1310 return JSON.stringify(obj, null, 2)
1411 .split(/([%@&][a-zA-Z0-9\/\+]{43}=*\.[\w]+)/)
1512 .map(function (e) {
@@ -19,80 +16,60 @@
1916 return e
2017 })
2118 }
2219
20 +function header (msg) {
21 + return h('div.header',
22 + h('span.avatar',
23 + h('a', {href: '#' + msg.value.author},
24 + h('span.avatar--small', avatar.image(msg.value.author)),
25 + avatar.name(msg.value.author)
26 + )
27 + ),
28 + h('span.timestamp', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp)))),
29 + )
30 +}
31 +
2332 module.exports = function (msg) {
33 + var message = h('div.message')
34 + message.appendChild(header(msg))
35 +
2436 if (msg.value.content.type == 'post') {
25- return h('div.message',
26- h('span.avatar',
27- h('a', {href: '#' + msg.value.author},
28- h('span.avatar--small', avatar.image(msg.value.author)),
29- avatar.name(msg.value.author)
30- )
31- ),
32- h('span.timestamp', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp)))),
33- h('div.message__body',
37 + message.appendChild(h('div.message__body',
3438 {innerHTML: markdown.block(msg.value.content.text, {toUrl: function (url, image) {
35- if(url[0] == '@') return '#' + url
36- if(url[0] == '%') return '#' + url
39 + if(url[0] == '%' || url[0] == '@') return '#' + url
3740 if(!image) return url
3841 if(url[0] !== '&') return url
39- return config.blobsurl + url
42 + return config.blobsUrl + url
4043 }})}
4144 )
4245 )
46 + return message
4347 } else if (msg.value.content.type == 'vote') {
4448 var embed = msg.value.content.vote.link
4549
4650 var embedded = h('div.embedded')
47-
4851 sbot.get(embed, function (err, msg) {
4952 if (err) {console.log('could not find message locally, try ooo?') }
50- console.log(msg)
5153 msg.value = msg
5254 msg.key = embed
5355 if (msg.value.content.text) {
54- embedded.appendChild(
55- h('div.message',
56- h('span.avatar',
57- h('a', {href: '#' + msg.value.author},
58- h('span.avatar--small', avatar.image(msg.value.author)),
59- avatar.name(msg.value.author)
60- )
61- ),
62- h('span.timestamp', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp)))),
63- h('div.message__body',
64- {innerHTML: markdown.block(msg.value.content.text, {toUrl: function (url, image) {
65- if(url[0] == '@') return '#' + url
66- if(url[0] == '%') return '#' + url
67- if(!image) return url
68- if(url[0] !== '&') return url
69- return config.blobsUrl + url
70- }})}
71- )
72- )
73- )
56 + message.appendChild(h('img.emoji', {src: config.emojiUrl + 'star.png'}))
57 + message.appendChild(embedded)
58 + embedded.appendChild(header(msg))
59 + embedded.appendChild(h('div.message__body',
60 + {innerHTML: markdown.block(msg.value.content.text, {toUrl: function (url, image) {
61 + if(url[0] == '@') return '#' + url
62 + if(url[0] == '%') return '#' + url
63 + if(!image) return url
64 + if(url[0] !== '&') return url
65 + return config.blobsUrl + url
66 + }})}
67 + ))
7468 }
7569 })
76- return h('div.message',
77- h('span.avatar',
78- h('a', {href: '#' + msg.value.author},
79- h('span.avatar--small', avatar.image(msg.value.author)),
80- avatar.name(msg.value.author)
81- ), h('img.emoji', {src: config.emojiUrl + 'star.png'})
82- ),
83- h('span.timestamp', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp)))),
84- h('div.message__body', embedded)
85- )
70 + return message
8671 } else {
87- return h('div.message',
88- h('span.avatar',
89- h('a', {href: '#' + msg.value.author},
90- h('span.avatar--small', avatar.image(msg.value.author)),
91- avatar.name(msg.value.author)
92- )
93- ),
94- h('span.timestamp', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp)))),
95- h('pre', rawJSON(msg.value.content))
96- )
72 + message.appendChild(h('pre', rawJSON(msg.value.content)))
73 + return message
9774 }
9875 }
style.cssView
@@ -18,15 +18,20 @@
1818 margin-left: auto;
1919 margin-right: auto;
2020 }
2121
22-.message {
22 +.message, .embedded {
2323 display: block;
24- margin: .5em;
24 + margin: .6em;
2525 background: #111;
2626 padding: .5em;
2727 }
2828
29 +.embedded {
30 + border-left: 1px solid #666;
31 + padding-left: 1em;
32 +}
33 +
2934 .message img {
3035 max-width: 100%;
3136 }
3237
@@ -41,8 +46,9 @@
4146 margin-right: .2em;
4247 }
4348
4449 .emoji {
50 + float: left;
4551 width: 1.4em;
4652 vertical-align: top;
4753 }
4854
style.css.jsonView
@@ -1,1 +1,1 @@
1-"body {\n background: black;\n font-family: sans-serif;\n color: #ddd;\n font-size: .9em;\n}\n\n.hyperscroll {\n width: 100%;\n}\n\na {\n color: #f5f5f5;\n}\n\n.hyperscroll > .content {\n max-width: 680px;\n margin-left: auto;\n margin-right: auto;\n}\n\n.message {\n display: block;\n margin: .5em;\n background: #111;\n padding: .5em;\n}\n\n.message img {\n max-width: 100%;\n}\n\n.timestamp {\n float: right;\n}\n\n.avatar--small img {\n vertical-align: top;\n width: 1.4em;\n height: 1.4em;\n margin-right: .2em;\n}\n\n.emoji {\n width: 1.4em;\n vertical-align: top;\n}\n\npre {\n width: 100%;\n display: block;\n}\n\ncode {\n display: inline-block;\n vertical-align: bottom;\n}\n\ncode, pre {\noverflow: auto;\nword-break: break-all;\nword-wrap: break-word;\nwhite-space: pre;\nwhite-space: -moz-pre-wrap;\nwhite-space: pre-wrap;\nwhite-space: pre\\9;\n}\n\n"
1 +"body {\n background: black;\n font-family: sans-serif;\n color: #ddd;\n font-size: .9em;\n}\n\n.hyperscroll {\n width: 100%;\n}\n\na {\n color: #f5f5f5;\n}\n\n.hyperscroll > .content {\n max-width: 680px;\n margin-left: auto;\n margin-right: auto;\n}\n\n.message, .embedded {\n display: block;\n margin: .6em;\n background: #111;\n padding: .5em;\n}\n\n.embedded {\n border-left: 1px solid #666;\n padding-left: 1em;\n}\n\n.message img {\n max-width: 100%;\n}\n\n.timestamp {\n float: right;\n}\n\n.avatar--small img {\n vertical-align: top;\n width: 1.4em;\n height: 1.4em;\n margin-right: .2em;\n}\n\n.emoji {\n float: left;\n width: 1.4em;\n vertical-align: top;\n}\n\npre {\n width: 100%;\n display: block;\n}\n\ncode {\n display: inline-block;\n vertical-align: bottom;\n}\n\ncode, pre {\noverflow: auto;\nword-break: break-all;\nword-wrap: break-word;\nwhite-space: pre;\nwhite-space: -moz-pre-wrap;\nwhite-space: pre-wrap;\nwhite-space: pre\\9;\n}\n\n"

Built with git-ssb-web