git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 7a3e6e95924f553c415e339923bd07c0bebef60e

add like and reply to about messages

closes #478
Matt McKegg committed on 4/9/2017, 10:54:46 AM
Parent: 19dac8af2306fc228373a25ca2bf52c090e05e2e

Files changed

plugs/message/html/layout/mini.jschanged
plugs/message/html/render/about.jschanged
styles/message.mcsschanged
plugs/message/html/layout/mini.jsView
@@ -1,9 +1,11 @@
1-const h = require('mutant/h')
1+const {h, computed} = require('mutant')
22 const nest = require('depnest')
3+var ref = require('ssb-ref')
34
45 exports.needs = nest({
56 'message.html': {
7+ action: 'map',
68 backlinks: 'first',
79 author: 'first',
810 meta: 'map',
911 timestamp: 'first'
@@ -16,25 +18,45 @@
1618 exports.create = (api) => {
1719 return nest('message.html.layout', mini)
1820
1921 function mini (msg, opts) {
22+ if (opts.layout !== 'mini') return
23+
2024 var classList = []
2125 var additionalMeta = []
26+ var footer = []
27+
28+ if (opts.showActions) {
29+ // HACK: this is used for about messages, which really should have there own layout
30+ footer.push(
31+ computed(msg.key, (key) => {
32+ if (ref.isMsg(key)) {
33+ return h('footer', [
34+ h('div.actions', [
35+ api.message.html.action(msg)
36+ ])
37+ ])
38+ }
39+ })
40+ )
41+ }
42+
2243 if (opts.priority >= 2) {
2344 classList.push('-new')
2445 additionalMeta.push(h('span.flag -new', {title: 'New Message'}))
2546 }
26- if (opts.layout !== 'mini') return
2747 return h('Message -mini', {classList}, [
2848 h('header', [
2949 h('div.mini', [
3050 api.profile.html.person(msg.value.author), ' ',
3151 opts.content
3252 ]),
3353 h('div.meta', {}, [
54+ api.message.html.meta(msg),
3455 api.message.html.timestamp(msg),
3556 additionalMeta
3657 ])
37- ])
58+ ]),
59+ footer
3860 ])
3961 }
4062 }
plugs/message/html/render/about.jsView
@@ -56,15 +56,18 @@
5656 var elements = []
5757
5858 if (content.length) {
5959 var element = api.message.html.layout(msg, extend({
60- content, layout: 'mini'
60+ showActions: true,
61+ content,
62+ layout: 'mini'
6163 }, opts))
6264 elements.push(api.message.html.decorate(element, { msg }))
6365 }
6466
6567 if (c.description) {
6668 elements.push(api.message.html.decorate(api.message.html.layout(msg, extend({
69+ showActions: true,
6770 content: [
6871 self ? 'self assigned a description' : ['assigned a description to ', api.profile.html.person(c.about)],
6972 api.message.html.markdown(c.description)
7073 ],
styles/message.mcssView
@@ -35,8 +35,17 @@
3535
3636 -mini {
3737 header {
3838 margin-bottom: 15px
39+ div.meta {
40+ span.likes {
41+ margin-top: -5px
42+ }
43+ a {
44+ display: inline-block
45+ margin-left: 3px
46+ }
47+ }
3948 }
4049 }
4150
4251 -reply {

Built with git-ssb-web