git ssb

2+

ev / mvd



Commit 75a88ef69dff48f8857d5a63d03c413d76c52ce1

set message branch in composer

Ev Bogue committed on 4/30/2018, 11:05:54 PM
Parent: 291141e14691f615e3f1006a1af1705f72e8c333

Files changed

compose.jschanged
render.jschanged
rendertools.jsdeleted
tools.jsadded
compose.jsView
@@ -1,11 +1,12 @@
11 var h = require('hyperscript')
22 var pull = require('pull-stream')
33 var sbot = require('./scuttlebot')
44
5-var header = require('./rendertools').header
65 var id = require('./keys').id
76
7 +var tools = require('./tools')
8 +
89 var mime = require('simple-mime')('application/octect-stream')
910 var split = require('split-buffer')
1011
1112 function file_input (onAdded) {
@@ -52,17 +53,18 @@
5253 msg.value = {
5354 "author": id,
5455 "content": {
5556 "type": opts.type,
56- "root": opts.root
57 + "root": opts.root,
58 + "branch": opts.branch
5759 }
5860 }
5961 msg.value.content.text = textarea.value
6062 console.log(msg)
6163
6264 var preview = h('div',
63- header(msg),
64- h('div.message__content', msg.value.content.text),
65 + tools.header(msg),
66 + h('div.message__content', tools.markdown(msg.value.content.text)),
6567 h('button.btn', 'Publish', {
6668 onclick: function () {
6769 sbot.publish(msg.value.content, function (err, msg) {
6870 if(err) throw err
render.jsView
@@ -1,32 +1,26 @@
11 var h = require('hyperscript')
2-var markdown = require('ssb-markdown')
32 var config = require('./config')()
43
54 var sbot = require('./scuttlebot')
65 var composer = require('./compose')
76
8-var tools = require('./rendertools')
7 +var tools = require('./tools')
98
109 module.exports = function (msg) {
1110 var opts = {}
1211 opts.root = null
1312 var message = h('div.message')
1413 if (msg.value.content.type == 'post') {
1514 message.appendChild(tools.header(msg))
1615 opts.type = 'post'
16 + opts.branch = msg.key
1717 if (msg.value.content.root) {
1818 message.appendChild(h('span', 're: ', tools.messageLink(msg.value.content.root)))
1919 opts.root = msg.value.content.root
2020 } else { opts.root = msg.key}
21- message.appendChild(h('div.message__body',
22- {innerHTML: markdown.block(msg.value.content.text, {toUrl: function (url, image) {
23- if(url[0] == '%' || url[0] == '@') return '#' + url
24- if(!image) return url
25- if(url[0] !== '&') return url
26- return config.blobsUrl + url
27- }})}
28- )
21 + message.appendChild(
22 + h('div.message__body', tools.markdown(msg.value.content.text))
2923 )
3024 message.appendChild(h('button.btn', 'Reply', {
3125 onclick: function () {
3226 var compose = composer(opts)
@@ -45,23 +39,20 @@
4539 msg.key = embed
4640 if (msg.value.content.text) {
4741 message.appendChild(embedded)
4842 embedded.appendChild(tools.header(msg))
49- embedded.appendChild(h('div.message__body',
50- {innerHTML: markdown.block(msg.value.content.text.substring(0, 256) + '... ', {toUrl: function (url, image) {
51- if(url[0] == '@') return '#' + url
52- if(url[0] == '%') return '#' + url
53- if(!image) return url
54- if(url[0] !== '&') return url
55- return config.blobsUrl + url
56- }})}, tools.messageLink(msg.key)
57- ))
43 + embedded.appendChild(
44 + h('div.message__body',
45 + tools.markdown(msg.value.content.text.substring(0, 256) + '...'),
46 + h('span', '[', h('a', {href: '#' + msg.key}, 'Full Post'), ']')
47 + )
48 + )
5849 }
5950 })
6051 return message
6152 } else {
62- //message.appendChild(tools.header(msg))
63- //message.appendChild(h('pre', tools.rawJSON(msg.value.content)))
64- //return message
65- return
53 + message.appendChild(tools.header(msg))
54 + message.appendChild(h('pre', tools.rawJSON(msg.value.content)))
55 + return message
56 + //return
6657 }
6758 }
rendertools.jsView
@@ -1,32 +1,0 @@
1-var h = require('hyperscript')
2-var human = require('human-time')
3-var avatar = require('./avatar')
4-var ref = require('ssb-ref')
5-
6-module.exports.header = function (msg) {
7- return h('div.header',
8- h('span.avatar',
9- h('a', {href: '#' + msg.value.author},
10- h('span.avatar--small', avatar.image(msg.value.author)),
11- avatar.name(msg.value.author)
12- )
13- ),
14- h('span.timestamp', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp)))),
15- )
16-}
17-
18-module.exports.messageLink = function (msglink) {
19- var link = h('span', h('a', {href: '#' + msglink}, msglink.substring(0, 8) + '...'))
20- return link
21-}
22-
23-module.exports.rawJSON = function (obj) {
24- return JSON.stringify(obj, null, 2)
25- .split(/([%@&][a-zA-Z0-9\/\+]{43}=*\.[\w]+)/)
26- .map(function (e) {
27- if(ref.isMsg(e) || ref.isFeed(e) || ref.isBlob(e)) {
28- return h('a', {href: '#' + e}, e)
29- }
30- return e
31- })
32-}
tools.jsView
@@ -1,0 +1,44 @@
1 +var h = require('hyperscript')
2 +var human = require('human-time')
3 +var avatar = require('./avatar')
4 +var ref = require('ssb-ref')
5 +
6 +module.exports.header = function (msg) {
7 + return h('div.header',
8 + h('span.avatar',
9 + h('a', {href: '#' + msg.value.author},
10 + h('span.avatar--small', avatar.image(msg.value.author)),
11 + avatar.name(msg.value.author)
12 + )
13 + ),
14 + h('span.timestamp', h('a', {href: '#' + msg.key}, human(new Date(msg.value.timestamp)))),
15 + )
16 +}
17 +
18 +module.exports.messageLink = function (msglink) {
19 + var link = h('span', h('a', {href: '#' + msglink}, msglink.substring(0, 8) + '...'))
20 + return link
21 +}
22 +
23 +module.exports.rawJSON = function (obj) {
24 + return JSON.stringify(obj, null, 2)
25 + .split(/([%@&][a-zA-Z0-9\/\+]{43}=*\.[\w]+)/)
26 + .map(function (e) {
27 + if(ref.isMsg(e) || ref.isFeed(e) || ref.isBlob(e)) {
28 + return h('a', {href: '#' + e}, e)
29 + }
30 + return e
31 + })
32 +}
33 +
34 +var markdown = require('ssb-markdown')
35 +var config = require('./config')()
36 +
37 +module.exports.markdown = function (msg, md) {
38 + return {innerHTML: markdown.block(msg, {toUrl: function (url, image) {
39 + if(url[0] == '%' || url[0] == '@') return '#' + url
40 + if(!image) return url
41 + if(url[0] !== '&') return url
42 + return config.blobsUrl + url
43 + }})}
44 +}

Built with git-ssb-web