git ssb

16+

Dominic / patchbay



Tree: 567b32727710add1401610208245e6950f200f06

Files: 567b32727710add1401610208245e6950f200f06 / modules / search.js

1253 bytesRaw
1var h = require('hyperscript')
2var u = require('../util')
3var pull = require('pull-stream')
4var Scroller = require('pull-scroll')
5
6var plugs = require('../plugs')
7var message_render = plugs.first(exports.message_render = [])
8var sbot_log = plugs.first(exports.sbot_log = [])
9
10function searchFilter(query) {
11 var search = new RegExp(query, 'i')
12 return function (msg) {
13 var c = msg && msg.value && msg.value.content
14 return c && (
15 msg.key == query ||
16 c.text && search.test(c.text) ||
17 c.name && search.test(c.name) ||
18 c.title && search.test(c.title))
19 }
20}
21
22exports.screen_view = function (path) {
23 if(path[0] === '?') {
24 var query = path.substr(1)
25 var matchesQuery = searchFilter(query)
26
27 var content = h('div.column.scroller__content')
28 var div = h('div.column.scroller',
29 {style: {'overflow':'auto'}},
30 h('div.scroller__wrapper',
31 content
32 )
33 )
34
35 pull(
36 sbot_log({old: false}),
37 pull.filter(matchesQuery),
38 Scroller(div, content, message_render, true, false)
39 )
40
41 pull(
42 u.next(sbot_log, {reverse: true, limit: 500, live: false}),
43 pull.filter(matchesQuery),
44 Scroller(div, content, message_render, false, false)
45 )
46
47 return div
48 }
49}
50

Built with git-ssb-web