git ssb

7+

dinoworm 🐛 / patchcore



Commit 05c1a0ae31c0547a316baa6497637eba2c85df73

Merge branch 'Happy0-canRender'

Matt McKegg committed on 10/19/2017, 2:37:09 AM
Parent: 418ac35b065b1ea7acf2d01ec7f1de61a5a721df
Parent: 428676644191b3fcf658e49167d835bb682488a2

Files changed

contact/async.jschanged
contact/obs.jschanged
example/index.jschanged
feed/pull/channel.jschanged
feed/pull/public.jschanged
feed/pull/rollup.jschanged
feed/pull/type.jschanged
message/async/name.jschanged
message/html/author.jschanged
message/html/layout/default.jschanged
message/html/layout/mini.jschanged
message/html/render/channel.jschanged
message/html/render/issue.jschanged
message/html/render/post.jschanged
message/html/render/vote.jschanged
message/obs/likes.jschanged
package-lock.jsonchanged
contact/async.jsView
@@ -1,7 +1,5 @@
11 var nest = require('depnest')
2-var onceTrue = require('mutant/once-true')
3-var resolve = require('mutant/resolve')
42 var ref = require('ssb-ref')
53
64 exports.needs = nest({
75 'contact.obs.following': 'first',
@@ -57,5 +55,4 @@
5755 blocking: false
5856 }, cb)
5957 }
6058 }
61-
contact/obs.jsView
@@ -1,11 +1,13 @@
1 +'use strict'
2 +
13 var nest = require('depnest')
24 var { Value, computed } = require('mutant')
35 var pull = require('pull-stream')
46 var ref = require('ssb-ref')
57
68 exports.needs = nest({
7- 'sbot.pull.stream': 'first',
9 + 'sbot.pull.stream': 'first'
810 })
911
1012 exports.gives = nest({
1113 'contact.obs': ['following', 'followers', 'blocking', 'blockers'],
@@ -71,17 +73,17 @@
7173 if (ref.isFeed(source)) {
7274 update(source, item[source], cache)
7375
7476 // generate reverse lookup
75- for (var dest in item[source]) {
77 + for (let dest in item[source]) {
7678 reverse[dest] = reverse[dest] || {}
7779 reverse[dest][source] = item[source][dest]
7880 }
7981 }
8082 }
8183
8284 // populate reverse observable cache
83- for (var dest in reverse) {
85 + for (let dest in reverse) {
8486 update(dest, reverse[dest], reverseCache)
8587 }
8688
8789 sync.set(true)
example/index.jsView
@@ -1,8 +1,9 @@
11 const combine = require('depject')
22 const apply = require('depject/apply')
33 const h = require('mutant/h')
44 const fs = require('fs')
5 +const Path = require('path')
56
67 const modules = require('../')
78 var api = entry(combine(modules))
89
@@ -12,9 +13,9 @@
1213 // public: 'first'
1314 // }
1415 // })()
1516
16-require('insert-css')(fs.readFileSync(__dirname + '/styles.css', 'utf8'))
17 +require('insert-css')(fs.readFileSync(Path.join(__dirname, 'styles.css'), 'utf8'))
1718
1819 var app = h('div.App', [
1920 api.feed.html.render(api.feed.pull.public)
2021 ])
feed/pull/channel.jsView
@@ -4,9 +4,9 @@
44
55 exports.gives = nest('feed.pull.channel')
66 exports.needs = nest({
77 'sbot.pull.backlinks': 'first',
8- 'message.sync.isBlocked': 'first',
8 + 'message.sync.isBlocked': 'first'
99 })
1010
1111 exports.create = function (api) {
1212 return nest('feed.pull.channel', function (channel) {
feed/pull/public.jsView
@@ -3,9 +3,9 @@
33
44 exports.gives = nest('feed.pull.public')
55 exports.needs = nest({
66 'sbot.pull.feed': 'first',
7- 'message.sync.isBlocked': 'first',
7 + 'message.sync.isBlocked': 'first'
88 })
99
1010 exports.create = function (api) {
1111 return nest('feed.pull.public', (opts) => {
feed/pull/rollup.jsView
@@ -13,9 +13,9 @@
1313 'backlinks.obs.for': 'first',
1414 'sbot.async.get': 'first',
1515 'message.sync.isBlocked': 'first',
1616 'message.sync.root': 'first',
17- 'message.sync.unbox': 'first',
17 + 'message.sync.unbox': 'first'
1818 })
1919
2020 exports.gives = nest('feed.pull.rollup', true)
2121
feed/pull/type.jsView
@@ -4,9 +4,9 @@
44
55 exports.gives = nest('feed.pull.type')
66 exports.needs = nest({
77 'sbot.pull.messagesByType': 'first',
8- 'message.sync.isBlocked': 'first',
8 + 'message.sync.isBlocked': 'first'
99 })
1010
1111 exports.create = function (api) {
1212 return nest('feed.pull.type', (type) => {
message/async/name.jsView
@@ -49,10 +49,10 @@
4949 }
5050
5151 function titleFromMarkdown (text, max) {
5252 text = text.trim().split('\n', 3).join('\n')
53- text = text.replace(/_|`|\*|\#|^\[@.*?\]|\[|\]|\(\S*?\)/g, '').trim()
54- text = text.replace(/\:$/, '')
53 + text = text.replace(/_|`|\*|#|^\[@.*?]|\[|]|\(\S*?\)/g, '').trim()
54 + text = text.replace(/:$/, '')
5555 text = text.trim().split('\n', 1)[0].trim()
5656 if (text.length > max) {
5757 text = text.substring(0, max - 2) + '...'
5858 }
message/html/author.jsView
@@ -5,11 +5,11 @@
55
66 exports.gives = nest('message.html.author')
77
88 exports.create = function (api) {
9- return nest('message.html.author', message_author)
9 + return nest('message.html.author', messageAuthor)
1010
11- function message_author (msg) {
11 + function messageAuthor (msg) {
1212 return h('div', {title: msg.value.author}, [
1313 '@', api.about.obs.name(msg.value.author)
1414 ])
1515 }
message/html/layout/default.jsView
@@ -11,11 +11,11 @@
1111
1212 exports.gives = nest('message.html.layout')
1313
1414 exports.create = (api) => {
15- return nest('message.html.layout', message_layout)
15 + return nest('message.html.layout', messageLayout)
1616
17- function message_layout (msg, opts) {
17 + function messageLayout (msg, opts) {
1818 if (!(opts.layout === undefined || opts.layout === 'default')) return
1919 return h('div', {
2020 classList: 'Message'
2121 }, [
message/html/layout/mini.jsView
@@ -10,11 +10,11 @@
1010
1111 exports.gives = nest('message.html.layout')
1212
1313 exports.create = (api) => {
14- return nest('message.html.layout', message_layout)
14 + return nest('message.html.layout', messageLayout)
1515
16- function message_layout (msg, opts) {
16 + function messageLayout (msg, opts) {
1717 if (opts.layout !== 'mini') return
1818 return h('div', {
1919 classList: 'Message -mini'
2020 }, [
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
1621 exports.create = function (api) {
17- return nest('message.html.render', channel)
22 + return nest('message.html', {
23 + canRender: isRenderable,
24 + render: channel
25 + })
1826
1927 function channel (msg, opts) {
20- if (msg.value.content.type !== 'channel') 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
26- return api.message.html.decorate(element, { msg })
34 + return api.message.html.decorate(element, {
35 + msg
36 + })
2737 }
2838
2939 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
1621 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))
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
2737 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,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
1621 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))
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
38 + function isRenderable (msg) {
39 + return (msg.value.content.type === 'post') ? true : undefined
40 + }
41 +
2842 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 }
message/html/render/vote.jsView
@@ -1,5 +1,4 @@
1-var h = require('mutant/h')
21 var nest = require('depnest')
32 var extend = require('xtend')
43
54 exports.needs = nest({
@@ -10,23 +9,35 @@
109 markdown: 'first'
1110 }
1211 })
1312
14-exports.gives = nest('message.html.render')
13 +exports.gives = nest({
14 + 'message.html': {
15 + canRender: true,
16 + render: true
17 + }
18 +})
1519
1620 exports.create = function (api) {
17- return nest('message.html.render', vote)
21 + return nest('message.html', {
22 + canRender: isRenderable,
23 + render: vote
24 + })
1825
1926 function vote (msg, opts) {
20- if (msg.value.content.type !== 'vote') return
27 + if (!isRenderable(msg)) return
2128 var element = api.message.html.layout(msg, extend({
2229 content: renderContent(msg),
2330 layout: 'mini'
2431 }, opts))
2532
2633 return api.message.html.decorate(element, { msg })
2734 }
2835
36 + function isRenderable (msg) {
37 + return msg.value.content.type === 'vote' ? true : undefined
38 + }
39 +
2940 function renderContent (msg) {
3041 var link = msg.value.content.vote.link
3142 return [
3243 msg.value.content.vote.value > 0 ? 'dug' : 'undug', ' ', api.message.html.link(link)
message/obs/likes.jsView
@@ -1,9 +1,8 @@
11 var nest = require('depnest')
22 var ref = require('ssb-ref')
33 var MutantArray = require('mutant/array')
44 var concat = require('mutant/concat')
5-var watch = require('mutant/watch')
65
76 var { computed } = require('mutant')
87
98 exports.needs = nest({
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 }

Built with git-ssb-web