git ssb

7+

dinoworm 🐛 / patchcore



Commit 69a54fb3197c0348818b22c6ba647e80302543de

Modules that give message.html.render also give message.html.canRender to discover if the client knows how to render a message type.

Gordon Martin committed on 10/15/2017, 10:56:59 PM
Parent: 57aa3f77facebb4078929bc790e72f2ab3ae79fb

Files changed

message/html/render/channel.jschanged
message/html/render/issue.jschanged
message/html/render/post.jschanged
message/html/render/vote.jschanged
package-lock.jsonchanged
package.jsonchanged
message/html/render/channel.jsView
@@ -10,26 +10,42 @@
1010 markdown: 'first'
1111 }
1212 })
1313
14-exports.gives = nest('message.html.render')
14 +exports.gives = nest({
15 + 'message.html': {
16 + canRender: true,
17 + render: true
18 + }
19 +})
1520
16-exports.create = function (api) {
17- return nest('message.html.render', channel)
21 +exports.create = function(api) {
22 + return nest('message.html', {
23 + canRender: isRenderable,
24 + render: channel
25 + })
1826
19- function channel (msg, opts) {
20- if (msg.value.content.type !== 'channel') return
27 + function channel(msg, opts) {
28 + if (!isRenderable(msg)) return
2129 var element = api.message.html.layout(msg, extend({
2230 content: renderContent(msg),
2331 layout: 'mini'
2432 }, opts))
2533
26- return api.message.html.decorate(element, { msg })
34 + return api.message.html.decorate(element, {
35 + msg
36 + })
2737 }
2838
29- function renderContent (msg) {
39 + function renderContent(msg) {
3040 var channel = '#' + msg.value.content.channel
3141 return [
32- msg.value.content.subscribed ? 'subscribed to channel' : 'unsubscribed from channel', ' ', h('a.channel', {href: channel}, channel)
42 + msg.value.content.subscribed ? 'subscribed to channel' : 'unsubscribed from channel', ' ', h('a.channel', {
43 + href: channel
44 + }, channel)
3345 ]
3446 }
47 +
48 + function isRenderable(msg) {
49 + return msg.value.content.type === 'channel' ? true : undefined
50 + }
3551 }
message/html/render/issue.jsView
@@ -10,22 +10,36 @@
1010 markdown: 'first'
1111 }
1212 })
1313
14-exports.gives = nest('message.html.render')
14 +exports.gives = nest({
15 + 'message.html': {
16 + canRender: true,
17 + render: true
18 + }
19 +})
1520
16-exports.create = function (api) {
17- return nest('message.html.render', function renderMessage (msg, opts) {
18- if (msg.value.content.type !== 'issue') return
19- var element = api.message.html.layout(msg, extend({
20- content: messageContent(msg),
21- layout: 'default'
22- }, opts))
21 +exports.create = function(api) {
22 + return nest('message.html', {
23 + canRender: isRenderable,
24 + render: function(msg, opts) {
25 + if (!isRenderable(msg)) return
26 + var element = api.message.html.layout(msg, extend({
27 + content: messageContent(msg),
28 + layout: 'default'
29 + }, opts))
2330
24- return api.message.html.decorate(element, { msg })
31 + return api.message.html.decorate(element, {
32 + msg
33 + })
34 + }
2535 })
2636
27- function messageContent (data) {
37 + function messageContent(data) {
2838 if (!data.value.content || !data.value.content.text) return
2939 return h('div', {}, api.message.html.markdown(data.value.content))
3040 }
41 +
42 + function isRenderable(msg) {
43 + return msg.value.content.type === 'issue' ? true : undefined
44 + }
3145 }
message/html/render/post.jsView
@@ -10,28 +10,42 @@
1010 markdown: 'first'
1111 }
1212 })
1313
14-exports.gives = nest('message.html.render')
14 +exports.gives = nest({
15 + 'message.html': {
16 + canRender: true,
17 + render: true
18 + }
19 +})
1520
16-exports.create = function (api) {
17- return nest('message.html.render', function renderMessage (msg, opts) {
18- if (msg.value.content.type !== 'post') return
19- var element = api.message.html.layout(msg, extend({
20- title: messageTitle(msg),
21- content: msg.isBlocked ? 'Content of a blocked user' : messageContent(msg),
22- layout: 'default'
23- }, opts))
21 +exports.create = function(api) {
22 + return nest('message.html', {
23 + canRender: isRenderable,
24 + render: function(msg, opts) {
25 + if (!isRenderable(msg)) return
26 + var element = api.message.html.layout(msg, extend({
27 + title: messageTitle(msg),
28 + content: msg.isBlocked ? 'Content of a blocked user' : messageContent(msg),
29 + layout: 'default'
30 + }, opts))
2431
25- return api.message.html.decorate(element, { msg })
32 + return api.message.html.decorate(element, {
33 + msg
34 + })
35 + }
2636 })
2737
28- function messageContent (data) {
38 + function isRenderable(msg) {
39 + return (msg.value.content.type === 'post') ? true : undefined
40 + }
41 +
42 + function messageContent(data) {
2943 if (!data.value.content || !data.value.content.text) return
3044 return h('div', {}, api.message.html.markdown(data.value.content))
3145 }
3246
33- function messageTitle (data) {
47 + function messageTitle(data) {
3448 var root = data.value.content && data.value.content.root
3549 return !root ? null : h('span', ['re: ', api.message.html.link(root)])
3650 }
3751 }
message/html/render/vote.jsView
@@ -10,23 +10,35 @@
1010 markdown: 'first'
1111 }
1212 })
1313
14-exports.gives = nest('message.html.render')
14 +exports.gives = nest({
15 + 'message.html': {
16 + canRender: true,
17 + render: true
18 + }
19 +})
1520
1621 exports.create = function (api) {
17- return nest('message.html.render', vote)
22 + return nest('message.html', {
23 + canRender: isRenderable,
24 + render: vote
25 + })
1826
1927 function vote (msg, opts) {
20- if (msg.value.content.type !== 'vote') return
28 + if (!isRenderable(msg)) return
2129 var element = api.message.html.layout(msg, extend({
2230 content: renderContent(msg),
2331 layout: 'mini'
2432 }, opts))
2533
2634 return api.message.html.decorate(element, { msg })
2735 }
2836
37 + function isRenderable(msg) {
38 + return msg.value.content.type === 'vote' ? true : undefined
39 + }
40 +
2941 function renderContent (msg) {
3042 var link = msg.value.content.vote.link
3143 return [
3244 msg.value.content.vote.value > 0 ? 'dug' : 'undug', ' ', api.message.html.link(link)
package-lock.jsonView
@@ -1,7 +1,7 @@
11 {
22 "name": "patchcore",
3- "version": "1.12.1",
3 + "version": "1.13.3",
44 "lockfileVersion": 1,
55 "requires": true,
66 "dependencies": {
77 "acorn": {
@@ -670,9 +670,9 @@
670670 "dependencies": {
671671 "glob": {
672672 "version": "7.1.2",
673673 "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
674- "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
674 + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
675675 "dev": true,
676676 "requires": {
677677 "fs.realpath": "1.0.0",
678678 "inflight": "1.0.6",
@@ -994,9 +994,9 @@
994994 },
995995 "glob": {
996996 "version": "7.1.2",
997997 "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
998- "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
998 + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
999999 "dev": true,
10001000 "requires": {
10011001 "fs.realpath": "1.0.0",
10021002 "inflight": "1.0.6",
@@ -1268,9 +1268,9 @@
12681268 },
12691269 "globals": {
12701270 "version": "9.18.0",
12711271 "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz",
1272- "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ=="
1272 + "integrity": "sha1-qjiWs+abSH8X4x7SFD1pqOMMLYo="
12731273 },
12741274 "globby": {
12751275 "version": "5.0.0",
12761276 "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz",
@@ -1287,9 +1287,9 @@
12871287 "dependencies": {
12881288 "glob": {
12891289 "version": "7.1.2",
12901290 "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
1291- "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
1291 + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
12921292 "dev": true,
12931293 "requires": {
12941294 "fs.realpath": "1.0.0",
12951295 "inflight": "1.0.6",
@@ -1301,9 +1301,9 @@
13011301 },
13021302 "minimatch": {
13031303 "version": "3.0.4",
13041304 "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
1305- "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
1305 + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
13061306 "dev": true,
13071307 "requires": {
13081308 "brace-expansion": "1.1.8"
13091309 }
@@ -2193,9 +2193,9 @@
21932193 "dependencies": {
21942194 "glob": {
21952195 "version": "7.1.2",
21962196 "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
2197- "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
2197 + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
21982198 "dev": true,
21992199 "requires": {
22002200 "fs.realpath": "1.0.0",
22012201 "inflight": "1.0.6",
@@ -2207,9 +2207,9 @@
22072207 },
22082208 "minimatch": {
22092209 "version": "3.0.4",
22102210 "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
2211- "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
2211 + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
22122212 "dev": true,
22132213 "requires": {
22142214 "brace-expansion": "1.1.8"
22152215 }
@@ -2285,9 +2285,9 @@
22852285 "dependencies": {
22862286 "glob": {
22872287 "version": "7.1.2",
22882288 "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
2289- "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
2289 + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=",
22902290 "dev": true,
22912291 "requires": {
22922292 "fs.realpath": "1.0.0",
22932293 "inflight": "1.0.6",
@@ -2299,9 +2299,9 @@
22992299 },
23002300 "minimatch": {
23012301 "version": "3.0.4",
23022302 "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
2303- "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
2303 + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
23042304 "dev": true,
23052305 "requires": {
23062306 "brace-expansion": "1.1.8"
23072307 }
package.jsonView
@@ -1,7 +1,7 @@
11 {
22 "name": "patchcore",
3- "version": "1.13.2",
3 + "version": "1.13.3",
44 "description": "minimal core for ssb clients",
55 "main": "index.js",
66 "scripts": {
77 "start": "electro example",

Built with git-ssb-web