Skip to content

Commit

Permalink
Merge branch 'master' of github.com:RocketChat/Rocket.Chat
Browse files Browse the repository at this point in the history
  • Loading branch information
marceloschmidt committed Oct 14, 2015
2 parents 68b38c8 + a78a7d3 commit b179ad3
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 34 deletions.
4 changes: 3 additions & 1 deletion i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@
"Showing_results" : "<p>Showing <b>%s</b> results</p>",
"Silence" : "Silence",
"since_creation" : "since %s",
"Site_Name" : "Site Name:",
"Site_Name" : "Site Name",
"Site_Url" : "Site URL",
"Site_Url_Description" : "Example: https://chat.domain.com/",
"SAML" : "SAML",
"SMTP" : "SMTP",
"SMTP_Host" : "SMTP Host",
Expand Down
4 changes: 3 additions & 1 deletion i18n/pt.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@
"Showing_results" : "<p>Exibindo <b>%s</b> resultados</p>",
"Silence" : "Silenciar",
"since_creation" : "desde %s",
"Site_Name" : "Nome do Site:",
"Site_Name" : "Nome do Site",
"Site_Url" : "URL do Site",
"Site_Url_Description" : "Exemplo: https://chat.dominio.com.br/",
"SAML" : "SAML",
"SMTP" : "SMTP",
"SMTP_Host" : "Host SMTP",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Package.onUse(function(api) {

// Settings
api.addFiles('settings/lib/rocketchat.coffee');
api.addFiles('settings/lib/onLoadSettings.coffee');

api.addFiles('settings/server/models/Settings.coffee', 'server');
api.addFiles('settings/server/methods.coffee', 'server');
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-lib/settings/client/rocketchat.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ settingsDict = new ReactiveDict('settings')
RocketChat.settings.get = (_id) ->
return settingsDict.get(_id)

RocketChat.settings.load = (key, value) ->
return settingsDict.set key, value
RocketChat.settings.onload '*', (key, value) ->
return settingsDict.set key, value
5 changes: 5 additions & 0 deletions packages/rocketchat-lib/settings/lib/onLoadSettings.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RocketChat.settings.onload 'Site_Url', (key, value, initialLoad) ->
if value?.trim() isnt ''
__meteor_runtime_config__.ROOT_URL = value
if Meteor.absoluteUrl.defaultOptions?.rootUrl?
Meteor.absoluteUrl.defaultOptions.rootUrl = value
42 changes: 28 additions & 14 deletions packages/rocketchat-lib/settings/lib/rocketchat.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,38 @@
# RocketChat.settings holds all packages settings
# @namespace RocketChat.settings
###
RocketChat.settings = {}
RocketChat.settings =
callbacks: {}
ts: new Date

RocketChat.settings.ts = new Date
get: (_id) ->
return Meteor.settings?[_id]

RocketChat.settings.get = (_id) ->
return Meteor.settings?[_id]
set: (_id, value, callback) ->
Meteor.call 'saveSetting', _id, value, callback

RocketChat.settings.set = (_id, value, callback) ->
Meteor.call 'saveSetting', _id, value, callback
batchSet: (settings, callback) ->

RocketChat.settings.batchSet = (settings, callback) ->
# async -> sync
# http://daemon.co.za/2012/04/simple-async-with-only-underscore/

# async -> sync
# http://daemon.co.za/2012/04/simple-async-with-only-underscore/
save = (setting) ->
return (callback) ->
Meteor.call 'saveSetting', setting._id, setting.value, callback

save = (setting) ->
return (callback) ->
Meteor.call 'saveSetting', setting._id, setting.value, callback
actions = _.map settings, (setting) -> save(setting)
_(actions).reduceRight(_.wrap, (err, success) -> return callback err, success)()

actions = _.map settings, (setting) -> save(setting)
_(actions).reduceRight(_.wrap, (err, success) -> return callback err, success)()
load: (key, value, initialLoad) ->
if RocketChat.settings.callbacks[key]?
for callback in RocketChat.settings.callbacks[key]
callback key, value, initialLoad

if RocketChat.settings.callbacks['*']?
for callback in RocketChat.settings.callbacks['*']
callback key, value, initialLoad


onload: (key, callback) ->
RocketChat.settings.callbacks[key] ?= []
RocketChat.settings.callbacks[key].push callback
16 changes: 0 additions & 16 deletions packages/rocketchat-lib/settings/server/methods.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
RocketChat.settings.callbacks = {}

###
# Add a setting
# @param {String} _id
Expand Down Expand Up @@ -60,20 +58,6 @@ RocketChat.settings.addGroup = (_id, options = {}) ->
return RocketChat.models.Settings.upsert { _id: _id }, upsertChanges


RocketChat.settings.load = (key, value, initialLoad) ->
if RocketChat.settings.callbacks[key]?
for callback in RocketChat.settings.callbacks[key]
callback key, value, initialLoad

if RocketChat.settings.callbacks['*']?
for callback in RocketChat.settings.callbacks['*']
callback key, value, initialLoad


RocketChat.settings.onload = (key, callback) ->
RocketChat.settings.callbacks[key] ?= []
RocketChat.settings.callbacks[key].push callback

###
# Remove a setting by id
# @param {String} _id
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-lib/settings/server/startup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ RocketChat.settings.add 'Accounts_OAuth_Twitter_id', '', { type: 'string', group
RocketChat.settings.add 'Accounts_OAuth_Twitter_secret', '', { type: 'string', group: 'Accounts', section: 'Twitter' }

RocketChat.settings.addGroup 'General'
RocketChat.settings.add 'Site_Url', __meteor_runtime_config__?.ROOT_URL, { type: 'string', group: 'General', i18nDescription: 'Site_Url_Description', public: true }
RocketChat.settings.add 'Site_Name', 'Rocket.Chat', { type: 'string', group: 'General', public: true }
RocketChat.settings.add 'Allow_Invalid_SelfSigned_Certs', false, { type: 'boolean', group: 'General' }
RocketChat.settings.add 'Disable_Favorite_Rooms', false, { type: 'boolean', group: 'General' }
Expand Down

0 comments on commit b179ad3

Please sign in to comment.