From 6bd4782ff65773ea72905010bc3c81ccf408c399 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 25 Sep 2018 00:21:17 +0200 Subject: [PATCH] Include filename in download link and embedd ogg audio --- dist/converse.js | 33 +++++++++++++++++---------------- src/templates/audio.html | 2 +- src/templates/video.html | 2 +- src/utils/core.js | 26 ++++++++++++++------------ 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/dist/converse.js b/dist/converse.js index a89e252b0..c54607e16 100644 --- a/dist/converse.js +++ b/dist/converse.js @@ -78364,9 +78364,9 @@ return __p var _ = {escape:__webpack_require__(/*! ./node_modules/lodash/escape.js */ "./node_modules/lodash/escape.js")}; module.exports = function(o) { var __t, __p = '', __e = _.escape; -__p += '\n\n\n' + __e(o.label_download) + @@ -81421,7 +81421,7 @@ module.exports = function(o) { var __t, __p = '', __e = _.escape; __p += '\n\n\n' + __e(o.label_download) + @@ -81729,28 +81729,29 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ u.renderFileURL = function (_converse, url) { const uri = new URI(url), - __ = _converse.__, filename = uri.filename(), 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; } + const __ = _converse.__; return tpl_file({ 'url': url, - 'label_download': __('Download "%1$s"', uri.filename()) + 'label_download': __('Download file "%1$s"', decodeURI(filename)) }); }; u.renderImageURL = function (_converse, url) { - const __ = _converse.__, - lurl = url.toLowerCase(); + const lurl = url.toLowerCase(); 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({ '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) { - const __ = _converse.__; - if (url.endsWith('mp4') || url.endsWith('webm')) { + const __ = _converse.__, + uri = new URI(url); return tpl_video({ '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) { - const __ = _converse.__; - - if (url.endsWith('mp3') || url.endsWith('m4a')) { + if (url.endsWith('mp3') || url.endsWith('m4a') || url.endsWith('ogg')) { + const __ = _converse.__, + uri = new URI(url); return tpl_audio({ 'url': url, - 'label_download': __('Download audio file') + 'label_download': __('Download audio file "%1$s"', decodeURI(uri.filename())) }); } diff --git a/src/templates/audio.html b/src/templates/audio.html index cbba70ba8..504eb8fd4 100644 --- a/src/templates/audio.html +++ b/src/templates/audio.html @@ -1,2 +1,2 @@ - + {{{o.label_download}}} diff --git a/src/templates/video.html b/src/templates/video.html index eac50b89f..696acf519 100644 --- a/src/templates/video.html +++ b/src/templates/video.html @@ -1,2 +1,2 @@ - + {{{o.label_download}}} diff --git a/src/utils/core.js b/src/utils/core.js index 943101ac4..3ca5f4c67 100644 --- a/src/utils/core.js +++ b/src/utils/core.js @@ -307,11 +307,10 @@ u.renderFileURL = function (_converse, url) { const uri = new URI(url), - { __ } = _converse, filename = uri.filename(), lower_filename = filename.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('png') || lower_filename.endsWith('gif') || lower_filename.endsWith('m4a') || lower_filename.endsWith('webm') || @@ -319,44 +318,47 @@ return url; } + const { __ } = _converse; return tpl_file({ 'url': url, - 'label_download': __('Download "%1$s"', uri.filename()) + 'label_download': __('Download file "%1$s"', decodeURI(filename)) }) }; u.renderImageURL = function (_converse, url) { - const { __ } = _converse, - lurl = url.toLowerCase(); - + const lurl = url.toLowerCase(); 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({ 'url': url, - 'label_download': __('Download') + 'label_download': __('Download image "%1$s"', decodeURI(uri.filename())) }) } return url; }; u.renderMovieURL = function (_converse, url) { - const { __ } = _converse; if (url.endsWith('mp4') || url.endsWith('webm')) { + const { __ } = _converse, + uri = new URI(url); return tpl_video({ 'url': url, - 'label_download': __('Download video file') + 'label_download': __('Download video file "%1$s"', decodeURI(uri.filename())) }) } return url; }; u.renderAudioURL = function (_converse, url) { - const { __ } = _converse; - if (url.endsWith('mp3') || url.endsWith('m4a')) { + if (url.endsWith('mp3') || url.endsWith('m4a') || url.endsWith('ogg')) { + const { __ } = _converse, + uri = new URI(url); return tpl_audio({ 'url': url, - 'label_download': __('Download audio file') + 'label_download': __('Download audio file "%1$s"', decodeURI(uri.filename())) }) } return url;