aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-04-11 23:25:59 -0700
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-04-11 23:25:59 -0700
commit4bc88fee677e467a6444fd16ec6a90e7c9548aaa (patch)
tree2723f2c08f033dede8eb0fc4fb8c6209fc21b654
parent5d3c9540eea7cf1ff9427df6995427697fb2629b (diff)
downloadpatchfoo-4bc88fee677e467a6444fd16ec6a90e7c9548aaa.tar.gz
patchfoo-4bc88fee677e467a6444fd16ec6a90e7c9548aaa.zip
Put attachment markdown into composer
-rw-r--r--lib/serve.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 7879377..2f96d57 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -989,6 +989,14 @@ Serve.prototype.composer = function (opts, cb) {
formNames[mentionNames[i]] = u.extractFeedIds(mentionIds[i])[0]
}
+ if (data.upload) {
+ // TODO: be able to change the content-type
+ var isImage = /^image\//.test(data.upload.type)
+ data.text = (data.text ? data.text + '\n' : '')
+ + (isImage ? '!' : '')
+ + '[' + data.upload.name + '](' + data.upload.link + ')'
+ }
+
var done = multicb({pluck: 1, spread: true})
done()(null, h('section.composer',
h('form', {method: 'post', action: opts.id ? '#' + opts.id : '',
@@ -1011,8 +1019,7 @@ Serve.prototype.composer = function (opts, cb) {
h('table.ssb-msgs',
h('tr.msg-row',
h('td.msg-left', {colspan: 2},
- h('input', {type: 'file', name: 'upload'}), ' ',
- h('input', {type: 'submit', name: 'action', value: 'attach'})
+ h('input', {type: 'file', name: 'upload'})
),
h('td.msg-right',
h('input', {type: 'submit', name: 'action', value: 'raw'}), ' ',
@@ -1020,12 +1027,6 @@ Serve.prototype.composer = function (opts, cb) {
)
)
),
- data.upload ? [
- h('div', h('em', 'attach:')),
- h('code', '[' + data.upload.name + '](' + data.upload.link + ')'), ' ',
- h('input', {name: 'blob_link', value: data.upload.link, type: 'hidden'}),
- h('input', {name: 'blob_type', value: data.upload.type})
- ] : '',
data.action === 'preview' ? preview(false, done()) :
data.action === 'raw' ? preview(true, done()) : ''
)