git ssb

7+

dinoworm 🐛 / patchcore



Commit 233eaf96f16ccf1edd809dfb3b8a6a610aeeb15d

alternative home for plugs

mix irving committed on 2/13/2017, 11:51:23 PM
Parent: b58dd46b8f88f0917c480faf8286bdd209933739

Files changed

components/message/action/reply.jsadded
components/message/decorate/data-id.jsadded
components/message/layout/default.jsadded
components/message/layout/mini.jsadded
components/message/meta/channel.jsadded
components/message/render/post.jsadded
components/message/render/vote.jsadded
components/message/render/zz_fallback.jsadded
plugs/message_action/reply.jsdeleted
plugs/message_decorate/data-id.jsdeleted
plugs/message_layout/default.jsdeleted
plugs/message_layout/mini.jsdeleted
plugs/message_meta/channel.jsdeleted
plugs/message_render/post.jsdeleted
plugs/message_render/vote.jsdeleted
plugs/message_render/zz_fallback.jsdeleted
components/message/action/reply.jsView
@@ -1,0 +1,9 @@
1 +var h = require('mutant/h')
2 +
3 +exports.gives = 'message_action'
4 +
5 +exports.create = function () {
6 + return function reply (msg) {
7 + return h('a', { href: '#' + msg.key }, 'Reply')
8 + }
9 +}
components/message/decorate/data-id.jsView
@@ -1,0 +1,8 @@
1 +exports.gives = 'message_decorate'
2 +
3 +exports.create = function (api) {
4 + return function (element, { msg }) {
5 + element.dataset.id = msg.key
6 + return element
7 + }
8 +}
components/message/layout/default.jsView
@@ -1,0 +1,37 @@
1 +const h = require('mutant/h')
2 +
3 +exports.needs = {
4 + message_backlinks: 'first',
5 + message_author: 'first',
6 + message_meta: 'map',
7 + message_action: 'map',
8 + message: {
9 + timestamp: 'first'
10 + }
11 +}
12 +
13 +exports.gives = {
14 + message_layout: true
15 +}
16 +
17 +exports.create = function (api) {
18 + return {
19 + message_layout
20 + }
21 +
22 + function message_layout (msg, opts) {
23 + if (!(opts.layout === undefined || opts.layout === 'default')) return
24 + return h('div', {
25 + classList: 'Message'
26 + }, [
27 + h('header.author', {}, api.message_author(msg)),
28 + h('section.timestamp', {}, api.message.timestamp(msg)),
29 + h('section.title', {}, opts.title),
30 + h('section.meta', {}, api.message_meta(msg)),
31 + h('section.content', {}, opts.content),
32 + h('section.raw-content'),
33 + h('section.action', {}, api.message_action(msg)),
34 + h('footer.backlinks', {}, api.message_backlinks(msg))
35 + ])
36 + }
37 +}
components/message/layout/mini.jsView
@@ -1,0 +1,33 @@
1 +const h = require('mutant/h')
2 +
3 +exports.needs = {
4 + message_backlinks: 'first',
5 + message_author: 'first',
6 + message_meta: 'map',
7 + message: {
8 + timestamp: 'first'
9 + }
10 +}
11 +
12 +exports.gives = {
13 + message_layout: true
14 +}
15 +
16 +exports.create = function (api) {
17 + return {
18 + message_layout
19 + }
20 +
21 + function message_layout (msg, opts) {
22 + if (opts.layout !== 'mini') return
23 + return h('div', {
24 + classList: 'Message -mini'
25 + }, [
26 + h('header.author', {}, api.message_author(msg, { size: 'mini' })),
27 + h('section.timestamp', {}, api.message.timestamp(msg)),
28 + h('section.meta', {}, api.message_meta(msg)),
29 + h('section.content', {}, opts.content),
30 + h('section.raw-content')
31 + ])
32 + }
33 +}
components/message/meta/channel.jsView
@@ -1,0 +1,10 @@
1 +const h = require('mutant/h')
2 +
3 +exports.gives = 'message_meta'
4 +
5 +exports.create = function (api) {
6 + return function channel (msg) {
7 + const { channel } = msg.value.content
8 + if (channel) return h('span', {}, ['#' + channel])
9 + }
10 +}
components/message/render/post.jsView
@@ -1,0 +1,39 @@
1 +var h = require('mutant/h')
2 +
3 +exports.needs = {
4 + message_decorate: 'reduce',
5 + message_layout: 'first',
6 + message_link: 'first',
7 + markdown: 'first'
8 +}
9 +
10 +exports.gives = {
11 + message_render: true
12 +}
13 +
14 +exports.create = function (api) {
15 + return {
16 + message_render
17 + }
18 +
19 + function message_render (msg) {
20 + if (msg.value.content.type !== 'post') return
21 + var element = api.message_layout(msg, {
22 + title: message_title(msg),
23 + content: message_content(msg),
24 + layout: 'default'
25 + })
26 +
27 + return api.message_decorate(element, { msg })
28 + }
29 +
30 + function message_content (data) {
31 + if (!data.value.content || !data.value.content.text) return
32 + return h('div', {}, api.markdown(data.value.content))
33 + }
34 +
35 + function message_title (data) {
36 + var root = data.value.content && data.value.content.root
37 + return !root ? null : h('span', ['re: ', api.message_link(root)])
38 + }
39 +}
components/message/render/vote.jsView
@@ -1,0 +1,35 @@
1 +var h = require('mutant/h')
2 +
3 +exports.needs = {
4 + message_layout: 'first',
5 + message_decorate: 'reduce',
6 + message_link: 'first',
7 + markdown: 'first'
8 +}
9 +
10 +exports.gives = {
11 + message_render: true
12 +}
13 +
14 +exports.create = function (api) {
15 + return {
16 + message_render
17 + }
18 +
19 + function message_render (msg) {
20 + if (msg.value.content.type !== 'vote') return
21 + var element = api.message_layout(msg, {
22 + content: render_vote(msg),
23 + layout: 'mini'
24 + })
25 +
26 + return api.message_decorate(element, { msg })
27 + }
28 +
29 + function render_vote (msg) {
30 + var link = msg.value.content.vote.link
31 + return [
32 + msg.value.content.vote.value > 0 ? 'dug' : 'undug', ' ', api.message_link(link)
33 + ]
34 + }
35 +}
components/message/render/zz_fallback.jsView
@@ -1,0 +1,33 @@
1 +var h = require('mutant/h')
2 +
3 +exports.needs = {
4 + message_layout: 'first',
5 + message_decorate: 'reduce'
6 +}
7 +
8 +exports.gives = {
9 + message_render: true
10 +}
11 +
12 +exports.create = function (api) {
13 + return {
14 + message_render
15 + }
16 +
17 + function message_render (msg) {
18 + var element = api.message_layout(msg, {
19 + content: message_content(msg),
20 + layout: 'mini'
21 + })
22 +
23 + return api.message_decorate(element, { msg })
24 + }
25 +
26 + function message_content (msg) {
27 + if (typeof msg.value.content === 'string') {
28 + return h('code', {}, 'PRIVATE')
29 + } else {
30 + return h('code', {}, msg.value.content.type)
31 + }
32 + }
33 +}
plugs/message_action/reply.jsView
@@ -1,9 +1,0 @@
1-var h = require('mutant/h')
2-
3-exports.gives = 'message_action'
4-
5-exports.create = function () {
6- return function reply (msg) {
7- return h('a', { href: '#' + msg.key }, 'Reply')
8- }
9-}
plugs/message_decorate/data-id.jsView
@@ -1,8 +1,0 @@
1-exports.gives = 'message_decorate'
2-
3-exports.create = function (api) {
4- return function (element, { msg }) {
5- element.dataset.id = msg.key
6- return element
7- }
8-}
plugs/message_layout/default.jsView
@@ -1,37 +1,0 @@
1-const h = require('mutant/h')
2-
3-exports.needs = {
4- message_backlinks: 'first',
5- message_author: 'first',
6- message_meta: 'map',
7- message_action: 'map',
8- message: {
9- timestamp: 'first'
10- }
11-}
12-
13-exports.gives = {
14- message_layout: true
15-}
16-
17-exports.create = function (api) {
18- return {
19- message_layout
20- }
21-
22- function message_layout (msg, opts) {
23- if (!(opts.layout === undefined || opts.layout === 'default')) return
24- return h('div', {
25- classList: 'Message'
26- }, [
27- h('header.author', {}, api.message_author(msg)),
28- h('section.timestamp', {}, api.message.timestamp(msg)),
29- h('section.title', {}, opts.title),
30- h('section.meta', {}, api.message_meta(msg)),
31- h('section.content', {}, opts.content),
32- h('section.raw-content'),
33- h('section.action', {}, api.message_action(msg)),
34- h('footer.backlinks', {}, api.message_backlinks(msg))
35- ])
36- }
37-}
plugs/message_layout/mini.jsView
@@ -1,33 +1,0 @@
1-const h = require('mutant/h')
2-
3-exports.needs = {
4- message_backlinks: 'first',
5- message_author: 'first',
6- message_meta: 'map',
7- message: {
8- timestamp: 'first'
9- }
10-}
11-
12-exports.gives = {
13- message_layout: true
14-}
15-
16-exports.create = function (api) {
17- return {
18- message_layout
19- }
20-
21- function message_layout (msg, opts) {
22- if (opts.layout !== 'mini') return
23- return h('div', {
24- classList: 'Message -mini'
25- }, [
26- h('header.author', {}, api.message_author(msg, { size: 'mini' })),
27- h('section.timestamp', {}, api.message.timestamp(msg)),
28- h('section.meta', {}, api.message_meta(msg)),
29- h('section.content', {}, opts.content),
30- h('section.raw-content')
31- ])
32- }
33-}
plugs/message_meta/channel.jsView
@@ -1,10 +1,0 @@
1-const h = require('mutant/h')
2-
3-exports.gives = 'message_meta'
4-
5-exports.create = function (api) {
6- return function channel (msg) {
7- const { channel } = msg.value.content
8- if (channel) return h('span', {}, ['#' + channel])
9- }
10-}
plugs/message_render/post.jsView
@@ -1,39 +1,0 @@
1-var h = require('mutant/h')
2-
3-exports.needs = {
4- message_decorate: 'reduce',
5- message_layout: 'first',
6- message_link: 'first',
7- markdown: 'first'
8-}
9-
10-exports.gives = {
11- message_render: true
12-}
13-
14-exports.create = function (api) {
15- return {
16- message_render
17- }
18-
19- function message_render (msg) {
20- if (msg.value.content.type !== 'post') return
21- var element = api.message_layout(msg, {
22- title: message_title(msg),
23- content: message_content(msg),
24- layout: 'default'
25- })
26-
27- return api.message_decorate(element, { msg })
28- }
29-
30- function message_content (data) {
31- if (!data.value.content || !data.value.content.text) return
32- return h('div', {}, api.markdown(data.value.content))
33- }
34-
35- function message_title (data) {
36- var root = data.value.content && data.value.content.root
37- return !root ? null : h('span', ['re: ', api.message_link(root)])
38- }
39-}
plugs/message_render/vote.jsView
@@ -1,35 +1,0 @@
1-var h = require('mutant/h')
2-
3-exports.needs = {
4- message_layout: 'first',
5- message_decorate: 'reduce',
6- message_link: 'first',
7- markdown: 'first'
8-}
9-
10-exports.gives = {
11- message_render: true
12-}
13-
14-exports.create = function (api) {
15- return {
16- message_render
17- }
18-
19- function message_render (msg) {
20- if (msg.value.content.type !== 'vote') return
21- var element = api.message_layout(msg, {
22- content: render_vote(msg),
23- layout: 'mini'
24- })
25-
26- return api.message_decorate(element, { msg })
27- }
28-
29- function render_vote (msg) {
30- var link = msg.value.content.vote.link
31- return [
32- msg.value.content.vote.value > 0 ? 'dug' : 'undug', ' ', api.message_link(link)
33- ]
34- }
35-}
plugs/message_render/zz_fallback.jsView
@@ -1,33 +1,0 @@
1-var h = require('mutant/h')
2-
3-exports.needs = {
4- message_layout: 'first',
5- message_decorate: 'reduce'
6-}
7-
8-exports.gives = {
9- message_render: true
10-}
11-
12-exports.create = function (api) {
13- return {
14- message_render
15- }
16-
17- function message_render (msg) {
18- var element = api.message_layout(msg, {
19- content: message_content(msg),
20- layout: 'mini'
21- })
22-
23- return api.message_decorate(element, { msg })
24- }
25-
26- function message_content (msg) {
27- if (typeof msg.value.content === 'string') {
28- return h('code', {}, 'PRIVATE')
29- } else {
30- return h('code', {}, msg.value.content.type)
31- }
32- }
33-}

Built with git-ssb-web