git ssb

2+

ev / mvd



Commit 8c9cc0b21eca28ac144356172dd3e6751ff73d3b

merge labels into master

Ev Bogue committed on 2/9/2019, 6:42:07 PM
Parent: 86ead1fef00900a6c2c146204116783ab4b69ce9
Parent: fd5b5ec859326033c364c31f5df00f867216815f

Files changed

render.jschanged
style.csschanged
views.jschanged
render.jsView
@@ -33,8 +33,14 @@
3333 message.appendChild(tools.mini(msg, muted))
3434 return message
3535 }
3636
37 + else if (msg.value.content.type == 'label'){
38 + var content = h('span', ' labeled ', tools.messageLink(msg.value.content.link), ' as ', h('mark', h('a', {href: '/#label/' + msg.value.content.label}, msg.value.content.label)))
39 + message.appendChild(tools.mini(msg, content))
40 + return message
41 + }
42 +
3743 else if (msg.value.content.type == 'queue') {
3844 if (msg.value.content.queue == true) {
3945 var content = h('span', ' added ', tools.messageLink(msg.value.content.message), ' to their ', h('a', {href: '#queue'}, 'queue'))
4046 message.appendChild(tools.mini(msg, content))
@@ -262,8 +268,19 @@
262268 }
263269 })
264270 )
265271
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 +
266283 var name = avatar.name(msg.value.author)
267284
268285 var buttons = h('div.buttons')
269286
@@ -325,8 +342,35 @@
325342 message.replaceChild(compose, message.lastElementChild)
326343 }
327344 }))
328345
346 +
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)
329373 buttons.appendChild(tools.queueButton(msg))
330374 buttons.appendChild(tools.star(msg))
331375 message.appendChild(buttons)
332376 return message
style.cssView
@@ -68,8 +68,13 @@
6868 a:hover {
6969 color: #ddd;
7070 }
7171
72 +.breadcrumbs {
73 + color: #363636;
74 + background: #f5f5f5;
75 +}
76 +
7277 .navbar a {
7378 color: #999;
7479 text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
7580 text-decoration: none;
views.jsView
@@ -35,8 +35,53 @@
3535
3636 screen.appendChild(hyperscroll(content))
3737 }
3838
39 +var labelStream = function (label){
40 + var content = h('div.content')
41 + var screen = document.getElementById('screen')
42 + screen.appendChild(hyperscroll(content))
43 + content.appendChild(h('div.breadcrumbs.message', h('a', {href: '/'}, 'label'), ' ⯈ ' , h('a', {href: '/#label/' + label}, label)))
44 + function createStream (opts) {
45 + return pull(
46 + Next(sbot.query, opts, ['value', 'timestamp']),
47 + pull.map(function (msg){
48 + if (msg.value) {
49 + sbot.get(msg.value.content.link, function (err, data) {
50 + if (data) {
51 + var message = {}
52 + message.value = data
53 + message.key = msg.value.content.link
54 + content.appendChild(render(message))
55 + }
56 + })
57 + }
58 + })
59 + )
60 + }
61 +
62 + pull(
63 + createStream({
64 + limit: 10,
65 + reverse: true,
66 + live: false,
67 + query: [{$filter: { value: { content: {type: 'label', label: label }, timestamp: { $gt: 0 }}}}]
68 + }),
69 + stream.bottom(content)
70 + )
71 +
72 + pull(
73 + createStream({
74 + limit: 10,
75 + old: false,
76 + live: true,
77 + query: [{$filter: { value: { content: {type: 'label', label: label }, timestamp: { $gt: 0 }}}}]
78 + }),
79 + stream.top(content)
80 + )
81 +}
82 +
83 +
3984 var privateStream = function () {
4085 var screen = document.getElementById('screen')
4186 var content = h('div.content')
4287
@@ -701,8 +746,10 @@
701746 } else if (ref.isFeed(src.substring(5))) {
702747 mentionsStream(src.substring(5))
703748 } else if (ref.isFeed(src.substring(8))) {
704749 friendsStream(src.substring(8))
750 + } else if (src.substring(0, 6) === 'label/') {
751 + labelStream(src.substring(6))
705752 } else if (src == 'queue') {
706753 queueStream()
707754 } else if (src == 'about') {
708755 about()

Built with git-ssb-web