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
f88960c5
Commit
f88960c5
authored
Aug 28, 2020
by
Ariel Fuggini
Committed by
JC Brand
Aug 31, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests and documentation
parent
94af11d7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
6 deletions
+21
-6
docs/source/configuration.rst
docs/source/configuration.rst
+7
-0
spec/messages.js
spec/messages.js
+7
-0
src/converse-chatview.js
src/converse-chatview.js
+1
-1
src/templates/directives/body.js
src/templates/directives/body.js
+1
-1
src/utils/html.js
src/utils/html.js
+5
-4
No files found.
docs/source/configuration.rst
View file @
f88960c5
...
...
@@ -907,6 +907,13 @@ and an idle presence according to XEP-0319 is sent.
If the given value is negative or ``0``, this feature is disabled.
image_urls_regex
----------------
Any URLs in a message that matches the regex in this setting will be considered an image and displayed inline.
E.g. ``/^https?:\/\/(?:www.)?(?:imgur\.com\/\w{7})\/?$/i``
jid
---
...
...
spec/messages.js
View file @
f88960c5
...
...
@@ -979,6 +979,13 @@ describe("A Chat Message", function () {
expect
(
view
.
content
.
querySelectorAll
(
'
img
'
).
length
).
toBe
(
4
);
mock
.
sendMessage
(
view
,
message
);
expect
(
view
.
content
.
querySelectorAll
(
'
img
'
).
length
).
toBe
(
4
);
// Configured image URLs are rendered
_converse
.
api
.
settings
.
set
(
'
image_urls_regex
'
,
/^https
?
:
\/\/(?:
www.
)?(?:
imgur
\.
com
\/\w{7})\/?
$/i
);
message
=
'
http://imgur.com/xxxxxxx
'
;
mock
.
sendMessage
(
view
,
message
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-content .chat-image
'
).
length
===
5
,
1000
);
expect
(
view
.
content
.
querySelectorAll
(
'
img
'
).
length
).
toBe
(
5
);
done
();
}));
...
...
src/converse-chatview.js
View file @
f88960c5
...
...
@@ -52,6 +52,7 @@ converse.plugins.add('converse-chatview', {
api
.
settings
.
extend
({
'
auto_focus
'
:
true
,
'
debounced_content_rendering
'
:
true
,
'
image_urls_regex
'
:
null
,
'
message_limit
'
:
0
,
'
muc_hats_from_vcard
'
:
false
,
'
show_images_inline
'
:
true
,
...
...
@@ -67,7 +68,6 @@ converse.plugins.add('converse-chatview', {
'
emoji
'
:
true
,
'
spoiler
'
:
true
},
'
image_urls_regex
'
:
null
});
...
...
src/templates/directives/body.js
View file @
f88960c5
...
...
@@ -120,7 +120,7 @@ function addHyperlinks (text, onImgLoad, onImgClick) {
text
.
addTemplateResult
(
url_obj
.
start
,
url_obj
.
end
,
show_images
&&
(
u
.
isImageURL
(
url_text
)
||
u
.
isWhitelistedImageURL
(
url_text
)
)
?
show_images
&&
u
.
isImageURL
(
url_text
)
?
u
.
convertToImageTag
(
url_text
,
onImgLoad
,
onImgClick
)
:
u
.
convertUrlToHyperlink
(
url_text
),
);
...
...
src/utils/html.js
View file @
f88960c5
...
...
@@ -76,10 +76,11 @@ function checkFileTypes (types, url) {
u
.
isAudioURL
=
url
=>
checkFileTypes
([
'
.ogg
'
,
'
.mp3
'
,
'
.m4a
'
],
url
);
u
.
isVideoURL
=
url
=>
checkFileTypes
([
'
.mp4
'
,
'
.webm
'
],
url
);
u
.
isImageURL
=
url
=>
checkFileTypes
([
'
.jpg
'
,
'
.jpeg
'
,
'
.png
'
,
'
.gif
'
,
'
.bmp
'
,
'
.tiff
'
,
'
.svg
'
],
url
);
u
.
isWhitelistedImageURL
=
url
=>
{
const
regex
=
_converse
.
api
.
settings
.
get
(
'
image_urls_regex
'
);
return
regex
?
regex
.
test
(
url
)
:
false
;
u
.
isImageURL
=
url
=>
{
const
regex
=
api
.
settings
.
get
(
'
image_urls_regex
'
);
return
regex
?
regex
.
test
(
url
)
:
checkFileTypes
([
'
.jpg
'
,
'
.jpeg
'
,
'
.png
'
,
'
.gif
'
,
'
.bmp
'
,
'
.tiff
'
,
'
.svg
'
],
url
);
}
function
getFileName
(
uri
)
{
...
...
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