git ssb

16+

Dominic / patchbay



Commit 4f3054d52e3dd8118e872578e5b857dcdad40d59

fix backlink rendering

Michael Williams authored on 12/28/2016, 9:57:57 AM
mix irving committed on 12/30/2016, 9:55:59 PM
Parent: 787f858837541c7b94531c9b98603402cfb7f06b

Files changed

modules_basic/message-backlinks.jschanged
modules_basic/message.jschanged
modules_basic/message-backlinks.mcssadded
modules_basic/message-backlinks.jsView
@@ -1,8 +1,20 @@
1-exports.gives = 'message_backlinks'
1 +var fs = require('fs')
2 +var Path = require('path')
3 +var h = require('../h')
24
5 +exports.gives = {
6 + message_backlinks: true,
7 + mcss: true
8 +}
9 +
310 exports.create = function (api) {
4- return function (msg) {
11 + return {
12 + message_backlinks,
13 + mcss: () => fs.readFileSync(Path.join(__dirname, 'message-backlinks.mcss'))
14 + }
15 +
16 + function message_backlinks (msg) {
517 var links = []
618 for(var k in CACHE) {
719 var _msg = CACHE[k]
820 if(Array.isArray(_msg.content.mentions)) {
@@ -10,7 +22,19 @@
1022 if(_msg.content.mentions[i].link == msg.key)
1123 links.push(k)
1224 }
1325 }
14- return links
26 +
27 + if (links.length === 0) return null
28 +
29 + return h('MessageBacklinks', [
30 + h('header', 'backlinks:'),
31 + h('ul', links.map(function (link) {
32 + return h('li', [
33 + h('a -backlink', {
34 + href: `#${link}`
35 + }, link)
36 + ])
37 + }))
38 + ])
1539 }
1640 }
modules_basic/message.jsView
@@ -6,16 +6,15 @@
66
77 exports.needs = {
88 avatar_name: 'first',
99 avatar_link: 'first',
10- message_meta: 'map',
1110 message_action: 'map',
12- message_link: 'first',
11 + message_author: 'first',
1312 message_backlinks: 'first',
14- message_author: 'first',
1513 message_content: 'first',
1614 message_content_mini: 'first',
17- message_footer: 'first'
15 + message_link: 'first',
16 + message_meta: 'map',
1817 }
1918
2019 exports.gives = {
2120 message_render: true,
modules_basic/message-backlinks.mcssView
@@ -1,0 +1,14 @@
1 +MessageBacklinks {
2 + header {
3 +
4 + }
5 + ul {
6 + li {
7 + a {
8 + -backlink {
9 +
10 + }
11 + }
12 + }
13 + }
14 +}

Built with git-ssb-web