git ssb

16+

Dominic / patchbay



Tree: 78dec1818c3a24d568c11eeaeaf553ac7a3e9140

Files: 78dec1818c3a24d568c11eeaeaf553ac7a3e9140 / message / html / layout / default.js

1282 bytesRaw
1const nest = require('depnest')
2const { h, Value } = require('mutant')
3const { isMsg } = require('ssb-ref')
4
5exports.needs = nest({
6 'message.html': {
7 backlinks: 'first',
8 author: 'first',
9 meta: 'map',
10 action: 'map',
11 timestamp: 'first'
12 },
13 'about.html.avatar': 'first'
14})
15
16exports.gives = nest('message.html.layout')
17
18exports.create = (api) => {
19 return nest('message.html.layout', messageLayout)
20
21 function messageLayout (msg, opts) {
22 if (!(opts.layout === undefined || opts.layout === 'default')) return
23
24 var { author, timestamp, meta, action, backlinks } = api.message.html
25 if (!isMsg(msg.key)) action = () => {}
26
27 var rawMessage = Value(null)
28
29 return h('Message', {
30 attributes: {
31 tabindex: '0' // needed to be able to navigate and show focus()
32 }
33 }, [
34 h('section.avatar', {}, api.about.html.avatar(msg.value.author)),
35 h('section.timestamp', {}, timestamp(msg)),
36 h('header.author', {}, author(msg)),
37 h('section.meta', {}, meta(msg, { rawMessage })),
38 h('section.title', {}, opts.title),
39 h('section.content', {}, opts.content),
40 h('section.raw-content', rawMessage),
41 h('section.actions', {}, action(msg)),
42 h('footer.backlinks', {}, backlinks(msg))
43 ])
44 }
45}
46

Built with git-ssb-web