git ssb

0+

dangerousbeans / yap



forked from Dominic / yap

Tree: 005856970f52098bfb3fd216a0c32b83d7b0cfe8

Files: 005856970f52098bfb3fd216a0c32b83d7b0cfe8 / apis / preview.js

1575 bytesRaw
1var u = require('../util')
2var getMentions = require('../mentions')
3
4function toRecps (ary) {
5 return ary.map(function (e) {
6 return 'string' === typeof e ? e : e.link
7 }).filter(Boolean).join(',')
8}
9
10module.exports = function (sbot) {
11 return function (opts, apply) {
12 var id = opts.id
13 var content = opts.content
14
15 console.error("preview", opts)
16
17 //fake message, with enough fields to give to message renderer
18 var data = {
19 key: '%................',
20 value: {
21 author: id,
22 content: content
23 }
24 }
25 return ['div.MessagePreview',
26 ['form',
27 {name: 'publish', method: 'POST'},
28 //TODO: enable changing the identity to publish as here
29
30 // for a message already related to something, such as a yup
31 // or a follow, it is easier to have just a couple of choices
32 // post the message to your self, or to the poster and yourself.
33 opts.suggestedRecps ?
34 apply('suggestedRecipients', opts) : '',
35
36 // for a private post, obviously you'd want to be able to
37 // include anyone.... TODO that
38
39 ['input', {type: 'hidden', name: 'id', value: data.value.author}],
40 apply('message', data),
41 u.createHiddenInputs(data.value.content, 'content'),
42 apply('mentions', data.value.content),
43 ['button', {name: 'type', value: 'publish'}, 'Publish']
44 ]
45 ]
46
47 //TODO: add form to set recipients, and change author.
48 //press back to edit body of the message again...
49 //submit takes you to back to the thread page.
50 }
51}
52
53

Built with git-ssb-web