git ssb

2+

ev / mvd



Tree: 49ecefe8720bc3af7ddca1a70870bdbadceae6da

Files: 49ecefe8720bc3af7ddca1a70870bdbadceae6da / views.js

1743 bytesRaw
1var pull = require('pull-stream')
2var sbot = require('./scuttlebot')
3var hyperscroll = require('hyperscroll')
4var More = require('pull-more')
5var stream = require('hyperloadmore/stream')
6var h = require('hyperscript')
7var render = require('./render')
8
9module.exports.logstream = function () {
10 var content = h('div.content')
11
12 document.body.appendChild(h('div.screen',
13 {style: {position: 'absolute', top: '0px', bottom: '0px', left: '0px', right: '0px'}},
14 hyperscroll(content)
15 ))
16
17 function createStream (opts) {
18 return pull(
19 More(sbot.createLogStream, opts),
20 pull.filter(function (data) {
21 return 'string' === typeof data.value.content.text
22 }),
23 pull.map(function (msg) {
24 return h('div.message', render(msg))
25 })
26 )
27 }
28
29 pull(
30 createStream({old: false, limit: 100}),
31 stream.top(content)
32 )
33
34 pull(
35 createStream({reverse: true, live: false, limit: 100}),
36 stream.bottom(content)
37 )
38}
39
40var rawJSON = require('patchapp-raw/json')
41
42module.exports.rawstream = function () {
43 var content = h('div.content')
44
45 document.body.appendChild(h('div.screen',
46 {style: {position: 'absolute', top: '0px', bottom: '0px', left: '0px', right: '0px'}},
47 hyperscroll(content)
48 ))
49
50 function createStream (opts) {
51 return pull(
52 More(sbot.createLogStream, opts),
53 pull.filter(function (data) {
54 return 'string' === typeof data.value.content.text
55 }),
56 pull.map(function (msg) {
57 return h('pre.raw__json', {id: msg.key}, rawJSON(msg))
58 })
59 )
60 }
61
62 pull(
63 createStream({old: false, limit: 10}),
64 stream.top(content)
65 )
66
67 pull(
68 createStream({reverse: true, live: false, limit: 10}),
69 stream.bottom(content)
70 )
71}
72

Built with git-ssb-web