diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-04-27 11:18:19 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-04-27 19:38:47 -1000 |
commit | 93db24ff8b6685f236e3f13031fb23602a4ada46 (patch) | |
tree | 70393b7ed21033d86ff4f9edb471e798f61a7d5c /lib/serve.js | |
parent | 0373df4b547ca9bc2d07dab0c4d7720ee4cce69e (diff) | |
download | patchfoo-93db24ff8b6685f236e3f13031fb23602a4ada46.tar.gz patchfoo-93db24ff8b6685f236e3f13031fb23602a4ada46.zip |
Add advanced search
Diffstat (limited to 'lib/serve.js')
-rw-r--r-- | lib/serve.js | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/lib/serve.js b/lib/serve.js index 9e1cbb5..d09aa0b 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -228,6 +228,7 @@ Serve.prototype.path = function (url) { case '/public': return this.public(m[2]) case '/private': return this.private(m[2]) case '/search': return this.search(m[2]) + case '/advsearch': return this.advsearch(m[2]) case '/vote': return this.vote(m[2]) case '/peers': return this.peers(m[2]) case '/channels': return this.channels(m[2]) @@ -380,6 +381,58 @@ Serve.prototype.search = function (ext) { ) } +Serve.prototype.advsearch = function (ext) { + var self = this + var q = this.query || {} + + if (q.source) q.source = u.extractFeedIds(q.source)[0] + if (q.dest) q.dest = u.extractFeedIds(q.dest)[0] + var hasQuery = q.text || q.source || q.dest + + pull( + cat([ + ph('section', {}, [ + ph('form', {action: '', method: 'get'}, [ + ph('table', [ + ph('tr', [ + ph('td', 'text'), + ph('td', ph('input', {name: 'text', placeholder: 'regex', + class: 'id-input', + value: q.text || ''})) + ]), + ph('tr', [ + ph('td', 'author'), + ph('td', ph('input', {name: 'source', placeholder: '@id', + class: 'id-input', + value: q.source || ''})) + ]), + ph('tr', [ + ph('td', 'mentions'), + ph('td', ph('input', {name: 'dest', placeholder: 'id', + class: 'id-input', + value: q.dest || ''})) + ]), + ph('tr', [ + ph('td', {colspan: 2}, [ + ph('input', {type: 'submit', value: 'search'}) + ]) + ]), + ]) + ]) + ]), + hasQuery && pull( + self.app.advancedSearch(q), + self.renderThread(), + self.wrapMessages() + ) + ]), + self.wrapPage('advanced search'), + self.respondSink(200, { + 'Content-Type': ctype(ext), + }) + ) +} + Serve.prototype.live = function (ext) { var self = this var q = self.query @@ -908,6 +961,7 @@ Serve.prototype.wrapPage = function (title, searchQ) { h('a', {href: render.toUrl('/peers')}, 'peers') , ' ', h('a', {href: render.toUrl('/channels')}, 'channels') , ' ', h('a', {href: render.toUrl('/friends')}, 'friends'), ' ', + h('a', {href: render.toUrl('/advsearch')}, 'search'), ' ', h('a', {href: render.toUrl('/live')}, 'live'), ' ', render.idLink(self.app.sbot.id, done()), ' ', h('input.search-input', {name: 'q', value: searchQ, @@ -1272,7 +1326,7 @@ Serve.prototype.composer = function (opts, cb) { h('code', '@' + mention.name), ': ', h('input', {name: 'mention_name', type: 'hidden', value: mention.name}), - h('input.mention-id-input', {name: 'mention_id', + h('input.id-input', {name: 'mention_id', value: mention.id, placeholder: 'id'})) })) ] : '', |