git ssb

30+

cel / git-ssb-web



Commit 827415227455eb1e465c4f587a0e47bcddabd393

Show message namings in search results

Charles Lehner committed on 4/13/2016, 10:59:24 AM
Parent: bdbcf3382e534954bdeab3f996415d9bc9077a57

Files changed

index.jschanged
index.jsView
@@ -813,9 +813,9 @@
813813 feedId ? ssb.createUserStream(opts) : ssb.createFeedStream(opts),
814814 pull.filter(function (msg) {
815815 return msg.value.content.type in msgTypes
816816 }),
817- filter,
817+ typeof filter == 'function' ? filter(opts) : filter,
818818 pull.take(20),
819819 addAuthorName(about),
820820 query.forwards && pullReverse(),
821821 paginate(
@@ -892,8 +892,14 @@
892892 cb(null, '<section class="collapse">' + msgLink + '<br>' +
893893 authorLink + ' opened ' + c.type + ' ' + issueLink +
894894 ' on ' + repoLink + '</section>')
895895 })
896+ case 'about':
897+ return cb(null, '<section class="collapse">' + msgLink + '<br>' +
898+ authorLink + ' named ' + '<tt>' + escapeHTML(c.about) + '</tt> ' +
899+ link([c.about], c.name) + '</section>')
900+ default:
901+ return cb(null, json(msg))
896902 }
897903 }
898904
899905 /* Index */
@@ -1266,18 +1272,45 @@
12661272 return serveRedirect(encodeURI(qId))
12671273
12681274 var search = new RegExp(q, 'i')
12691275 return serveTemplate('git ssb search', 200, req)(
1270- renderFeed(req, null, pull.filter(function (msg) {
1271- var c = msg.value.content
1272- return (
1273- search.test(msg.key) ||
1274- c.text && search.test(c.text) ||
1275- c.title && search.test(c.title))
1276- }))
1276+ renderFeed(req, null, function (opts) {
1277+ opts.type == 'about'
1278+ return function (read) {
1279+ return pull(
1280+ many([
1281+ getRepoNames(opts),
1282+ read
1283+ ]),
1284+ pull.filter(function (msg) {
1285+ var c = msg.value.content
1286+ return (
1287+ search.test(msg.key) ||
1288+ c.text && search.test(c.text) ||
1289+ c.name && search.test(c.name) ||
1290+ c.title && search.test(c.title))
1291+ })
1292+ )
1293+ }
1294+ })
12771295 )
12781296 }
12791297
1298+ function getRepoNames(opts) {
1299+ return pull(
1300+ ssb.messagesByType({
1301+ type: 'about',
1302+ reverse: opts.reverse,
1303+ lt: opts.lt,
1304+ gt: opts.gt,
1305+ }),
1306+ pull.filter(function (msg) {
1307+ return '%' == String(msg.value.content.about)[0]
1308+ && msg.value.content.name
1309+ })
1310+ )
1311+ }
1312+
12801313 /* Repo activity */
12811314
12821315 function serveRepoActivity(repo, branch) {
12831316 return renderRepoPage(repo, 'activity', branch, cat([

Built with git-ssb-web