git ssb

10+

Matt McKegg / patchwork



Commit ead5d15c75ce6e84eb01e6e0f16ba10e3552d905

add "All Posts" view (via /all search)

#444
closes #517
Matt McKegg committed on 4/23/2017, 1:01:49 AM
Parent: 54d70439428e8fd11338aa37918eeab2dbd9f31a

Files changed

modules/page/html/render/all.jsadded
modules/page/html/render/all.jsView
@@ -1,0 +1,61 @@
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 +}

Built with git-ssb-web