Files: 1994ec8623da9c5cd8b54b0dd3d1e3f59a22809a / message / html / layout / default.js
1282 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, Value } = require('mutant') |
3 | const { isMsg } = require('ssb-ref') |
4 | |
5 | exports.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 | |
16 | exports.gives = nest('message.html.layout') |
17 | |
18 | exports.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