Files: 05eef0d0f21b9e30181ff79499082aeb99b76e8a / views.js
1743 bytesRaw
1 | var pull = require('pull-stream') |
2 | var sbot = require('./scuttlebot') |
3 | var hyperscroll = require('hyperscroll') |
4 | var More = require('pull-more') |
5 | var stream = require('hyperloadmore/stream') |
6 | var h = require('hyperscript') |
7 | var render = require('./render') |
8 | |
9 | module.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 | |
40 | var rawJSON = require('patchapp-raw/json') |
41 | |
42 | module.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