Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/candy-chat/candy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Langfeld <ben@langfeld.me>2015-03-27 15:33:46 +0300
committerBen Langfeld <ben@langfeld.me>2015-03-27 15:33:46 +0300
commit563680ee6d27900beb7068fb41cdd4f31b1f9769 (patch)
tree5f8c9fb617f31ccaf2a6e95841b8722f38480085
parent9ad044bed76ab262878682d637cf2f5c7b29ae25 (diff)
parentb9539d1174472134384ef08a221cecf0df1d6506 (diff)
Merge pull request #375 from bklang/dev
Allow option to truncate display of long URLs
-rw-r--r--src/util.js4
-rw-r--r--src/view.js4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/util.js b/src/util.js
index fd866aa..dfcf613 100644
--- a/src/util.js
+++ b/src/util.js
@@ -520,7 +520,9 @@ Candy.Util = (function(self, $){
*/
linkify: function(text) {
text = text.replace(/(^|[^\/])(www\.[^\.]+\.[\S]+(\b|$))/gi, '$1http://$2');
- return text.replace(/(\b(?:(?:https?|ftp|file):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:1\d\d|2[01]\d|22[0-3]|[1-9]\d?)(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?)/gi, '<a href="$1" target="_blank">$1</a>');
+ return text.replace(/(\b(?:(?:https?|ftp|file):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:1\d\d|2[01]\d|22[0-3]|[1-9]\d?)(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?)/gi, function(matched, url) {
+ return '<a href="' + url + '" target="_blank">' + self.crop(url, Candy.View.getOptions().crop.message.url) + '</a>';
+ });
},
/** Function: escape
diff --git a/src/view.js b/src/view.js
index b670302..ade660d 100644
--- a/src/view.js
+++ b/src/view.js
@@ -31,7 +31,7 @@ Candy.View = (function(self, $) {
* (String) language - language to use
* (String) assets - path to assets (res) directory (with trailing slash)
* (Object) messages - limit: clean up message pane when n is reached / remove: remove n messages after limit has been reached
- * (Object) crop - crop if longer than defined: message.nickname=15, message.body=1000, roster.nickname=15
+ * (Object) crop - crop if longer than defined: message.nickname=15, message.body=1000, message.url=undefined (not cropped), roster.nickname=15
* (Bool) enableXHTML - [default: false] enables XHTML messages sending & displaying
*/
_options = {
@@ -39,7 +39,7 @@ Candy.View = (function(self, $) {
assets: 'res/',
messages: { limit: 2000, remove: 500 },
crop: {
- message: { nickname: 15, body: 1000 },
+ message: { nickname: 15, body: 1000, url: undefined },
roster: { nickname: 15 }
},
enableXHTML: false