git ssb

0+

ev / gitmx



Commit c68f5e54b067301117c9d60b66ddb801e6280484

abstract labels into tools, and tweak git renders

Ev Bogue committed on 2/13/2019, 4:58:25 AM
Parent: d1e853f691416e29ae636b734bbda1bfa0bd4b05

Files changed

render.jschanged
render.jsView
@@ -94,8 +94,10 @@
9494 }
9595 message.appendChild(tools.mini(msg, ' ' + msg.value.content.text))
9696 return message
9797 }
98 +
99 +
98100 else if (msg.value.content.type == 'contact') {
99101 if (msg.value.content.contact) {
100102 var contact = h('a', {href: '#' + msg.value.content.contact}, avatar.name(msg.value.content.contact))
101103 } else { var contact = h('p', 'no contact named')}
@@ -121,55 +123,62 @@
121123 }
122124
123125 else if (msg.value.content.type == 'git-update') {
124126
125- message.appendChild(tools.header(msg))
127 + var reponame = h('span', ' pushed to ', h('a', {href: '#' + msg.value.content.repo}, msg.value.content.repo))
126128
127- var reponame = h('p', 'pushed to ', h('a', {href: '#' + msg.value.content.repo}, msg.value.content.repo))
129 + message.appendChild(tools.mini(msg, reponame))
128130
129- var cloneurl = h('pre', 'git clone ssb://' + msg.value.content.repo)
130-
131- message.appendChild(reponame)
132-
133-
134131 ssbAvatar(sbot, id, msg.value.content.repo, function (err, data) {
135132 if (data) {
136- var actualname = h('p', 'pushed to ', h('a', {href: '#' + msg.value.content.repo}, '%' + data.name))
133 + var actualname = h('span', ' pushed to ', h('a', {href: '#' + msg.value.content.repo}, '%' + data.name))
137134 reponame.parentNode.replaceChild(actualname, reponame)
138135 }
139136 })
140137
141- message.appendChild(cloneurl)
138 + var commits = h('ul')
142139
143- var commits = h('ul')
144- //if (msg.value.content.commits[0]) {
145140 if (msg.value.content.commits) {
146141 msg.value.content.commits.map(function (commit) {
147142 commits.appendChild(h('li', h('code', commit.sha1), ' - ', commit.title))
148143 })
149-
150144 }
151145
152146 message.appendChild(commits)
153147
148 +
149 + var buttons = h('div.buttons')
150 + buttons.appendChild(tools.star(msg))
151 + buttons.appendChild(tools.labeler(msg))
152 + message.appendChild(tools.getLabels(msg))
153 + message.appendChild(buttons)
154 +
154155 return message
155156
156157 }
157158 else if (msg.value.content.type == 'git-repo') {
158- message.appendChild(tools.header(msg))
159159
160- var reponame = h('p', 'git-ssb repo ', h('a', {href: '#' + msg.key}, msg.key))
161-
162- message.appendChild(reponame)
160 + var reponame = h('span', ' created a git-ssb repo ', h('a', {href: '#' + msg.key}, msg.key))
163161
162 + message.appendChild(tools.mini(msg, reponame))
163 +
164164 ssbAvatar(sbot, id, msg.key, function (err, data) {
165165 if (data)
166- var actualname = h('p', 'git-ssb repo ', h('a', {href: '#' + msg.key}, '%' + data.name))
166 + var actualname = h('span', ' created a git-ssb repo ', h('a', {href: '#' + msg.key}, '%' + data.name))
167167 reponame.parentNode.replaceChild(actualname, reponame)
168168 })
169169
170170 var cloneurl = h('pre', 'git clone ssb://' + msg.key)
171171 message.appendChild(cloneurl)
172 +
173 + var buttons = h('div.buttons')
174 +
175 + buttons.appendChild(tools.star(msg))
176 + buttons.appendChild(tools.labeler(msg))
177 + message.appendChild(tools.getLabels(msg))
178 +
179 + message.appendChild(buttons)
180 +
172181 return message
173182 }
174183
175184 else if (msg.value.content.type == 'wiki') {
@@ -268,19 +277,8 @@
268277 }
269278 })
270279 )
271280
272- pull(
273- sbot.query({query: [{$filter: {value: { content: {type: 'label', link: msg.key}}}}], limit: 100, live: true}),
274- pull.drain(function (labels){
275- console.log(labels)
276- if (labels.value){
277- message.appendChild(h('span', ' ', h('mark', h('a', {href: '/#label/' + labels.value.content.label}, labels.value.content.label))))
278-
279- }
280- })
281- )
282-
283281 var name = avatar.name(msg.value.author)
284282
285283 var buttons = h('div.buttons')
286284
@@ -343,36 +341,13 @@
343341 }
344342 }))
345343
346344
347- var inputter = h('input', {placeholder: 'Add a label to this post ie art, books, new'})
348-
349- var labeler = h('div',
350- inputter,
351- h('button.btn', 'Publish label', {
352- onclick: function () {
353- var post = {}
354- post.type = 'label',
355- post.label = inputter.value,
356- post.link = msg.key
357-
358- sbot.publish(post, function (err, msg){
359- console.log(msg)
360- labeler.parentNode.replaceChild(buttons, labeler)
361- })
362- }
363- })
364- )
365-
366- var labels = h('button.btn', 'Add label', {
367- onclick: function () {
368- buttons.parentNode.replaceChild(labeler, buttons)
369- }
370- })
371-
372- buttons.appendChild(labels)
373345 buttons.appendChild(tools.queueButton(msg))
374346 buttons.appendChild(tools.star(msg))
347 + buttons.appendChild(tools.labeler(msg))
348 + message.appendChild(tools.getLabels(msg))
349 +
375350 message.appendChild(buttons)
376351 return message
377352
378353 } else if (msg.value.content.type == 'vote') {

Built with git-ssb-web