git ssb

30+

cel / git-ssb-web



Commit ae7c8f32a4d51050bd9b6b9d07764f2b81665223

refactor: support git-ssb-index

noffle committed on 5/20/2018, 5:38:34 PM
Parent: 9c3452530e296365dce5b439655e7ae70f4d1f44

Files changed

index.jschanged
lib/users.jschanged
index.jsView
@@ -587,12 +587,25 @@
587587 var opts = {
588588 reverse: !query.forwards,
589589 lt: query.lt && +query.lt || Date.now(),
590590 gt: query.gt ? +query.gt : -Infinity,
591 + values: true,
591592 id: feedId
592593 }
594 +
595 + // use git index, if present
596 + var source
597 + if (this.ssb.git) {
598 + source = pull(
599 + feedId ? this.ssb.git.author(opts) : this.ssb.git.read(opts),
600 + pull.map(function (msg) { return msg.value }),
601 + )
602 + } else {
603 + source = feedId ? this.ssb.createUserStream(opts) : this.ssb.createFeedStream(opts)
604 + }
605 +
593606 return pull(
594- feedId ? this.ssb.createUserStream(opts) : this.ssb.createFeedStream(opts),
607 + source,
595608 u.decryptMessages(this.ssb),
596609 u.readableMessages(),
597610 pull.filter(function (msg) {
598611 var c = msg.value.content
lib/users.jsView
@@ -60,22 +60,41 @@
6060
6161 U.serveUserRepos = function (req, feedId) {
6262 var self = this
6363 var title = req._t('UsersRepos', {name: '%{name}'})
64- return self.renderUserPage(req, feedId, 'repos', title, pull(
65- cat([
66- self.web.ssb.messagesByType({
67- type: 'git-update',
68- reverse: true
64 +
65 + // use git index, if present
66 + var source
67 + if (self.web.ssb.git) {
68 + source = pull(
69 + self.web.ssb.git.author({
70 + lt: '9999999999999',
71 + values: true,
72 + reverse: true,
73 + id: feedId
6974 }),
70- self.web.ssb.messagesByType({
71- type: 'git-repo',
72- reverse: true
75 + pull.map(function (msg) { return msg.value }),
76 + )
77 + } else {
78 + source = pull(
79 + cat([
80 + self.web.ssb.messagesByType({
81 + type: 'git-update',
82 + reverse: true
83 + }),
84 + self.web.ssb.messagesByType({
85 + type: 'git-repo',
86 + reverse: true
87 + })
88 + ]),
89 + pull.filter(function (msg) {
90 + return msg.value.author == feedId
7391 })
74- ]),
75- pull.filter(function (msg) {
76- return msg.value.author == feedId
77- }),
92 + )
93 + }
94 +
95 + return self.renderUserPage(req, feedId, 'repos', title, pull(
96 + source,
7897 pull.unique(function (msg) {
7998 return msg.value.content.repo || msg.key
8099 }),
81100 paramap(function (msg, cb) {

Built with git-ssb-web