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