git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit b934c63c9cd0fa08b3e84acd8cf5c8bae64e994c

basic git message render, and show if a message is private

Ev Bogue committed on 6/11/2018, 9:29:12 PM
Parent: 82667629e00c7d73e813e77adc04302f468562dc

Files changed

render.jschanged
render.jsView
@@ -8,8 +8,9 @@
88
99 var config = require('./config')()
1010 var id = require('./keys').id
1111
12+var avatar = require('./avatar')
1213
1314 module.exports = function (msg) {
1415 var message = h('div.message#' + msg.key.substring(0, 44))
1516
@@ -23,13 +24,50 @@
2324 message.appendChild(tools.mini(msg, muted))
2425 return message
2526 }
2627
27- if (msg.value.private == true) {
28+ /*if (msg.value.private == true) {
2829 var privateMsg = h('span', ' ', h('img.emoji', {src: config.emojiUrl + 'lock.png'}), ' ', h('button.btn', 'Open'))
2930 message.appendChild(tools.mini(msg, privateMsg))
3031 return message
32+ }*/
33+ else if (msg.value.content.type == 'git-update') {
34+
35+ message.appendChild(tools.header(msg))
36+
37+ var reponame = h('p', 'pushed to ', h('a', {href: '#' + msg.value.content.repo}, msg.value.content.repo))
38+
39+ var cloneurl = h('pre', 'git clone ssb://' + msg.value.content.repo)
40+
41+ message.appendChild(reponame)
42+
43+ pull(
44+ sbot.get(msg.value.content.repo, function (err, data) {
45+ if (err) throw err
46+ console.log(data)
47+ if (data.content.name) {
48+ actualname = h('p', 'pushed to ', h('a', {href: '#' + msg.value.content.repo}, '%' + data.content.name))
49+ reponame.parentNode.replaceChild(actualname, reponame)
50+ }
51+ })
52+ )
53+ message.appendChild(cloneurl)
54+ //message.appendChild(h('pre', tools.rawJSON(msg.value)))
55+ return message
56+
3157 }
58+ else if (msg.value.content.type == 'git-repo') {
59+ message.appendChild(tools.header(msg))
60+ if (msg.value.content.name) {
61+ message.appendChild(h('p', h('a', {href: msg.link}, '%' + msg.value.content.name)))
62+ } else {
63+ message.appendChild(h('p', h('a', {href: msg.link}, msg.link)))
64+ }
65+ var cloneurl = h('pre', 'git clone ssb://' + msg.key)
66+ message.appendChild(cloneurl)
67+ //message.appendChild(h('pre', tools.rawJSON(msg.value.content)))
68+ return message
69+ }
3270
3371 else if (msg.value.content.type == 'post') {
3472 var opts = {
3573 type: 'post',
@@ -72,8 +110,12 @@
72110 var buttons = h('div.buttons')
73111 buttons.appendChild(h('button.btn', 'Reply', {
74112 onclick: function () {
75113 opts.type = 'post'
114+ opts.mentions = '[' + avatar.name(msg.value.author).textContent + '](' + msg.value.author + ')'
115+ if (msg.value.content.recps) {
116+ opts.recps = msg.value.content.recps
117+ }
76118 var r = message.childNodes.length - 1
77119 delete opts.updated
78120 delete opts.original
79121 delete fallback.messageText
@@ -102,14 +144,10 @@
102144 message.replaceChild(compose, message.lastElementChild)
103145 }
104146 }))
105147
148+ buttons.appendChild(tools.done(msg.key))
106149
107- var done = h('button.btn.right', '+')
108- var add = h('button.btn.right', '-')
109-
110- buttons.appendChild(done)
111- buttons.appendChild(add)
112150 buttons.appendChild(tools.star(msg))
113151 message.appendChild(buttons)
114152 return message
115153
@@ -126,14 +164,13 @@
126164 return message
127165 } else {
128166
129167 //FULL FALLBACK
130- //message.appendChild(tools.header(msg))
131- //message.appendChild(h('pre', tools.rawJSON(msg.value.content)))
132- //return message
168+ message.appendChild(tools.header(msg))
169+ message.appendChild(h('pre', tools.rawJSON(msg.value.content)))
133170
134171 //MINI FALLBACK
135- var fallback = h('span', ' ' + msg.value.content.type)
136- message.appendChild(tools.mini(msg, fallback))
172+ //var fallback = h('span', ' ' + msg.value.content.type)
173+ //message.appendChild(tools.mini(msg, fallback))
137174 return message
138175 }
139176 }

Built with git-ssb-web