[NEW] Setting to set a JS/CSS CDN (#11779)

pull/11814/head
Aaron Ogle 7 years ago committed by Diego Sampaio
parent dcdcbfba9e
commit 767b3c9437
  1. 2
      packages/rocketchat-i18n/i18n/en.i18n.json
  2. 12
      packages/rocketchat-lib/server/startup/settings.js
  3. 22
      packages/rocketchat-lib/server/startup/settingsOnLoadCdnPrefix.js

@ -431,6 +431,8 @@
"CAS_version": "CAS Version",
"CAS_version_Description": "Only use a supported CAS version supported by your CAS SSO service.",
"CDN_PREFIX": "CDN Prefix",
"CDN_PREFIX_ALL": "Use CDN Prefix for all assets",
"CDN_JSCSS_PREFIX": "CDN Prefix for JS/CSS",
"Certificates_and_Keys": "Certificates and Keys",
"Change_Room_Type": "Changing the Room Type",
"Changing_email": "Changing email",

@ -754,6 +754,18 @@ RocketChat.settings.addGroup('General', function() {
type: 'string',
public: true,
});
this.add('CDN_PREFIX_ALL', true, {
type: 'boolean',
public: true,
});
this.add('CDN_JSCSS_PREFIX', '', {
type: 'string',
public: true,
enableQuery: {
_id: 'CDN_PREFIX_ALL',
value: false,
},
});
this.add('Force_SSL', false, {
type: 'boolean',
public: true,

@ -5,14 +5,28 @@ function testWebAppInternals(fn) {
typeof WebAppInternals !== 'undefined' && fn(WebAppInternals);
}
RocketChat.settings.onload('CDN_PREFIX', function(key, value) {
if (_.isString(value) && value.trim()) {
const useForAll = RocketChat.settings.get('CDN_PREFIX_ALL');
if (_.isString(value) && value.trim() && useForAll) {
return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(value));
}
});
Meteor.startup(function() {
const value = RocketChat.settings.get('CDN_PREFIX');
if (_.isString(value) && value.trim()) {
RocketChat.settings.onload('CDN_JSCSS_PREFIX', function(key, value) {
const useForAll = RocketChat.settings.get('CDN_PREFIX_ALL');
if (_.isString(value) && value.trim() && !useForAll) {
return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(value));
}
});
Meteor.startup(function() {
const cdnValue = RocketChat.settings.get('CDN_PREFIX');
const useForAll = RocketChat.settings.get('CDN_PREFIX_ALL');
const cdnJsCss = RocketChat.settings.get('CDN_JSCSS_PREFIX');
if (_.isString(cdnValue) && cdnValue.trim()) {
if (useForAll) {
return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(cdnValue));
} else if (_.isString(cdnJsCss) && cdnJsCss.trim()) {
return testWebAppInternals((WebAppInternals) => WebAppInternals.setBundledJsCssPrefix(cdnJsCss));
}
}
});

Loading…
Cancel
Save