Files: 5b9d7ca9bb4a61d94b54a1fc968703c840a856d9 / modules / page / html / render / all.js
1390 bytesRaw
1 | var nest = require('depnest') |
2 | var { h } = require('mutant') |
3 | var extend = require('xtend') |
4 | var pull = require('pull-stream') |
5 | |
6 | exports.needs = nest({ |
7 | 'sbot.pull.feed': 'first', |
8 | 'message.html.compose': 'first', |
9 | 'message.async.publish': 'first', |
10 | 'feed.html.rollup': 'first' |
11 | }) |
12 | |
13 | exports.gives = nest({ |
14 | 'page.html.render': true |
15 | }) |
16 | |
17 | exports.create = function (api) { |
18 | return nest('page.html.render', page) |
19 | |
20 | function page (path) { |
21 | if (path !== '/all') return // "/" is a sigil for "page" |
22 | |
23 | var prepend = [ |
24 | h('PageHeading', [ |
25 | h('h1', [ |
26 | 'All Posts from Your ', |
27 | h('strong', 'Extended Network') |
28 | ]) |
29 | ]), |
30 | api.message.html.compose({ meta: { type: 'post' }, placeholder: 'Write a public message' }) |
31 | ] |
32 | |
33 | var feedView = api.feed.html.rollup(getFeed, { |
34 | prepend, |
35 | windowSize: 1000 |
36 | }) |
37 | |
38 | var result = h('div.SplitView', [ |
39 | h('div.main', feedView) |
40 | ]) |
41 | |
42 | result.pendingUpdates = feedView.pendingUpdates |
43 | result.reload = feedView.reload |
44 | |
45 | return result |
46 | |
47 | function getFeed (opts) { |
48 | if (opts.lt) { |
49 | opts = extend(opts, {lt: parseInt(opts.lt, 10)}) |
50 | } |
51 | |
52 | return pull( |
53 | api.sbot.pull.feed(opts), |
54 | pull.map((msg) => { |
55 | if (msg.sync) return msg |
56 | return {key: msg.key, value: msg.value, timestamp: msg.value.timestamp} |
57 | }) |
58 | ) |
59 | } |
60 | } |
61 | } |
62 |
Built with git-ssb-web