git ssb

30+

cel / git-ssb-web



Commit 51231092e514abc2c2cf7af606e1bf4e510f7f75

Handle hashtag/channel repos

cel committed on 9/20/2017, 7:40:02 AM
Parent: 83af49c5eefe3d3bdb488ab8c469ab4299563bb4

Files changed

index.jschanged
lib/about.jschanged
lib/repos/index.jschanged
lib/votes.jschanged
package.jsonchanged
index.jsView
@@ -110,11 +110,12 @@
110110 this.pullReqs = PullRequests.init(ssb)
111111 this.getRepo = asyncMemo({
112112 cache: new LRUCache(32)
113113 }, function (id, cb) {
114 + if (id[0] === '#') return ssbGit.getRepo(ssb, id, {live: true}, cb)
114115 this.getMsg(id, function (err, msg) {
116 + if (err) return cb(err)
115117 if (msg.private && this.isPublic) return cb(new Error('Private Repo'))
116- if (err) return cb(err)
117118 ssbGit.getRepo(ssb, msg, {live: true}, cb)
118119 })
119120 })
120121
@@ -163,8 +164,10 @@
163164 }.bind(this))
164165 }
165166
166167 G.getRepoName = function (ownerId, repoId, cb) {
168 + if (!repoId) return cb(null, '?')
169 + if (repoId[0] === '#') return cb(null, repoId)
167170 this.about.getName({
168171 owner: ownerId,
169172 target: repoId
170173 }, cb)
@@ -238,8 +241,10 @@
238241 if (dir == '')
239242 return this.serveIndex(req)
240243 else if (dir == 'search')
241244 return this.serveSearch(req)
245 + else if (dir[0] === '#')
246 + return this.serveChannel(req, dir, dirs.slice(1))
242247 else if (ref.isBlobId(dir))
243248 return this.serveBlob(req, dir)
244249 else if (ref.isMsgId(dir))
245250 return this.serveMessage(req, dir, dirs.slice(1))
@@ -625,8 +630,9 @@
625630 })
626631 case 'issue':
627632 case 'pull-request':
628633 var issueLink = u.link([msg.key], u.messageTitle(msg))
634 + // TODO: handle hashtag in project property
629635 return self.getMsg(c.project, function (err, projectMsg) {
630636 if (err) return cb(null,
631637 self.repos.serveRepoNotFound(req, c.repo, err))
632638 self.getRepoName(projectMsg.value.author, c.project,
@@ -676,9 +682,17 @@
676682 G.serveIndex = function (req) {
677683 return this.serveTemplate(req)(this.renderFeed(req))
678684 }
679685
680-/* Message */
686 +G.serveChannel = function (req, id, path) {
687 + var self = this
688 + return u.readNext(function (cb) {
689 + self.getRepo(id, function (err, repo) {
690 + if (err) return cb(null, self.serveError(req, err))
691 + cb(null, self.repos.serveRepoPage(req, GitRepo(repo), path))
692 + })
693 + })
694 +}
681695
682696 G.serveMessage = function (req, id, path) {
683697 var self = this
684698 return u.readNext(function (cb) {
lib/about.jsView
@@ -42,9 +42,19 @@
4242 })
4343 })
4444 }
4545 pull(
46- sbot.links({
46 + sbot.backlinks ? sbot.backlinks.read({
47 + reverse: true,
48 + query: [{$filter: {
49 + dest: id,
50 + value: {
51 + content: {
52 + type: 'about'
53 + }
54 + }
55 + }}]
56 + }) : sbot.links({
4757 rel: 'about',
4858 values: true,
4959 dest: id
5060 }),
@@ -86,8 +96,9 @@
8696 }
8797
8898 function getAbout(dest, cb) {
8999 if (!dest) return cb(null, {})
100 + if (dest[0] === '#') return cb(null, {name: dest})
90101 var target = dest.target || dest
91102 getAboutInfo(target, function (err, info) {
92103 if (err) return cb(err)
93104 // order of preference: source, owner, any, msg
lib/repos/index.jsView
@@ -154,9 +154,9 @@
154154 R.serveRepoNotFound = function (req, id, err) {
155155 return this.web.serveTemplate(req, req._t('error.RepoNotFound'), 404)
156156 (pull.values([
157157 '<h2>' + req._t('error.RepoNotFound') + '</h2>',
158- '<p>' + req._t('error.RepoNameNotFound') + '</p>',
158 + '<p>' + req._t('error.RepoIdNotFound', id) + '</p>',
159159 '<pre>' + u.escape(err.stack) + '</pre>'
160160 ]))
161161 }
162162
@@ -204,9 +204,9 @@
204204 u.link([repo.upstream])
205205 var title = titleTemplate ? titleTemplate
206206 .replace(/%\{repo\}/g, repoName)
207207 .replace(/%\{author\}/g, authorName)
208- : authorName + '/' + repoName
208 + : (authorName ? authorName + '/' : '') + repoName
209209 var isPublic = self.web.isPublic
210210 var isLocal = !isPublic
211211 cb(null, self.web.serveTemplate(req, title)(cat([
212212 h('div', {class: 'repo-title'}, [
@@ -233,9 +233,12 @@
233233 ])
234234 )
235235 ]),
236236 forms.name(req, isLocal, repo.id, repoName, 'repo-name', null, req._t('repo.Rename'),
237- h('h2', {class: 'bgslash'}, `${u.link([repo.feed], authorName)} / ${u.link([repo.id], repoName)}${repo.private ? ' ' + u.privateIcon(req) : ''}`)
237 + h('h2', {class: 'bgslash'},
238 + (authorName ? u.link([repo.feed], authorName) + ' / ' : '') +
239 + u.link([repo.id], repoName) +
240 + (repo.private ? ' ' + u.privateIcon(req) : ''))
238241 ),
239242 ]),
240243 u.when(repo.upstream, () =>
241244 h('small', {class: 'bgslash'}, req._t('ForkedFrom', {
lib/votes.jsView
@@ -22,9 +22,19 @@
2222 downvotes: 0
2323 }
2424
2525 pull(
26- sbot.links({dest: id, rel: 'vote', values: true}),
26 + sbot.backlinks ? sbot.backlinks.read({
27 + reverse: true,
28 + query: [{$filter: {
29 + dest: id,
30 + value: {
31 + content: {
32 + type: 'vote'
33 + }
34 + }
35 + }}]
36 + }) : sbot.links({dest: id, rel: 'vote', values: true}),
2737 u.decryptMessages(sbot),
2838 u.readableMessages(),
2939 pull.drain(processMsg, function (err) {
3040 cb(err, result)
package.jsonView
@@ -14,9 +14,9 @@
1414 "multicb": "^1.2.1",
1515 "node-polyglot": "^1.0.0",
1616 "pull-cat": "^1.1.11",
1717 "pull-git-pack": "^1.0.1",
18- "pull-git-repo": "^1.2.1",
18 + "pull-git-repo": "^1.3.0",
1919 "pull-hyperscript": "^0.2.2",
2020 "pull-identify-filetype": "^1.1.0",
2121 "pull-many": "^1.0.8",
2222 "pull-paginate": "^1.0.0",
@@ -24,9 +24,9 @@
2424 "pull-stream": "^3.5.0",
2525 "remove-markdown": "^0.1.0",
2626 "ssb-client": "^4.2.1",
2727 "ssb-config": "^2.2.0",
28- "ssb-git-repo": "^2.6.0",
28 + "ssb-git-repo": "^2.9.2",
2929 "ssb-issues": "^1.0.0",
3030 "ssb-keys": "^7.0.3",
3131 "ssb-marked": "^0.6.0",
3232 "ssb-mentions": "^0.1.0",

Built with git-ssb-web