Commit 8c9cc0b21eca28ac144356172dd3e6751ff73d3b
merge labels into master
Ev Bogue committed on 2/9/2019, 6:42:07 PMParent: 86ead1fef00900a6c2c146204116783ab4b69ce9
Parent: fd5b5ec859326033c364c31f5df00f867216815f
Files changed
render.js | changed |
style.css | changed |
views.js | changed |
render.js | ||
---|---|---|
@@ -33,8 +33,14 @@ | ||
33 | 33 | message.appendChild(tools.mini(msg, muted)) |
34 | 34 | return message |
35 | 35 | } |
36 | 36 | |
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 | + | |
37 | 43 | else if (msg.value.content.type == 'queue') { |
38 | 44 | if (msg.value.content.queue == true) { |
39 | 45 | var content = h('span', ' added ', tools.messageLink(msg.value.content.message), ' to their ', h('a', {href: '#queue'}, 'queue')) |
40 | 46 | message.appendChild(tools.mini(msg, content)) |
@@ -262,8 +268,19 @@ | ||
262 | 268 | } |
263 | 269 | }) |
264 | 270 | ) |
265 | 271 | |
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 | + | |
266 | 283 | var name = avatar.name(msg.value.author) |
267 | 284 | |
268 | 285 | var buttons = h('div.buttons') |
269 | 286 | |
@@ -325,8 +342,35 @@ | ||
325 | 342 | message.replaceChild(compose, message.lastElementChild) |
326 | 343 | } |
327 | 344 | })) |
328 | 345 | |
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) | |
329 | 373 | buttons.appendChild(tools.queueButton(msg)) |
330 | 374 | buttons.appendChild(tools.star(msg)) |
331 | 375 | message.appendChild(buttons) |
332 | 376 | return message |
style.css | ||
---|---|---|
@@ -68,8 +68,13 @@ | ||
68 | 68 | a:hover { |
69 | 69 | color: #ddd; |
70 | 70 | } |
71 | 71 | |
72 | +.breadcrumbs { | |
73 | + color: #363636; | |
74 | + background: #f5f5f5; | |
75 | +} | |
76 | + | |
72 | 77 | .navbar a { |
73 | 78 | color: #999; |
74 | 79 | text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); |
75 | 80 | text-decoration: none; |
views.js | ||
---|---|---|
@@ -35,8 +35,53 @@ | ||
35 | 35 | |
36 | 36 | screen.appendChild(hyperscroll(content)) |
37 | 37 | } |
38 | 38 | |
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 | + | |
39 | 84 | var privateStream = function () { |
40 | 85 | var screen = document.getElementById('screen') |
41 | 86 | var content = h('div.content') |
42 | 87 | |
@@ -701,8 +746,10 @@ | ||
701 | 746 | } else if (ref.isFeed(src.substring(5))) { |
702 | 747 | mentionsStream(src.substring(5)) |
703 | 748 | } else if (ref.isFeed(src.substring(8))) { |
704 | 749 | friendsStream(src.substring(8)) |
750 | + } else if (src.substring(0, 6) === 'label/') { | |
751 | + labelStream(src.substring(6)) | |
705 | 752 | } else if (src == 'queue') { |
706 | 753 | queueStream() |
707 | 754 | } else if (src == 'about') { |
708 | 755 | about() |
Built with git-ssb-web