Commit ff143e8934ce10479fb7f2a1a8a3b5eaea7447cd
make a stab at hashtag search
Ev Bogue committed on 7/28/2018, 1:22:21 AMParent: 7e5eace0de85841889751468a862dd2c55f447bc
Files changed
index.js | changed |
tools.js | changed |
views.js | changed |
index.js | ||
---|---|---|
@@ -54,9 +54,12 @@ | ||
54 | 54 | h('li', h('a', {href: '#key' }, 'Key')), |
55 | 55 | h('li.right', h('a', {href: '#about'}, '?')), |
56 | 56 | h('form.search', { |
57 | 57 | onsubmit: function (e) { |
58 | - window.location.hash = '?' + search.value | |
58 | + if (search.value[0] == '#') | |
59 | + window.location.hash = '#' + search.value | |
60 | + else | |
61 | + window.location.hash = '?' + search.value | |
59 | 62 | e.preventDefault() |
60 | 63 | }}, |
61 | 64 | search |
62 | 65 | ) |
tools.js | ||
---|---|---|
@@ -388,9 +388,9 @@ | ||
388 | 388 | var config = require('./config')() |
389 | 389 | |
390 | 390 | module.exports.markdown = function (msg, md) { |
391 | 391 | return {innerHTML: markdown.block(msg, {toUrl: function (url, image) { |
392 | - if(url[0] == '%' || url[0] == '@') return '#' + url | |
392 | + if(url[0] == '%' || url[0] == '@' || url[0] == '#') return '#' + url | |
393 | 393 | if(!image) return url |
394 | 394 | if(url[0] !== '&') return url |
395 | 395 | return config.blobsUrl + url |
396 | 396 | }})} |
views.js | ||
---|---|---|
@@ -472,19 +472,20 @@ | ||
472 | 472 | } |
473 | 473 | |
474 | 474 | function search (src) { |
475 | 475 | console.log('search' + src) |
476 | - | |
476 | + | |
477 | 477 | var content = h('div.content') |
478 | 478 | var screen = document.getElementById('screen') |
479 | 479 | screen.appendChild(hyperscroll(content)) |
480 | - | |
480 | + | |
481 | 481 | pull( |
482 | - sbot.search.query({query: src}), | |
482 | + sbot.search.query({query: src, limit: 100}), | |
483 | 483 | pull.drain(function (search) { |
484 | 484 | content.appendChild(render(search)) |
485 | 485 | }) |
486 | 486 | ) |
487 | + | |
487 | 488 | } |
488 | 489 | |
489 | 490 | function hash () { |
490 | 491 | return window.location.hash.substring(1) |
@@ -506,11 +507,13 @@ | ||
506 | 507 | } else if (src == 'private') { |
507 | 508 | privateStream() |
508 | 509 | } else if (src == 'key') { |
509 | 510 | keyPage() |
510 | - } else if (src[0] == '?') { | |
511 | - search(src.substr(1).split('%20').join(' ')) | |
512 | - //search(src.substring(1, 1000)) | |
511 | + } else if (src[0] == '?' || (src[0] == '#')) { | |
512 | + if (src[0] == '#') | |
513 | + search(src.split('%20').join(' ')) | |
514 | + else | |
515 | + search(src.substr(1).split('%20').join(' ')) | |
513 | 516 | } else { |
514 | 517 | everythingStream() |
515 | 518 | checkInvite() |
516 | 519 | } |
Built with git-ssb-web