From 4bc88fee677e467a6444fd16ec6a90e7c9548aaa Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 11 Apr 2017 23:25:59 -0700 Subject: Put attachment markdown into composer --- lib/serve.js | 17 +++++++++-------- 1 file 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()) : '' ) -- cgit v1.2.3