git ssb

10+

Matt McKegg / patchwork



Commit c2d8083ad55e777a6e7b82aaa57f2aaa27f5a607

show thread forks and authors of message backlinks

Matt McKegg committed on 6/2/2017, 7:28:19 AM
Parent: 47128cd0a170a7691269a44d297af30a324c3a4a

Files changed

modules/page/html/render/message.jschanged
package.jsonchanged
plugs/message/html/layout/default.jschanged
styles/message.mcsschanged
modules/page/html/render/message.jsView
@@ -15,9 +15,9 @@
1515
1616 exports.gives = nest('page.html.render')
1717
1818 exports.create = function (api) {
19- return nest('page.html.render', function channel (id) {
19 + return nest('page.html.render', function (id) {
2020 if (!ref.isMsg(id)) return
2121 var loader = h('div', {className: 'Loading -large'})
2222
2323 var result = Proxy(loader)
@@ -49,9 +49,9 @@
4949 var isReply = !!value.content.root
5050 var thread = api.feed.obs.thread(id, {branch: isReply})
5151
5252 meta.channel.set(value.content.channel)
53- meta.root.set(thread.rootId)
53 + meta.root.set(value.content.root || thread.rootId)
5454
5555 // if root thread, reply to last post
5656 meta.branch.set(isReply ? thread.branchId : thread.lastId)
5757
package.jsonView
@@ -37,9 +37,9 @@
3737 "mutant-pull-reduce": "^1.1.0",
3838 "non-private-ip": "^1.4.1",
3939 "on-change-network": "0.0.2",
4040 "on-wakeup": "^1.0.1",
41- "patchcore": "~0.5.2",
41 + "patchcore": "~0.6.0",
4242 "patchwork-gatherings": "^1.0.2",
4343 "pull-abortable": "^4.1.0",
4444 "pull-defer": "^0.2.2",
4545 "pull-file": "~1.0.0",
plugs/message/html/layout/default.jsView
@@ -1,12 +1,14 @@
1-const { when, h, map, computed } = require('mutant')
1 +const { h, map, computed } = require('mutant')
22 var nest = require('depnest')
33 var ref = require('ssb-ref')
44
55 exports.needs = nest({
66 'profile.html.person': 'first',
77 'message.obs.backlinks': 'first',
88 'message.obs.name': 'first',
9 + 'message.obs.forks': 'first',
10 + 'message.obs.author': 'first',
911 'message.html': {
1012 link: 'first',
1113 meta: 'map',
1214 action: 'map',
@@ -23,8 +25,10 @@
2325 function layout (msg, opts) {
2426 if (!(opts.layout === undefined || opts.layout === 'default')) return
2527
2628 var backlinks = opts.backlinks ? api.message.obs.backlinks(msg.key) : []
29 + var forks = msg.value.content.root ? api.message.obs.forks(msg.key) : []
30 +
2731 var classList = ['Message']
2832 var replyInfo = null
2933
3034 if (msg.value.content.root) {
@@ -59,15 +63,29 @@
5963 ])
6064 ])
6165 }
6266 }),
63- map(backlinks, backlink => {
67 + map(forks, msgId => {
6468 return h('a.backlink', {
65- href: backlink,
66- title: backlink
69 + href: msgId,
70 + title: msgId
6771 }, [
68- h('strong', 'Referenced from'), ' ', api.message.obs.name(backlink)
72 + h('strong', [
73 + authorLink(msgId), ' forked this discussion:'
74 + ]), ' ',
75 + api.message.obs.name(msgId)
6976 ])
77 + }),
78 + map(backlinks, msgId => {
79 + return h('a.backlink', {
80 + href: msgId,
81 + title: msgId
82 + }, [
83 + h('strong', [
84 + authorLink(msgId), ' referenced this message:'
85 + ]), ' ',
86 + api.message.obs.name(msgId)
87 + ])
7088 })
7189 ])
7290
7391 // scoped
@@ -97,8 +115,19 @@
97115 additionalMeta
98116 ])
99117 ])
100118 }
119 +
120 + function authorLink (msgId) {
121 + var author = api.message.obs.author(msgId)
122 + return computed(author, author => {
123 + if (author) {
124 + return api.profile.html.person(author)
125 + } else {
126 + return 'Someone'
127 + }
128 + })
129 + }
101130 }
102131 }
103132
104133 function last (array) {
styles/message.mcssView
@@ -192,13 +192,11 @@
192192 }
193193
194194 a.backlink {
195195 display: block;
196- border-top: 1px solid #e2e0e0;
197- margin: 0 -1px;
196 + border-top: 1px solid #EEE;
198197 padding: 10px 15px;
199- background: #f3f2f2;
200- border-bottom: 1px solid #d1d0d0;
198 + background: #ffffff;
201199 color: #8f8f8f;
202200 margin-top: -1px;
203201 font-size: 9pt;
204202

Built with git-ssb-web