Include filename in download link and embedd ogg audio

This commit is contained in:
JC Brand 2018-09-25 00:21:17 +02:00
parent af35d461e8
commit 6bd4782ff6
4 changed files with 33 additions and 30 deletions

33
dist/converse.js vendored
View File

@ -78364,9 +78364,9 @@ return __p
var _ = {escape:__webpack_require__(/*! ./node_modules/lodash/escape.js */ "./node_modules/lodash/escape.js")}; var _ = {escape:__webpack_require__(/*! ./node_modules/lodash/escape.js */ "./node_modules/lodash/escape.js")};
module.exports = function(o) { module.exports = function(o) {
var __t, __p = '', __e = _.escape; var __t, __p = '', __e = _.escape;
__p += '<!-- src/templates/audio.html -->\n<audio controls><source src="' + __p += '<!-- src/templates/audio.html -->\n<audio controls src="' +
__e(o.url) + __e(o.url) +
'" type="audio/mpeg"></audio>\n<a target="_blank" rel="noopener" href="' + '"></audio>\n<a target="_blank" rel="noopener" href="' +
__e(o.url) + __e(o.url) +
'">' + '">' +
__e(o.label_download) + __e(o.label_download) +
@ -81421,7 +81421,7 @@ module.exports = function(o) {
var __t, __p = '', __e = _.escape; var __t, __p = '', __e = _.escape;
__p += '<!-- src/templates/video.html -->\n<video controls src="' + __p += '<!-- src/templates/video.html -->\n<video controls src="' +
__e(o.url) + __e(o.url) +
'" type="video/mp4" style="max-height: 50vh"></video>\n<a target="_blank" rel="noopener" href="' + '" style="max-height: 50vh"></video>\n<a target="_blank" rel="noopener" href="' +
__e(o.url) + __e(o.url) +
'">' + '">' +
__e(o.label_download) + __e(o.label_download) +
@ -81729,28 +81729,29 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
u.renderFileURL = function (_converse, url) { u.renderFileURL = function (_converse, url) {
const uri = new URI(url), const uri = new URI(url),
__ = _converse.__,
filename = uri.filename(), filename = uri.filename(),
lower_filename = filename.toLowerCase(); lower_filename = filename.toLowerCase();
if (!_.includes(["https", "http"], uri.protocol().toLowerCase()) || lower_filename.endsWith('mp3') || lower_filename.endsWith('mp4') || lower_filename.endsWith('jpg') || lower_filename.endsWith('jpeg') || lower_filename.endsWith('png') || lower_filename.endsWith('gif') || lower_filename.endsWith('m4a') || lower_filename.endsWith('webm') || lower_filename.endsWith('svg')) { if (!_.includes(["https", "http"], uri.protocol().toLowerCase()) || lower_filename.endsWith('mp3') || lower_filename.endsWith('mp4') || lower_filename.endsWith('ogg') || lower_filename.endsWith('jpg') || lower_filename.endsWith('jpeg') || lower_filename.endsWith('png') || lower_filename.endsWith('gif') || lower_filename.endsWith('m4a') || lower_filename.endsWith('webm') || lower_filename.endsWith('svg')) {
return url; return url;
} }
const __ = _converse.__;
return tpl_file({ return tpl_file({
'url': url, 'url': url,
'label_download': __('Download "%1$s"', uri.filename()) 'label_download': __('Download file "%1$s"', decodeURI(filename))
}); });
}; };
u.renderImageURL = function (_converse, url) { u.renderImageURL = function (_converse, url) {
const __ = _converse.__, const lurl = url.toLowerCase();
lurl = url.toLowerCase();
if (lurl.endsWith('jpg') || lurl.endsWith('jpeg') || lurl.endsWith('png') || lurl.endsWith('gif') || lurl.endsWith('svg')) { if (lurl.endsWith('jpg') || lurl.endsWith('jpeg') || lurl.endsWith('png') || lurl.endsWith('gif') || lurl.endsWith('svg')) {
const __ = _converse.__,
uri = new URI(url);
return tpl_image({ return tpl_image({
'url': url, 'url': url,
'label_download': __('Download') 'label_download': __('Download image "%1$s"', decodeURI(uri.filename()))
}); });
} }
@ -81758,12 +81759,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}; };
u.renderMovieURL = function (_converse, url) { u.renderMovieURL = function (_converse, url) {
const __ = _converse.__;
if (url.endsWith('mp4') || url.endsWith('webm')) { if (url.endsWith('mp4') || url.endsWith('webm')) {
const __ = _converse.__,
uri = new URI(url);
return tpl_video({ return tpl_video({
'url': url, 'url': url,
'label_download': __('Download video file') 'label_download': __('Download video file "%1$s"', decodeURI(uri.filename()))
}); });
} }
@ -81771,12 +81772,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}; };
u.renderAudioURL = function (_converse, url) { u.renderAudioURL = function (_converse, url) {
const __ = _converse.__; if (url.endsWith('mp3') || url.endsWith('m4a') || url.endsWith('ogg')) {
const __ = _converse.__,
if (url.endsWith('mp3') || url.endsWith('m4a')) { uri = new URI(url);
return tpl_audio({ return tpl_audio({
'url': url, 'url': url,
'label_download': __('Download audio file') 'label_download': __('Download audio file "%1$s"', decodeURI(uri.filename()))
}); });
} }

View File

@ -1,2 +1,2 @@
<audio controls><source src="{{{o.url}}}" type="audio/mpeg"></audio> <audio controls src="{{{o.url}}}"></audio>
<a target="_blank" rel="noopener" href="{{{o.url}}}">{{{o.label_download}}}</a> <a target="_blank" rel="noopener" href="{{{o.url}}}">{{{o.label_download}}}</a>

View File

@ -1,2 +1,2 @@
<video controls src="{{{o.url}}}" type="video/mp4" style="max-height: 50vh"></video> <video controls src="{{{o.url}}}" style="max-height: 50vh"></video>
<a target="_blank" rel="noopener" href="{{{o.url}}}">{{{o.label_download}}}</a> <a target="_blank" rel="noopener" href="{{{o.url}}}">{{{o.label_download}}}</a>

View File

@ -307,11 +307,10 @@
u.renderFileURL = function (_converse, url) { u.renderFileURL = function (_converse, url) {
const uri = new URI(url), const uri = new URI(url),
{ __ } = _converse,
filename = uri.filename(), filename = uri.filename(),
lower_filename = filename.toLowerCase(); lower_filename = filename.toLowerCase();
if (!_.includes(["https", "http"], uri.protocol().toLowerCase()) || if (!_.includes(["https", "http"], uri.protocol().toLowerCase()) ||
lower_filename.endsWith('mp3') || lower_filename.endsWith('mp4') || lower_filename.endsWith('mp3') || lower_filename.endsWith('mp4') || lower_filename.endsWith('ogg') ||
lower_filename.endsWith('jpg') || lower_filename.endsWith('jpeg') || lower_filename.endsWith('jpg') || lower_filename.endsWith('jpeg') ||
lower_filename.endsWith('png') || lower_filename.endsWith('gif') || lower_filename.endsWith('png') || lower_filename.endsWith('gif') ||
lower_filename.endsWith('m4a') || lower_filename.endsWith('webm') || lower_filename.endsWith('m4a') || lower_filename.endsWith('webm') ||
@ -319,44 +318,47 @@
return url; return url;
} }
const { __ } = _converse;
return tpl_file({ return tpl_file({
'url': url, 'url': url,
'label_download': __('Download "%1$s"', uri.filename()) 'label_download': __('Download file "%1$s"', decodeURI(filename))
}) })
}; };
u.renderImageURL = function (_converse, url) { u.renderImageURL = function (_converse, url) {
const { __ } = _converse, const lurl = url.toLowerCase();
lurl = url.toLowerCase();
if (lurl.endsWith('jpg') || lurl.endsWith('jpeg') || lurl.endsWith('png') || if (lurl.endsWith('jpg') || lurl.endsWith('jpeg') || lurl.endsWith('png') ||
lurl.endsWith('gif') || lurl.endsWith('svg')) { lurl.endsWith('gif') || lurl.endsWith('svg')) {
const { __ } = _converse,
uri = new URI(url);
return tpl_image({ return tpl_image({
'url': url, 'url': url,
'label_download': __('Download') 'label_download': __('Download image "%1$s"', decodeURI(uri.filename()))
}) })
} }
return url; return url;
}; };
u.renderMovieURL = function (_converse, url) { u.renderMovieURL = function (_converse, url) {
const { __ } = _converse;
if (url.endsWith('mp4') || url.endsWith('webm')) { if (url.endsWith('mp4') || url.endsWith('webm')) {
const { __ } = _converse,
uri = new URI(url);
return tpl_video({ return tpl_video({
'url': url, 'url': url,
'label_download': __('Download video file') 'label_download': __('Download video file "%1$s"', decodeURI(uri.filename()))
}) })
} }
return url; return url;
}; };
u.renderAudioURL = function (_converse, url) { u.renderAudioURL = function (_converse, url) {
const { __ } = _converse; if (url.endsWith('mp3') || url.endsWith('m4a') || url.endsWith('ogg')) {
if (url.endsWith('mp3') || url.endsWith('m4a')) { const { __ } = _converse,
uri = new URI(url);
return tpl_audio({ return tpl_audio({
'url': url, 'url': url,
'label_download': __('Download audio file') 'label_download': __('Download audio file "%1$s"', decodeURI(uri.filename()))
}) })
} }
return url; return url;