git ssb

10+

Matt McKegg / patchwork



Commit 42148acc3cccd6630209efdf347b718e5a03cb7d

use ssb-search in patchwork

Matt McKegg committed on 4/14/2018, 10:54:23 AM
Parent: 3994612d1d69cb182c0e638c63591ead2781898b

Files changed

modules/page/html/render/search.jschanged
package.jsonchanged
server-process.jschanged
modules/page/html/render/search.jsView
@@ -3,9 +3,8 @@
33 var TextNodeSearcher = require('text-node-searcher')
44 var whitespace = /\s+/
55 var pullAbortable = require('pull-abortable')
66 var Scroller = require('../../../../lib/scroller')
7-var nextStepper = require('../../../../lib/next-stepper')
87 var nest = require('depnest')
98 var Proxy = require('mutant/proxy')
109
1110 exports.needs = nest({
@@ -21,18 +20,17 @@
2120 const i18n = api.intl.sync.i18n
2221 return nest('page.html.render', function channel (path) {
2322 if (path[0] !== '?') return
2423
25- var queryStr = path.substr(1).trim()
26- var query = queryStr.split(whitespace)
24+ var query = path.substr(1).trim()
2725 var done = Value(false)
2826 var loading = Proxy(true)
2927 var count = Value(0)
3028 var updates = Value(0)
3129 var aborter = null
3230
3331 const searchHeader = h('div', {className: 'PageHeading'}, [
34- h('h1', [h('strong', i18n('Search Results:')), ' ', query.join(' ')])
32+ h('h1', [h('strong', i18n('Search Results:')), ' ', query])
3533 ])
3634
3735 var updateLoader = h('a Notifier -loader', { href: '#', 'ev-click': refresh }, [
3836 'Show ', h('strong', [updates]), ' ', plural(updates, i18n('update'), i18n('updates'))
@@ -58,9 +56,9 @@
5856
5957 var realtimeAborter = pullAbortable()
6058
6159 pull(
62- api.sbot.pull.stream(sbot => sbot.patchwork.linearSearch({old: false, query})),
60+ api.sbot.pull.stream(sbot => sbot.patchwork.linearSearch({old: false, query: query.split(whitespace)})),
6361 realtimeAborter,
6462 pull.drain(msg => {
6563 updates.set(updates() + 1)
6664 })
@@ -102,13 +100,9 @@
102100 done.set(true)
103101 })
104102
105103 pull(
106- api.sbot.pull.stream(sbot => nextStepper(getStream, {
107- reverse: true,
108- limit: 5,
109- query
110- })),
104+ api.sbot.pull.stream(sbot => sbot.search.query({query})),
111105 pull.through(() => count.set(count() + 1)),
112106 aborter,
113107 pull.filter(msg => msg.value),
114108 scroller
@@ -118,20 +112,11 @@
118112 return !done && queue < 5
119113 }))
120114 }
121115
122- function getStream (opts) {
123- if (opts.lt != null && !opts.lt.marker) {
124- // if an lt has been specified that is not a marker, assume stream is finished
125- return pull.empty()
126- } else {
127- return api.sbot.pull.stream(sbot => sbot.patchwork.linearSearch(opts))
128- }
129- }
130-
131116 function renderMsg (msg) {
132117 var el = h('FeedEvent', api.message.html.render(msg))
133- highlight(el, createOrRegExp(query))
118+ highlight(el, createOrRegExp(query.split(whitespace)))
134119 return el
135120 }
136121 })
137122 }
package.jsonView
@@ -70,8 +70,9 @@
7070 "ssb-msgs": "^5.2.0",
7171 "ssb-private": "0.1.4",
7272 "ssb-query": "^1.0.0",
7373 "ssb-ref": "github:ssbc/ssb-ref#secret-blobs",
74+ "ssb-search": "~1.1.1",
7475 "ssb-sort": "^1.0.0",
7576 "ssb-ws": "~2.1.1",
7677 "standard": "^11.0.1",
7778 "statistics": "^3.3.0",
server-process.jsView
@@ -16,8 +16,9 @@
1616 .use(require('scuttlebot/plugins/local'))
1717 .use(require('scuttlebot/plugins/logging'))
1818 .use(require('ssb-query'))
1919 .use(require('ssb-about'))
20+ .use(require('ssb-search'))
2021 .use(require('ssb-ws'))
2122 // .use(require('ssb-ebt')) // enable at your own risk!
2223 .use(require('./sbot'))
2324

Built with git-ssb-web