Commit d67a3e9888a624e96041acdeadb0ae5e15e7a055
add search route at /#?
Ev Bogue committed on 7/10/2018, 3:23:56 AMParent: a3c2d0291e363d728b025f52bfc0e5edc54ee3de
Files changed
bin.js | changed |
manifest.json | changed |
package-lock.json | changed |
package.json | changed |
scuttlebot.js | changed |
views.js | changed |
bin.js | ||
---|---|---|
@@ -38,8 +38,9 @@ | ||
38 | 38 … | .use(require('ssb-backlinks')) |
39 | 39 … | .use(require('./query')) |
40 | 40 … | .use(require('ssb-links')) |
41 | 41 … | .use(require('ssb-ebt')) |
42 … | + .use(require('ssb-search')) | |
42 | 43 … | .use(require('scuttlebot/plugins/invite')) |
43 | 44 … | .use(require('scuttlebot/plugins/local')) |
44 | 45 … | .use(require('decent-ws')) |
45 | 46 … | .use({ |
manifest.json | ||
---|---|---|
@@ -79,8 +79,8 @@ | ||
79 | 79 … | "read": "source", |
80 | 80 … | "dump": "source" |
81 | 81 … | }, |
82 | 82 … | "ws": {}, |
83 | - "fulltext": { | |
84 | - "search": "source" | |
83 … | + "search": { | |
84 … | + "query": "source" | |
85 | 85 … | } |
86 | 86 … | } |
package-lock.json | ||
---|---|---|
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.json | ||
---|---|---|
@@ -51,8 +51,9 @@ | ||
51 | 51 … | "ssb-links": "^3.0.3", |
52 | 52 … | "ssb-markdown": "^3.6.0", |
53 | 53 … | "ssb-mentions": "^0.5.0", |
54 | 54 … | "ssb-ref": "^2.11.1", |
55 … | + "ssb-search": "^1.0.1", | |
55 | 56 … | "visualize-buffer": "0.0.1", |
56 | 57 … | "yargs": "^11.0.0" |
57 | 58 … | } |
58 | 59 … | } |
scuttlebot.js | |||
---|---|---|---|
@@ -90,8 +90,13 @@ | |||
90 | 90 … | get: rec.async(function (opts, cb) { | |
91 | 91 … | sbot.friends.get(opts, cb) | |
92 | 92 … | }) | |
93 | 93 … | }, | |
94 … | + search: { | ||
95 … | + query: rec.source(function (opts) { | ||
96 … | + return sbot.search.query(opts) | ||
97 … | + }) | ||
98 … | + }, | ||
94 | 99 … | publish: rec.async(function (content, cb) { | |
95 | 100 … | if(content.recps) | |
96 | 101 … | content = ssbKeys.box(content, content.recps.map(function (e) { | |
97 | 102 … | return ref.isFeed(e) ? e : e.link | |
views.js | ||
---|---|---|
@@ -466,16 +466,30 @@ | ||
466 | 466 … | stream.top(content) |
467 | 467 … | ) |
468 | 468 … | } |
469 | 469 … | |
470 … | +function search (src) { | |
471 … | + console.log('search' + src) | |
470 | 472 … | |
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 … | + | |
471 | 485 … | function hash () { |
472 | 486 … | return window.location.hash.substring(1) |
473 | 487 … | } |
474 | 488 … | |
475 | 489 … | module.exports = function () { |
476 | 490 … | var src = hash() |
477 | - | |
491 … | + console.log(src) | |
478 | 492 … | if (ref.isFeed(src)) { |
479 | 493 … | userStream(src) |
480 | 494 … | } else if (ref.isMsg(src)) { |
481 | 495 … | msgThread(src) |
@@ -488,8 +502,11 @@ | ||
488 | 502 … | } else if (src == 'private') { |
489 | 503 … | privateStream() |
490 | 504 … | } else if (src == 'key') { |
491 | 505 … | keyPage() |
506 … | + } else if (src[0] == '?') { | |
507 … | + search(src.substr(1).split('%20').join(' ')) | |
508 … | + //search(src.substring(1, 1000)) | |
492 | 509 … | } else { |
493 | 510 … | everythingStream() |
494 | 511 … | checkInvite() |
495 | 512 … | } |
Built with git-ssb-web