git ssb

2+

ev / mvd



Commit d67a3e9888a624e96041acdeadb0ae5e15e7a055

add search route at /#?

Ev Bogue committed on 7/10/2018, 3:23:56 AM
Parent: a3c2d0291e363d728b025f52bfc0e5edc54ee3de

Files changed

bin.jschanged
manifest.jsonchanged
package-lock.jsonchanged
package.jsonchanged
scuttlebot.jschanged
views.jschanged
bin.jsView
@@ -38,8 +38,9 @@
3838 .use(require('ssb-backlinks'))
3939 .use(require('./query'))
4040 .use(require('ssb-links'))
4141 .use(require('ssb-ebt'))
42 + .use(require('ssb-search'))
4243 .use(require('scuttlebot/plugins/invite'))
4344 .use(require('scuttlebot/plugins/local'))
4445 .use(require('decent-ws'))
4546 .use({
manifest.jsonView
@@ -79,8 +79,8 @@
7979 "read": "source",
8080 "dump": "source"
8181 },
8282 "ws": {},
83- "fulltext": {
84- "search": "source"
83 + "search": {
84 + "query": "source"
8585 }
8686 }
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 205908 bytes
New file size: 212894 bytes
package.jsonView
@@ -51,8 +51,9 @@
5151 "ssb-links": "^3.0.3",
5252 "ssb-markdown": "^3.6.0",
5353 "ssb-mentions": "^0.5.0",
5454 "ssb-ref": "^2.11.1",
55 + "ssb-search": "^1.0.1",
5556 "visualize-buffer": "0.0.1",
5657 "yargs": "^11.0.0"
5758 }
5859 }
scuttlebot.jsView
@@ -90,8 +90,13 @@
9090 get: rec.async(function (opts, cb) {
9191 sbot.friends.get(opts, cb)
9292 })
9393 },
94 + search: {
95 + query: rec.source(function (opts) {
96 + return sbot.search.query(opts)
97 + })
98 + },
9499 publish: rec.async(function (content, cb) {
95100 if(content.recps)
96101 content = ssbKeys.box(content, content.recps.map(function (e) {
97102 return ref.isFeed(e) ? e : e.link
views.jsView
@@ -466,16 +466,30 @@
466466 stream.top(content)
467467 )
468468 }
469469
470 +function search (src) {
471 + console.log('search' + src)
470472
473 + var content = h('div.content')
474 + var screen = document.getElementById('screen')
475 + screen.appendChild(hyperscroll(content))
476 +
477 + pull(
478 + sbot.search.query({query: src}),
479 + pull.drain(function (search) {
480 + content.appendChild(render(search))
481 + })
482 + )
483 +}
484 +
471485 function hash () {
472486 return window.location.hash.substring(1)
473487 }
474488
475489 module.exports = function () {
476490 var src = hash()
477-
491 + console.log(src)
478492 if (ref.isFeed(src)) {
479493 userStream(src)
480494 } else if (ref.isMsg(src)) {
481495 msgThread(src)
@@ -488,8 +502,11 @@
488502 } else if (src == 'private') {
489503 privateStream()
490504 } else if (src == 'key') {
491505 keyPage()
506 + } else if (src[0] == '?') {
507 + search(src.substr(1).split('%20').join(' '))
508 + //search(src.substring(1, 1000))
492509 } else {
493510 everythingStream()
494511 checkInvite()
495512 }

Built with git-ssb-web