git ssb

7+

dinoworm 🐛 / patchcore



Commit dec1405faffdc02726f4a93daad00a2baffc0083

message.html.render: allow passing opts to message.html.layout

Matt McKegg committed on 2/15/2017, 12:08:58 PM
Parent: d22417019051f39b5191fc70d7052d81779e3ef7

Files changed

message/html/render/post.jschanged
message/html/render/vote.jschanged
message/html/render/zz_fallback.jschanged
package.jsonchanged
message/html/render/post.jsView
@@ -1,6 +1,7 @@
11 var h = require('mutant/h')
22 var nest = require('depnest')
3 +var extend = require('xtend')
34
45 exports.needs = nest({
56 'message.html': {
67 decorate: 'reduce',
@@ -12,15 +13,15 @@
1213
1314 exports.gives = nest('message.html.render')
1415
1516 exports.create = function (api) {
16- return nest('message.html.render', function renderMessage (msg) {
17 + return nest('message.html.render', function renderMessage (msg, opts) {
1718 if (msg.value.content.type !== 'post') return
18- var element = api.message.html.layout(msg, {
19 + var element = api.message.html.layout(msg, extend({
1920 title: messageTitle(msg),
2021 content: messageContent(msg),
2122 layout: 'default'
22- })
23 + }, opts))
2324
2425 return api.message.html.decorate(element, { msg })
2526 })
2627
message/html/render/vote.jsView
@@ -1,6 +1,7 @@
11 var h = require('mutant/h')
22 var nest = require('depnest')
3 +var extend = require('xtend')
34
45 exports.needs = nest({
56 'message.html': {
67 decorate: 'reduce',
@@ -12,21 +13,21 @@
1213
1314 exports.gives = nest('message.html.render')
1415
1516 exports.create = function (api) {
16- return nest('message.html.render', message_render)
17 + return nest('message.html.render', vote)
1718
18- function message_render (msg) {
19 + function vote (msg, opts) {
1920 if (msg.value.content.type !== 'vote') return
20- var element = api.message.html.layout(msg, {
21- content: render_vote(msg),
21 + var element = api.message.html.layout(msg, extend({
22 + content: renderContent(msg),
2223 layout: 'mini'
23- })
24 + }, opts))
2425
2526 return api.message.html.decorate(element, { msg })
2627 }
2728
28- function render_vote (msg) {
29 + function renderContent (msg) {
2930 var link = msg.value.content.vote.link
3031 return [
3132 msg.value.content.vote.value > 0 ? 'dug' : 'undug', ' ', api.message.html.link(link)
3233 ]
message/html/render/zz_fallback.jsView
@@ -1,6 +1,7 @@
11 var h = require('mutant/h')
22 var nest = require('depnest')
3 +var extend = require('xtend')
34
45 exports.needs = nest({
56 'message.html': {
67 decorate: 'reduce',
@@ -12,18 +13,18 @@
1213
1314 exports.create = function (api) {
1415 return nest('message.html.render', renderMessage)
1516
16- function renderMessage (msg) {
17- var element = api.message.html.layout(msg, {
18- content: message_content(msg),
17 + function renderMessage (msg, opts) {
18 + var element = api.message.html.layout(msg, extend({
19 + content: renderContent(msg),
1920 layout: 'mini'
20- })
21 + }, opts))
2122
2223 return api.message.html.decorate(element, { msg })
2324 }
2425
25- function message_content (msg) {
26 + function renderContent (msg) {
2627 if (typeof msg.value.content === 'string') {
2728 return h('code', {}, 'PRIVATE')
2829 } else {
2930 return h('code', {}, msg.value.content.type)
package.jsonView
@@ -40,8 +40,9 @@
4040 "ssb-keys": "^7.0.4",
4141 "ssb-markdown": "^3.2.1",
4242 "ssb-ref": "^2.6.2",
4343 "visualize-buffer": "0.0.1"
44 + "xtend": "^4.0.1"
4445 },
4546 "browserify": {
4647 "transform": [
4748 "bulkify",

Built with git-ssb-web