git ssb

10+

Matt McKegg / patchwork



Commit 1b66c47afdef9e153462cf94ef615c9b15f47c84

display backlinks on threads

Matt McKegg committed on 2/17/2017, 4:02:17 PM
Parent: 0226ff61f37fc9d4a090da891284f7e6fa9646cc

Files changed

modules/page/html/render/message.jschanged
plugs/message/html/layout/default.jschanged
styles/message.mcsschanged
modules/page/html/render/message.jsView
@@ -56,9 +56,9 @@
5656 var container = h('Thread', [
5757 when(thread.branchId, h('a.full', {href: thread.rootId}, ['View full thread'])),
5858 map(thread.messages, (msg) => {
5959 return computed([msg, thread.previousKey(msg)], (msg, previousId) => {
60- return api.message.html.render(msg, {previousId})
60 + return api.message.html.render(msg, {previousId, backlinks: true})
6161 })
6262 }),
6363 compose
6464 ])
plugs/message/html/layout/default.jsView
@@ -1,9 +1,11 @@
1-const { when, h } = require('mutant')
1 +const { when, h, map } = require('mutant')
22 var nest = require('depnest')
33
44 exports.needs = nest({
55 'profile.html.person': 'first',
6 + 'message.obs.backlinks': 'first',
7 + 'message.obs.name': 'first',
68 'message.html': {
79 link: 'first',
810 meta: 'map',
911 action: 'map',
@@ -19,8 +21,9 @@
1921
2022 function layout (msg, opts) {
2123 if (!(opts.layout === undefined || opts.layout === 'default')) return
2224
25 + var backlinks = opts.backlinks ? api.message.obs.backlinks(msg.key) : []
2326 var classList = ['Message']
2427 var replyInfo = null
2528
2629 if (msg.value.content.root) {
@@ -37,8 +40,16 @@
3740 classList
3841 }, [
3942 messageHeader(msg, replyInfo),
4043 h('section', [opts.content]),
44 + map(backlinks, backlink => {
45 + return h('a.backlink', {
46 + href: backlink,
47 + title: backlink
48 + }, [
49 + h('strong', 'Referenced from'), ' ', api.message.obs.name(backlink)
50 + ])
51 + }),
4152 when(msg.key, h('footer', [
4253 h('div.actions', [
4354 api.message.html.action(msg)
4455 ])
styles/message.mcssView
@@ -141,8 +141,25 @@
141141 max-width: 100%
142142 }
143143 }
144144
145 + a.backlink {
146 + display: block;
147 + border-top: 1px solid #d1d0d0;
148 + margin: 0 -1px;
149 + padding: 10px 15px;
150 + background: #e8e6e6;
151 + border-bottom: 1px solid #d1d0d0;
152 + color: #8f8f8f;
153 + margin-top: -1px;
154 + font-size: 9pt;
155 +
156 + :hover {
157 + text-decoration: none
158 + color: #777
159 + }
160 + }
161 +
145162 footer {
146163 background: #fdfdfd
147164 padding: 15px 15px
148165 text-align: right

Built with git-ssb-web