aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-06-28 23:27:37 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-06-29 11:00:43 -1000
commite16b4a1f99ec9235ed54179a5b29569deac7a298 (patch)
tree51d150ce14a51797225d31c82d2a776578d7f52b /lib
parentd23f29afb789f399f74d9d33987e8e3e1f235afd (diff)
downloadpatchfoo-e16b4a1f99ec9235ed54179a5b29569deac7a298.tar.gz
patchfoo-e16b4a1f99ec9235ed54179a5b29569deac7a298.zip
Handle audio/video blobs
Diffstat (limited to 'lib')
-rw-r--r--lib/render.js20
-rw-r--r--lib/serve.js19
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