Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
82239d28
Commit
82239d28
authored
Oct 16, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor file-extension checking into utility functions
parent
0c58cb7c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
45 deletions
+98
-45
CHANGES.md
CHANGES.md
+2
-0
dist/converse.js
dist/converse.js
+51
-18
package-lock.json
package-lock.json
+1
-1
src/utils/core.js
src/utils/core.js
+44
-26
No files found.
CHANGES.md
View file @
82239d28
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
-
Bugfix. Handler not triggered when submitting MUC password form 2nd time
-
Bugfix. Handler not triggered when submitting MUC password form 2nd time
-
Bugfix. MUC features weren't being refreshed when saving the config form
-
Bugfix. MUC features weren't being refreshed when saving the config form
-
Don't show duplicate notification messages
-
Don't show duplicate notification messages
-
New config setting
[
show_images_inline
](
https://conversejs.org/docs/html/configuration.html#show-images-inline
)
-
#537 Render
`xmpp:`
URI as link
-
#537 Render
`xmpp:`
URI as link
-
#1062 Collapse multiple join/leave messages into one
-
#1062 Collapse multiple join/leave messages into one
-
#1063 URLs in the topic / subject are not clickable
-
#1063 URLs in the topic / subject are not clickable
...
@@ -17,6 +18,7 @@
...
@@ -17,6 +18,7 @@
-
#1214 Setting
`allow_contact_requests`
to
`false`
has no effect
-
#1214 Setting
`allow_contact_requests`
to
`false`
has no effect
-
#1221 Avoid creating a headlines box if we don't have anything to show inside it
-
#1221 Avoid creating a headlines box if we don't have anything to show inside it
-
#1222 Adding a bookmark should prefill the room name
-
#1222 Adding a bookmark should prefill the room name
-
#1228 Converse automatically visits links (to try and determine whether they're images to show inline)
## 4.0.2 (2018-10-02)
## 4.0.2 (2018-10-02)
...
...
dist/converse.js
View file @
82239d28
...
@@ -81839,30 +81839,60 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
...
@@ -81839,30 +81839,60 @@ 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);
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('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'
)) {
if (
u.isImageURL(uri) || u.isVideoURL(uri) || u.isAudioURL(uri
)) {
return url;
return url;
}
}
const __ = _converse.__;
const __ = _converse.__,
filename = uri.filename();
return tpl_file({
return tpl_file({
'url': url,
'url': url,
'label_download': __('Download file "%1$s"', decodeURI(filename))
'label_download': __('Download file "%1$s"', decodeURI(filename))
});
});
};
};
u.isAudioURL = function (url) {
if (!(url instanceof URI)) {
url = new URI(url);
}
const filename = url.filename().toLowerCase();
if (!_.includes(["https", "http"], url.protocol().toLowerCase())) {
return false;
}
return filename.endsWith('.ogg') || filename.endsWith('.mp3') || filename.endsWith('.m4a');
};
u.isVideoURL = function (url) {
if (!(url instanceof URI)) {
url = new URI(url);
}
const filename = url.filename().toLowerCase();
if (!_.includes(["https", "http"], url.protocol().toLowerCase())) {
return false;
}
return filename.endsWith('.mp4') || filename.endsWith('.webm');
};
u.isImageURL = function (url) {
u.isImageURL = function (url) {
const uri = new URI(url),
if (!(url instanceof URI)) {
filename = uri.filename().toLowerCase();
url = new URI(url);
}
const filename = url.filename().toLowerCase();
if (!_.includes(["https", "http"], ur
i
.protocol().toLowerCase())) {
if (!_.includes(["https", "http"], ur
l
.protocol().toLowerCase())) {
return false;
return false;
}
}
return filename.endsWith('
jpg') || filename.endsWith('jpeg') || filename.endsWith('png') || filename.endsWith('gif') || filename.endsWith('
svg');
return filename.endsWith('
.jpg') || filename.endsWith('.jpeg') || filename.endsWith('.png') || filename.endsWith('.gif') || filename.endsWith('.bmp') || filename.endsWith('.tiff') || filename.endsWith('.
svg');
};
};
u.renderImageURL = function (_converse, url) {
u.renderImageURL = function (_converse, url) {
...
@@ -81870,9 +81900,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
...
@@ -81870,9 +81900,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return u.addHyperlinks(url);
return u.addHyperlinks(url);
}
}
if (u.isImageURL(url)) {
const uri = new URI(url);
const __ = _converse.__,
uri = new URI(url);
if (u.isImageURL(uri)) {
const __ = _converse.__;
return tpl_image({
return tpl_image({
'url': url,
'url': url,
'label_download': __('Download image "%1$s"', decodeURI(uri.filename()))
'label_download': __('Download image "%1$s"', decodeURI(uri.filename()))
...
@@ -81883,9 +81914,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
...
@@ -81883,9 +81914,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
};
};
u.renderMovieURL = function (_converse, url) {
u.renderMovieURL = function (_converse, url) {
if (url.endsWith('mp4') || url.endsWith('webm')) {
const uri = new URI(url);
const __ = _converse.__,
uri = new URI(url);
if (u.isVideoURL(uri)) {
const __ = _converse.__;
return tpl_video({
return tpl_video({
'url': url,
'url': url,
'label_download': __('Download video file "%1$s"', decodeURI(uri.filename()))
'label_download': __('Download video file "%1$s"', decodeURI(uri.filename()))
...
@@ -81896,9 +81928,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
...
@@ -81896,9 +81928,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
};
};
u.renderAudioURL = function (_converse, url) {
u.renderAudioURL = function (_converse, url) {
if (url.endsWith('mp3') || url.endsWith('m4a') || url.endsWith('ogg')) {
const uri = new URI(url);
const __ = _converse.__,
uri = new URI(url);
if (u.isAudioURL(uri)) {
const __ = _converse.__;
return tpl_audio({
return tpl_audio({
'url': url,
'url': url,
'label_download': __('Download audio file "%1$s"', decodeURI(uri.filename()))
'label_download': __('Download audio file "%1$s"', decodeURI(uri.filename()))
package-lock.json
View file @
82239d28
...
@@ -2252,7 +2252,7 @@
...
@@ -2252,7 +2252,7 @@
}
}
},
},
"backbone.browserStorage"
:
{
"backbone.browserStorage"
:
{
"version"
:
"github:jcbrand/Backbone.browserStorage#7
079bf7bf9a43474da1d48e31e3cda6c4a716382
"
,
"version"
:
"github:jcbrand/Backbone.browserStorage#7
8e4a58f7cee10cad6af4fd5f3213331a396aa5a
"
,
"dev"
:
true
,
"dev"
:
true
,
"requires"
:
{
"requires"
:
{
"backbone"
:
"1.3.3"
,
"backbone"
:
"1.3.3"
,
...
...
src/utils/core.js
View file @
82239d28
...
@@ -318,43 +318,61 @@
...
@@ -318,43 +318,61 @@
};
};
u
.
renderFileURL
=
function
(
_converse
,
url
)
{
u
.
renderFileURL
=
function
(
_converse
,
url
)
{
const
uri
=
new
URI
(
url
),
const
uri
=
new
URI
(
url
);
filename
=
uri
.
filename
(),
if
(
u
.
isImageURL
(
uri
)
||
u
.
isVideoURL
(
uri
)
||
u
.
isAudioURL
(
uri
))
{
lower_filename
=
filename
.
toLowerCase
();
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
;
const
{
__
}
=
_converse
,
filename
=
uri
.
filename
();
return
tpl_file
({
return
tpl_file
({
'
url
'
:
url
,
'
url
'
:
url
,
'
label_download
'
:
__
(
'
Download file "%1$s"
'
,
decodeURI
(
filename
))
'
label_download
'
:
__
(
'
Download file "%1$s"
'
,
decodeURI
(
filename
))
})
})
};
};
u
.
isAudioURL
=
function
(
url
)
{
if
(
!
(
url
instanceof
URI
))
{
url
=
new
URI
(
url
);
}
const
filename
=
url
.
filename
().
toLowerCase
();
if
(
!
_
.
includes
([
"
https
"
,
"
http
"
],
url
.
protocol
().
toLowerCase
()))
{
return
false
;
}
return
filename
.
endsWith
(
'
.ogg
'
)
||
filename
.
endsWith
(
'
.mp3
'
)
||
filename
.
endsWith
(
'
.m4a
'
);
}
u
.
isVideoURL
=
function
(
url
)
{
if
(
!
(
url
instanceof
URI
))
{
url
=
new
URI
(
url
);
}
const
filename
=
url
.
filename
().
toLowerCase
();
if
(
!
_
.
includes
([
"
https
"
,
"
http
"
],
url
.
protocol
().
toLowerCase
()))
{
return
false
;
}
return
filename
.
endsWith
(
'
.mp4
'
)
||
filename
.
endsWith
(
'
.webm
'
);
}
u
.
isImageURL
=
function
(
url
)
{
u
.
isImageURL
=
function
(
url
)
{
const
uri
=
new
URI
(
url
),
if
(
!
(
url
instanceof
URI
))
{
filename
=
uri
.
filename
().
toLowerCase
();
url
=
new
URI
(
url
);
if
(
!
_
.
includes
([
"
https
"
,
"
http
"
],
uri
.
protocol
().
toLowerCase
()))
{
}
const
filename
=
url
.
filename
().
toLowerCase
();
if
(
!
_
.
includes
([
"
https
"
,
"
http
"
],
url
.
protocol
().
toLowerCase
()))
{
return
false
;
return
false
;
}
}
return
filename
.
endsWith
(
'
jpg
'
)
||
filename
.
endsWith
(
'
jpeg
'
)
||
return
filename
.
endsWith
(
'
.jpg
'
)
||
filename
.
endsWith
(
'
.jpeg
'
)
||
filename
.
endsWith
(
'
png
'
)
||
filename
.
endsWith
(
'
gif
'
)
||
filename
.
endsWith
(
'
.png
'
)
||
filename
.
endsWith
(
'
.gif
'
)
||
filename
.
endsWith
(
'
svg
'
);
filename
.
endsWith
(
'
.bmp
'
)
||
filename
.
endsWith
(
'
.tiff
'
)
||
filename
.
endsWith
(
'
.svg
'
);
};
};
u
.
renderImageURL
=
function
(
_converse
,
url
)
{
u
.
renderImageURL
=
function
(
_converse
,
url
)
{
if
(
!
_converse
.
show_images_inline
)
{
if
(
!
_converse
.
show_images_inline
)
{
return
u
.
addHyperlinks
(
url
);
return
u
.
addHyperlinks
(
url
);
}
}
if
(
u
.
isImageURL
(
url
))
{
const
uri
=
new
URI
(
url
);
const
{
__
}
=
_converse
,
if
(
u
.
isImageURL
(
uri
))
{
uri
=
new
URI
(
url
)
;
const
{
__
}
=
_converse
;
return
tpl_image
({
return
tpl_image
({
'
url
'
:
url
,
'
url
'
:
url
,
'
label_download
'
:
__
(
'
Download image "%1$s"
'
,
decodeURI
(
uri
.
filename
()))
'
label_download
'
:
__
(
'
Download image "%1$s"
'
,
decodeURI
(
uri
.
filename
()))
...
@@ -364,9 +382,9 @@
...
@@ -364,9 +382,9 @@
};
};
u
.
renderMovieURL
=
function
(
_converse
,
url
)
{
u
.
renderMovieURL
=
function
(
_converse
,
url
)
{
if
(
url
.
endsWith
(
'
mp4
'
)
||
url
.
endsWith
(
'
webm
'
))
{
const
uri
=
new
URI
(
url
);
const
{
__
}
=
_converse
,
if
(
u
.
isVideoURL
(
uri
))
{
uri
=
new
URI
(
url
)
;
const
{
__
}
=
_converse
;
return
tpl_video
({
return
tpl_video
({
'
url
'
:
url
,
'
url
'
:
url
,
'
label_download
'
:
__
(
'
Download video file "%1$s"
'
,
decodeURI
(
uri
.
filename
()))
'
label_download
'
:
__
(
'
Download video file "%1$s"
'
,
decodeURI
(
uri
.
filename
()))
...
@@ -376,9 +394,9 @@
...
@@ -376,9 +394,9 @@
};
};
u
.
renderAudioURL
=
function
(
_converse
,
url
)
{
u
.
renderAudioURL
=
function
(
_converse
,
url
)
{
if
(
url
.
endsWith
(
'
mp3
'
)
||
url
.
endsWith
(
'
m4a
'
)
||
url
.
endsWith
(
'
ogg
'
))
{
const
uri
=
new
URI
(
url
);
const
{
__
}
=
_converse
,
if
(
u
.
isAudioURL
(
uri
))
{
uri
=
new
URI
(
url
)
;
const
{
__
}
=
_converse
;
return
tpl_audio
({
return
tpl_audio
({
'
url
'
:
url
,
'
url
'
:
url
,
'
label_download
'
:
__
(
'
Download audio file "%1$s"
'
,
decodeURI
(
uri
.
filename
()))
'
label_download
'
:
__
(
'
Download audio file "%1$s"
'
,
decodeURI
(
uri
.
filename
()))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment