diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/render.js | 20 | ||||
-rw-r--r-- | lib/serve.js | 19 |
2 files changed, 31 insertions, 8 deletions
diff --git a/lib/render.js b/lib/render.js index 0d83f75..e9fae80 100644 --- a/lib/render.js +++ b/lib/render.js @@ -25,12 +25,22 @@ MdRenderer.prototype.urltransform = function (href) { } MdRenderer.prototype.image = function (ref, title, text) { - var href = this.render.imageUrl(ref) - return h('img', { - src: href, - alt: this.render.getImageAlt(ref, text), + var alt = this.render.getImageAlt(ref, text) + return (/^video:/.test(text) ? h('video', { + controls: 'controls', + src: this.render.toUrl(ref), + alt: alt, title: title || undefined - }).outerHTML + }) : /^audio:/.test(text) ? h('audio', { + controls: 'controls', + src: this.render.toUrl(ref), + alt: alt, + title: title || undefined + }) : h('img', { + src: this.render.imageUrl(ref), + alt: alt, + title: title || undefined + })).outerHTML } MdRenderer.prototype.link = function (ref, title, text) { diff --git a/lib/serve.js b/lib/serve.js index 448b18b..3c9334f 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -3027,6 +3027,16 @@ Serve.prototype.wrapMyChannels = function (opts) { }) } +var blobPrefixesByType = { + audio: 'audio:', + video: 'video:', +} + +var blobPrefixesByExt = { + mp3: 'audio:', + mp4: 'video:', +} + Serve.prototype.composer = function (opts, cb) { var self = this opts = opts || {} @@ -3078,10 +3088,13 @@ Serve.prototype.composer = function (opts, cb) { var href = data.upload.link + (data.upload.key ? '?unbox=' + data.upload.key + '.boxs': '') // TODO: be able to change the content-type - var isImage = /^image\//.test(data.upload.type) + var blobType = String(data.upload.type).split('/')[0] + var blobExt = String(data.upload.name).split('.').pop() + var blobPrefix = blobPrefixesByType[blobType] || blobPrefixesByExt[blobExt] || '' + var isMedia = blobPrefix || blobType === 'image' data.text = (data.text ? data.text + '\n' : '') - + (isImage ? '!' : '') - + '[' + data.upload.name + '](' + href + ')' + + (isMedia ? '!' : '') + + '[' + blobPrefix + data.upload.name + '](' + href + ')' } // get bare feed names |