-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from RocketChat/rocket-packages
- Loading branch information
Showing
21 changed files
with
202 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,5 @@ rocket:file | |
pauli:accounts-linkedin | ||
iframely:oembed | ||
pierreeric:rxfavico | ||
rocket:lib | ||
rocket:me |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@Rocket = (-> | ||
@RocketChat = (-> | ||
|
||
|
||
@Login = (-> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"deploy": { | ||
"production": { | ||
"user": "root", | ||
"host": ["rocket.chat"], | ||
"ref": "origin/master", | ||
"repo": "https://github.com/RocketChat/Rocket.Chat.git", | ||
"path": "/var/www/rocket.chat", | ||
"post-deploy": "source build.sh production" | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# https://github.com/TelescopeJS/Telescope/blob/master/packages/telescope-lib/lib/callbacks.js | ||
|
||
### | ||
# Callback hooks provide an easy way to add extra steps to common operations. | ||
# @namespace RocketChat.callbacks | ||
### | ||
RocketChat.callbacks = {} | ||
|
||
### | ||
# Callback priorities | ||
### | ||
RocketChat.callbacks.priority = | ||
HIGH: -1 | ||
MEDIUM: 0 | ||
LOW: 1 | ||
|
||
### | ||
# Add a callback function to a hook | ||
# @param {String} hook - The name of the hook | ||
# @param {Function} callback - The callback function | ||
### | ||
|
||
RocketChat.callbacks.add = (hook, callback, priority) -> | ||
# if callback array doesn't exist yet, initialize it | ||
priority ?= RocketChat.callbacks.priority.MEDIUM | ||
unless _.isNumber priority | ||
priority = RocketChat.callbacks.priority.MEDIUM | ||
callback.priority = priority | ||
RocketChat.callbacks[hook] ?= [] | ||
RocketChat.callbacks[hook].push callback | ||
return | ||
|
||
### | ||
# Remove a callback from a hook | ||
# @param {string} hook - The name of the hook | ||
# @param {string} functionName - The name of the function to remove | ||
### | ||
|
||
RocketChat.callbacks.remove = (hookName, callbackName) -> | ||
RocketChat.callbacks[hookName] = _.reject RocketChat.callbacks[hookName], (callback) -> | ||
callback.name is callbackName | ||
return | ||
|
||
### | ||
# Successively run all of a hook's callbacks on an item | ||
# @param {String} hook - The name of the hook | ||
# @param {Object} item - The post, comment, modifier, etc. on which to run the callbacks | ||
# @param {Object} [constant] - An optional constant that will be passed along to each callback | ||
# @returns {Object} Returns the item after it's been through all the callbacks for this hook | ||
### | ||
|
||
RocketChat.callbacks.run = (hook, item, constant) -> | ||
callbacks = RocketChat.callbacks[hook] | ||
if !!callbacks?.length | ||
# if the hook exists, and contains callbacks to run | ||
_.sortBy(callbacks, (callback) -> return callback.priority or RocketChat.callbacks.priority.MEDIUM).reduce (result, callback) -> | ||
# console.log(callback.name); | ||
callback result, constant | ||
, item | ||
else | ||
# else, just return the item unchanged | ||
item | ||
|
||
### | ||
# Successively run all of a hook's callbacks on an item, in async mode (only works on server) | ||
# @param {String} hook - The name of the hook | ||
# @param {Object} item - The post, comment, modifier, etc. on which to run the callbacks | ||
# @param {Object} [constant] - An optional constant that will be passed along to each callback | ||
### | ||
|
||
RocketChat.callbacks.runAsync = (hook, item, constant) -> | ||
callbacks = RocketChat.callbacks[hook] | ||
if Meteor.isServer and !!callbacks?.length | ||
# use defer to avoid holding up client | ||
Meteor.defer -> | ||
# run all post submit server callbacks on post object successively | ||
_.sortBy(callbacks, (callback) -> return callback.priority or RocketChat.callbacks.priority.MEDIUM).forEach (callback) -> | ||
# console.log(callback.name); | ||
callback item, constant | ||
return | ||
return | ||
else | ||
return item | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### | ||
# Kick off the global namespace for RocketChat. | ||
# @namespace RocketChat | ||
### | ||
|
||
RocketChat = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This will add underscore.string methods to Underscore.js | ||
# except for include, contains, reverse and join that are | ||
# dropped because they collide with the functions already | ||
# defined by Underscore.js. | ||
_.mixin(s.exports()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Package.describe({ | ||
name: 'rocketchat:lib', | ||
version: '0.0.1', | ||
summary: 'RocketChat libraries', | ||
git: '' | ||
}); | ||
|
||
Package.onUse(function(api) { | ||
api.versionsFrom('1.0'); | ||
|
||
api.use([ | ||
'coffeescript', | ||
'underscore', | ||
'underscorestring:underscore.string' | ||
]); | ||
|
||
api.addFiles('lib/underscore.string.coffee', 'server'); | ||
api.addFiles('lib/core.coffee', 'server'); | ||
api.addFiles('lib/callbacks.coffee', 'server'); | ||
|
||
api.export(['RocketChat'], ['server']); | ||
}); | ||
|
||
Package.onTest(function(api) { | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
### | ||
# Me is a named function that will replace /me commands | ||
# @param {Object} doc - The message object | ||
### | ||
|
||
class Me | ||
constructor: (doc) -> | ||
# If message starts with /me, replace it for text formatting | ||
if doc.message.indexOf('/me') is 0 | ||
doc.message = '######' + Meteor.user().name + doc.message.replace('/me', '') | ||
return doc | ||
|
||
RocketChat.callbacks.add 'sendMessage', Me |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Package.describe({ | ||
name: 'rocketchat:me', | ||
version: '0.0.1', | ||
summary: 'Message pre-processor that will translate /me commands', | ||
git: '' | ||
}); | ||
|
||
Package.onUse(function(api) { | ||
api.versionsFrom('1.0'); | ||
|
||
api.use([ | ||
'coffeescript', | ||
'rocketchat:lib@0.0.1' | ||
]); | ||
|
||
api.addFiles('me.coffee', 'server'); | ||
}); | ||
|
||
Package.onTest(function(api) { | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters