git ssb

10+

Matt McKegg / patchwork



Commit b6089670d854fcefa6bc5ca05636a801707deb30

add `/data-feed` url to access raw messages being synced

Matt McKegg committed on 11/2/2016, 3:41:17 AM
Parent: 44e517454ddcdf910952c5689b462967e22fdb75

Files changed

modules/message.jschanged
modules/data-feed.jsadded
styles/message.mcsschanged
modules/message.jsView
@@ -12,8 +12,22 @@
1212 var message_main_meta = plugs.map(exports.message_main_meta = [])
1313 var message_action = plugs.map(exports.message_action = [])
1414 var contextMenu = require('../lib/context-menu')
1515
16 +exports.data_render = function (msg) {
17 + var div = h('Message -data', {
18 + 'ev-contextmenu': contextMenu.bind(null, msg)
19 + }, [
20 + messageHeader(msg),
21 + h('section', [
22 + h('pre', [
23 + JSON.stringify(msg.value, null, 2)
24 + ])
25 + ])
26 + ])
27 + return div
28 +}
29 +
1630 exports.message_render = function (msg, inContext, previousId) {
1731 var elMini = message_content_mini(msg)
1832 if (elMini) {
1933 var div = h('Message', {
@@ -55,23 +69,9 @@
5569 element.querySelector('.enter').click()
5670 }
5771 }
5872 }, [
59- h('header', [
60- h('div.main', [
61- h('a.avatar', {href: `#${msg.value.author}`}, avatar_image(msg.value.author)),
62- h('div.main', [
63- h('div.name', [
64- h('a', {href: `#${msg.value.author}`}, avatar_name(msg.value.author))
65- ]),
66- h('div.meta', [
67- message_main_meta(msg),
68- ' ', replyInfo
69- ])
70- ])
71- ]),
72- h('div.meta', message_meta(msg))
73- ]),
73 + messageHeader(msg, replyInfo),
7474 h('section', [el]),
7575 when(msg.key, h('footer', [
7676 h('div.actions', [
7777 message_action(msg),
@@ -85,8 +85,26 @@
8585
8686 return element
8787 }
8888
89 +function messageHeader (msg, replyInfo) {
90 + return h('header', [
91 + h('div.main', [
92 + h('a.avatar', {href: `#${msg.value.author}`}, avatar_image(msg.value.author)),
93 + h('div.main', [
94 + h('div.name', [
95 + h('a', {href: `#${msg.value.author}`}, avatar_name(msg.value.author))
96 + ]),
97 + h('div.meta', [
98 + message_main_meta(msg),
99 + ' ', replyInfo
100 + ])
101 + ])
102 + ]),
103 + h('div.meta', message_meta(msg))
104 + ])
105 +}
106 +
89107 function last (array) {
90108 if (Array.isArray(array)) {
91109 return array[array.length - 1]
92110 } else {
modules/data-feed.jsView
@@ -1,0 +1,32 @@
1 +var h = require('hyperscript')
2 +var u = require('patchbay/util')
3 +var pull = require('pull-stream')
4 +var Scroller = require('pull-scroll')
5 +
6 +var plugs = require('patchbay/plugs')
7 +var sbot_log = plugs.first(exports.sbot_log = [])
8 +var data_render = plugs.first(exports.data_render = [])
9 +
10 +exports.screen_view = function (path, sbot) {
11 + if(path === '/data-feed') {
12 + var content = h('div.column.scroller__content')
13 + var div = h('div.column.scroller',
14 + {style: {'overflow':'auto'}},
15 + h('div.scroller__wrapper',
16 + content
17 + )
18 + )
19 +
20 + pull(
21 + u.next(sbot_log, {old: false, limit: 100}),
22 + Scroller(div, content, data_render, true, false)
23 + )
24 +
25 + pull(
26 + u.next(sbot_log, {reverse: true, limit: 100, live: false}),
27 + Scroller(div, content, data_render, false, false)
28 + )
29 +
30 + return div
31 + }
32 +}
styles/message.mcssView
@@ -9,8 +9,25 @@
99 :focus {
1010 z-index: 1
1111 }
1212
13 + -data {
14 + header {
15 + div.main {
16 + font-size: 80%
17 + a.avatar {
18 + img {
19 + width: 25px
20 + }
21 + }
22 + }
23 + }
24 + (pre) {
25 + overflow: auto
26 + max-height: 200px
27 + }
28 + }
29 +
1330 -reply {
1431 header {
1532 div.main {
1633 a.avatar {

Built with git-ssb-web