diff --git a/.meteor/packages b/.meteor/packages index 6e57a4e8a9d..b892c8843a2 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -138,3 +138,4 @@ rocketchat:assets rocketchat:integrations rocketchat:message-attachments rocketchat:api +rocketchat:highlight-words diff --git a/.meteor/versions b/.meteor/versions index b6e876e1351..c95c10d59d1 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -121,6 +121,7 @@ reactive-dict@1.1.3 reactive-var@1.0.6 reload@1.1.4 retry@1.0.4 +rocketchat:highlight-words@0.0.1 rocketchat:api@0.0.1 rocketchat:assets@0.0.1 rocketchat:authorization@0.0.1 diff --git a/packages/rocketchat-highlight-words/client.coffee b/packages/rocketchat-highlight-words/client.coffee new file mode 100644 index 00000000000..ee002a83344 --- /dev/null +++ b/packages/rocketchat-highlight-words/client.coffee @@ -0,0 +1,25 @@ +### +# Hilights is a named function that will process Highlights +# @param {Object} message - The message object +### + +class HighlightWordsClient + constructor: (message) -> + msg = message + + if not _.isString message + if _.trim message.html + msg = message.html + else + return message + + to_highlight = Meteor.user()?.settings?.preferences?['highlights'] + + _.forEach to_highlight, (highlight) -> + if not _.isBlank(highlight) + msg = msg.replace(new RegExp("(#{highlight})", 'gmi'), '$1') + + message.html = msg + return message + +RocketChat.callbacks.add 'renderMessage', HighlightWordsClient \ No newline at end of file diff --git a/packages/rocketchat-highlight-words/package.js b/packages/rocketchat-highlight-words/package.js new file mode 100644 index 00000000000..51c1ed50a60 --- /dev/null +++ b/packages/rocketchat-highlight-words/package.js @@ -0,0 +1,22 @@ +Package.describe({ + name: 'rocketchat:highlight-words', + version: '0.0.1', + // Brief, one-line summary of the package. + summary: '', + // URL to the Git repository containing the source code for this package. + git: '', + // By default, Meteor will default to using README.md for documentation. + // To avoid submitting documentation, set this field to null. + documentation: '' +}); + +Package.onUse(function(api) { + api.versionsFrom('1.2.1'); + + api.use([ + 'coffeescript', + 'rocketchat:lib' + ]); + + api.addFiles('client.coffee', 'client'); +});