git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 9216a0ee5a7da1602222d794ef538ca059e1face

quick hack at better rollup of git-update messages (still not great)

Matt McKegg committed on 11/4/2016, 3:47:15 AM
Parent: fa40e97eba905e02fa26262401aa38c50f6de16b

Files changed

lib/feed-summary.jschanged
modules/message-name.jschanged
modules/message.jschanged
modules/git-mini-messages.jsadded
package.jsonchanged
styles/message.mcsschanged
styles/patchbay-tweaks.csschanged
lib/feed-summary.jsView
@@ -74,10 +74,10 @@
7474 }
7575 }
7676 }
7777 } else {
78- if (c.root) {
79- const group = ensureMessage(c.root, messageUpdates)
78+ if (c.root || (c.type === 'git-update' && c.repo)) {
79+ const group = ensureMessage(c.root || c.repo, messageUpdates)
8080 group.fromTime = fromTime
8181 group.lastUpdateType = 'reply'
8282 group.repliesFrom.add(msg.value.author)
8383 SortedArray.add(group.replies, msg, compareUserTimestamp)
modules/message-name.jsView
@@ -1,15 +1,20 @@
1+var plugs = require('patchbay/plugs')
2+var sbot_links = plugs.first(exports.sbot_links = [])
3+var get_id = plugs.first(exports.get_id = [])
4+var sbot_get = plugs.first(exports.sbot_get = [])
5+var getAvatar = require('ssb-avatar')
16
2-var sbot_get = require('patchbay/plugs').first(exports.sbot_get = [])
3-
47 exports.message_name = function (id, cb) {
58 sbot_get(id, function (err, value) {
69 if (err && err.name === 'NotFoundError') {
710 return cb(null, id.substring(0, 10) + '...(missing)')
811 } else if (value.content.type === 'post' && typeof value.content.text === 'string') {
912 if (value.content.text.trim()) {
1013 return cb(null, titleFromMarkdown(value.content.text, 40))
1114 }
15+ } else if (value.content.type === 'git-repo') {
16+ return getRepoName(id, cb)
1217 } else if (typeof value.content.text === 'string') {
1318 return cb(null, value.content.type + ': ' + titleFromMarkdown(value.content.text, 30))
1419 }
1520
@@ -26,4 +31,14 @@
2631 text = text.substring(0, max - 2) + '...'
2732 }
2833 return text
2934 }
35+
36+function getRepoName (id, cb) {
37+ getAvatar({
38+ links: sbot_links,
39+ get: sbot_get
40+ }, get_id(), id, function (err, avatar) {
41+ if (err) return cb(err)
42+ cb(null, avatar.name)
43+ })
44+}
modules/message.jsView
@@ -33,13 +33,13 @@
3333 var div = h('Message', {
3434 'ev-contextmenu': contextMenu.bind(null, msg)
3535 }, [
3636 h('header', [
37- h('div', [
37+ h('div.mini', [
3838 avatar_link(msg.value.author, avatar_name(msg.value.author), ''),
3939 ' ', elMini
4040 ]),
41- h('div.message_meta.row', [message_meta(msg)])
41+ h('div.meta', [message_main_meta(msg)])
4242 ])
4343 ])
4444 div.setAttribute('tabindex', '0')
4545 return div
modules/git-mini-messages.jsView
@@ -1,0 +1,22 @@
1+var h = require('../lib/h')
2+var when = require('@mmckegg/mutant/when')
3+var plugs = require('patchbay/plugs')
4+var message_link = plugs.first(exports.message_link = [])
5+
6+exports.message_content = exports.message_content_mini = function (msg, sbot) {
7+ if (msg.value.content.type === 'git-update') {
8+ var commits = msg.value.content.commits || []
9+ return [
10+ h('a', {href: `#${msg.key}`}, [
11+ 'pushed',
12+ when(commits, [' ', pluralizeCommits(commits)])
13+ ]),
14+ ' to ',
15+ message_link(msg.value.content.repo)
16+ ]
17+ }
18+}
19+
20+function pluralizeCommits (commits) {
21+ return when(commits.length === 1, '1 commit', `${commits.length} commits`)
22+}
package.jsonView
@@ -38,8 +38,9 @@
3838 "pull-pushable": "^2.0.1",
3939 "pull-stream": "~3.4.5",
4040 "scuttlebot": "~9.2.0",
4141 "sorted-array-functions": "~1.0.0",
42+ "ssb-avatar": "^0.2.0",
4243 "ssb-blobs": "~0.1.7",
4344 "ssb-keys": "~7.0.0",
4445 "ssb-links": "~2.0.0",
4546 "ssb-query": "~0.1.1",
styles/message.mcssView
@@ -44,8 +44,12 @@
4444 header {
4545 margin: 15px 15px
4646 display: flex
4747
48+ div.mini {
49+ flex: 1
50+ }
51+
4852 div.main {
4953 display: flex
5054 flex: 1
5155
styles/patchbay-tweaks.cssView
@@ -10,8 +10,9 @@
1010
1111 a.avatar {
1212 display: inline;
1313 font-weight: bold;
14+ color: #222
1415 }
1516
1617 div.avatar > a.avatar {
1718 display: flex;

Built with git-ssb-web