Files: 41ed6a5aa572f6de601bab35fc108a955657c074 / modules_basic / message-backlinks.js
861 bytesRaw
1 | const fs = require('fs') |
2 | const h = require('../h') |
3 | |
4 | exports.gives = { |
5 | message_backlinks: true, |
6 | mcss: true |
7 | } |
8 | |
9 | exports.create = function (api) { |
10 | return { |
11 | message_backlinks, |
12 | mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8') |
13 | } |
14 | |
15 | function message_backlinks (msg) { |
16 | var links = [] |
17 | for(var k in CACHE) { |
18 | var _msg = CACHE[k] |
19 | if(Array.isArray(_msg.content.mentions)) { |
20 | for(var i = 0; i < _msg.content.mentions.length; i++) |
21 | if(_msg.content.mentions[i].link == msg.key) |
22 | links.push(k) |
23 | } |
24 | } |
25 | |
26 | if (links.length === 0) return null |
27 | |
28 | return h('MessageBacklinks', [ |
29 | h('header', 'backlinks:'), |
30 | h('ul', links.map(function (link) { |
31 | return h('li', [ |
32 | h('a -backlink', { |
33 | href: `#${link}` |
34 | }, link) |
35 | ]) |
36 | })) |
37 | ]) |
38 | } |
39 | } |
40 |
Built with git-ssb-web