Commit 827415227455eb1e465c4f587a0e47bcddabd393
Show message namings in search results
Charles Lehner committed on 4/13/2016, 10:59:24 AMParent: bdbcf3382e534954bdeab3f996415d9bc9077a57
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -813,9 +813,9 @@ | ||
813 | 813 | feedId ? ssb.createUserStream(opts) : ssb.createFeedStream(opts), |
814 | 814 | pull.filter(function (msg) { |
815 | 815 | return msg.value.content.type in msgTypes |
816 | 816 | }), |
817 | - filter, | |
817 | + typeof filter == 'function' ? filter(opts) : filter, | |
818 | 818 | pull.take(20), |
819 | 819 | addAuthorName(about), |
820 | 820 | query.forwards && pullReverse(), |
821 | 821 | paginate( |
@@ -892,8 +892,14 @@ | ||
892 | 892 | cb(null, '<section class="collapse">' + msgLink + '<br>' + |
893 | 893 | authorLink + ' opened ' + c.type + ' ' + issueLink + |
894 | 894 | ' on ' + repoLink + '</section>') |
895 | 895 | }) |
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)) | |
896 | 902 | } |
897 | 903 | } |
898 | 904 | |
899 | 905 | /* Index */ |
@@ -1266,18 +1272,45 @@ | ||
1266 | 1272 | return serveRedirect(encodeURI(qId)) |
1267 | 1273 | |
1268 | 1274 | var search = new RegExp(q, 'i') |
1269 | 1275 | 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 | + }) | |
1277 | 1295 | ) |
1278 | 1296 | } |
1279 | 1297 | |
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 | + | |
1280 | 1313 | /* Repo activity */ |
1281 | 1314 | |
1282 | 1315 | function serveRepoActivity(repo, branch) { |
1283 | 1316 | return renderRepoPage(repo, 'activity', branch, cat([ |
Built with git-ssb-web