From 23f9ba2fe03a2c3e0f99149dea90072e19c2c3a1 Mon Sep 17 00:00:00 2001 From: Borsh Denis Date: Mon, 3 Apr 2017 02:29:02 +0500 Subject: [PATCH 001/473] add customFields --- server/publications/room.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/publications/room.js b/server/publications/room.js index 068e70c4f08..804311938c5 100644 --- a/server/publications/room.js +++ b/server/publications/room.js @@ -13,6 +13,7 @@ const options = { jitsiTimeout: 1, description: 1, default: 1, + customFields: 1, // @TODO create an API to register this fields based on room type livechatData: 1, From eb34fcf923bc72c6b4e21a980c47a287d2822286 Mon Sep 17 00:00:00 2001 From: AhmetS Date: Fri, 21 Apr 2017 11:08:55 +0100 Subject: [PATCH 002/473] Set User Agent to rocketchatbot In doing so, If we want to share a single page application, we can include requests from `rocketchatbot` in our server rules to redirect to something like prerender.io version of the page or our own pre-rendering server. Example prerender.io config: ``` RewriteCond %{HTTP_USER_AGENT} rocketchatbot|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR] RewriteCond %{QUERY_STRING} _escaped_fragment_ # Only proxy the request to Prerender if it's a request for HTML RewriteRule ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff))(.*) http://service.prerender.io/http://example.com/$2 [P,L] ``` --- packages/rocketchat-oembed/server/server.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rocketchat-oembed/server/server.coffee b/packages/rocketchat-oembed/server/server.coffee index 63ab940c3d5..aad2e125b9e 100644 --- a/packages/rocketchat-oembed/server/server.coffee +++ b/packages/rocketchat-oembed/server/server.coffee @@ -70,7 +70,7 @@ getUrlContent = (urlObj, redirectCount = 5, callback) -> gzip: true maxRedirects: redirectCount headers: - 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36' + 'User-Agent': 'rocketchatbot' headers = null statusCode = null From 231cdaa26ca203d1c4ea4ac2623626a744939635 Mon Sep 17 00:00:00 2001 From: Qi Yin Date: Fri, 26 May 2017 17:35:52 +0800 Subject: [PATCH 003/473] add server methods getRoomNameById --- server/methods/getRoomNameById.js | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 server/methods/getRoomNameById.js diff --git a/server/methods/getRoomNameById.js b/server/methods/getRoomNameById.js new file mode 100644 index 00000000000..1228eda8327 --- /dev/null +++ b/server/methods/getRoomNameById.js @@ -0,0 +1,32 @@ +Meteor.methods({ + getRoomNameById(rid) { + check(rid, String); + + if (!Meteor.userId()) { + throw new Meteor.Error('error-invalid-user', 'Invalid user', { + method: 'getRoomNameById' + }); + } + + const room = RocketChat.models.Rooms.findOneById(rid); + + if (room == null) { + throw new Meteor.Error('error-not-allowed', 'Not allowed', { + method: 'getRoomNameById' + }); + } + + const user = Meteor.user(); + if (user && user.username && room.usernames.indexOf(user.username) !== -1) { + return room.name; + } + + if (room.t !== 'c' || RocketChat.authz.hasPermission(Meteor.userId(), 'view-c-room') !== true) { + throw new Meteor.Error('error-not-allowed', 'Not allowed', { + method: 'getRoomNameById' + }); + } + + return room.name; + } +}); From 8e5fd7f99e167c6d8aa92917a7926b75506487c0 Mon Sep 17 00:00:00 2001 From: Karl Prieb Date: Wed, 31 May 2017 16:10:25 -0300 Subject: [PATCH 004/473] add new variables to db --- packages/rocketchat-theme/server/server.js | 9 ++-- packages/rocketchat-theme/server/variables.js | 50 +++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/packages/rocketchat-theme/server/server.js b/packages/rocketchat-theme/server/server.js index 16b254185f6..2c29415c57d 100644 --- a/packages/rocketchat-theme/server/server.js +++ b/packages/rocketchat-theme/server/server.js @@ -117,7 +117,7 @@ RocketChat.theme = new class { }); } - addVariable(type, name, value, section, persist = true, editor, allowedTypes) { + addVariable(type, name, value, section, persist = true, editor, allowedTypes, property) { this.variables[name] = { type, value @@ -129,15 +129,16 @@ RocketChat.theme = new class { editor: editor || type, section, 'public': false, - allowedTypes + allowedTypes, + property }; return RocketChat.settings.add(`theme-${ type }-${ name }`, value, config); } } - addPublicColor(name, value, section, editor = 'color') { - return this.addVariable('color', name, value, section, true, editor, ['color', 'expression']); + addPublicColor(name, value, section, editor = 'color', property) { + return this.addVariable('color', name, value, section, true, editor, ['color', 'expression'], property); } addPublicFont(name, value) { diff --git a/packages/rocketchat-theme/server/variables.js b/packages/rocketchat-theme/server/variables.js index 96c292d83d6..4977435b353 100644 --- a/packages/rocketchat-theme/server/variables.js +++ b/packages/rocketchat-theme/server/variables.js @@ -39,6 +39,56 @@ const minorColors= { 'status-offline': '@transparent-darker' }; +const sidebar = [ + { + class: 'sidebar-background', + property: 'background-color', + value: '#2f343d' + }, + { + class: 'sidebar-content', + property: 'color', + value: '#6c727a' + }, + { + class: 'sidebar-content-active', + property: 'background-color', + value: '#6c727a' + }, + { + class: 'sidebar-content-unread', + property: 'color', + value: '#ffffff' + }, + { + class: 'sidebar-content:hover', + property: 'background-color', + value: '#26282d' + }, + { + class: 'sidebar-category-badge', + property: 'background-color', + value: '#414852' + }, + { + class: 'sidebar-category-badge-content', + property: 'color', + value: '#ffffff' + }, + { + class: 'sidebar-room-badge', + property: 'background-color', + value: '#414852' + }, + { + class: 'sidebar-room-badge-content', + property: 'color', + value: '#ffffff' + } +]; + +sidebar.forEach(setting => RocketChat.theme.addPublicColor(setting.class, setting.value, 'Sidebar', 'color', setting.property)); + // Bulk-add settings for color scheme Object.keys(majorColors).forEach((key) => { From a06c861c58f55f57d92637a902f52e3239cf6615 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Wed, 31 May 2017 18:15:51 -0300 Subject: [PATCH 005/473] render colors --- .meteor/.finished-upgraders | 1 + .meteor/packages | 21 ++++---- .meteor/release | 2 +- .meteor/versions | 47 ++++++++-------- packages/rocketchat-theme/server/server.js | 2 +- .../.npm/package/npm-shrinkwrap.json | 28 +++++----- packages/rocketchat-ui-master/client/main.js | 2 + .../server/dynamic-css.js | 35 ++++++++++++ .../rocketchat-ui-master/server/inject.js | 53 +++---------------- .../server/page-loading.css | 41 ++++++++++++++ 10 files changed, 139 insertions(+), 93 deletions(-) create mode 100644 packages/rocketchat-ui-master/server/dynamic-css.js create mode 100644 packages/rocketchat-ui-master/server/page-loading.css diff --git a/.meteor/.finished-upgraders b/.meteor/.finished-upgraders index a8020370920..2a56593d3f8 100644 --- a/.meteor/.finished-upgraders +++ b/.meteor/.finished-upgraders @@ -15,3 +15,4 @@ notices-for-facebook-graph-api-2 1.4.0-remove-old-dev-bundle-link 1.4.1-add-shell-server-package 1.4.3-split-account-service-packages +1.5-add-dynamic-import-package diff --git a/.meteor/packages b/.meteor/packages index 3c749d04714..b1b91a38037 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -4,17 +4,17 @@ # but you can also edit it by hand. rocketchat:cors -accounts-facebook@1.1.1 -accounts-github@1.2.1 -accounts-google@1.1.2 -accounts-meteor-developer@1.2.1 +accounts-facebook@1.2.0 +accounts-github@1.3.0 +accounts-google@1.2.0 +accounts-meteor-developer@1.3.0 accounts-password@1.3.6 -accounts-twitter@1.2.1 +accounts-twitter@1.3.0 blaze-html-templates check@1.2.5 coffeescript@1.11.1_4 ddp-rate-limiter@1.0.7 -ecmascript@0.7.3 +ecmascript@0.8.0 ejson@1.0.13 email@1.2.1 fastclick@1.0.13 @@ -22,19 +22,19 @@ http@1.2.12 jquery@1.11.10 less@2.7.9 logging@1.1.17 -meteor-base@1.0.4 +meteor-base@1.1.0 mobile-experience@1.0.4 -mongo@1.1.17 +mongo@1.1.18 random@1.0.10 rate-limit@1.0.8 -reactive-dict@1.1.8 +reactive-dict@1.1.9 reactive-var@1.0.11 reload@1.1.11 service-configuration@1.0.11 session@1.1.7 shell-server@0.2.3 spacebars -standard-minifier-js@2.0.0 +standard-minifier-js@2.1.0 tracker@1.1.3 rocketchat:2fa @@ -172,3 +172,4 @@ yasaricli:slugify yasinuslu:blaze-meta deepwell:bootstrap-datepicker2 rocketchat:postcss +dynamic-import diff --git a/.meteor/release b/.meteor/release index fb6f3bc15e2..025f64e7073 100644 --- a/.meteor/release +++ b/.meteor/release @@ -1 +1 @@ -METEOR@1.4.4.2 +METEOR@1.5 diff --git a/.meteor/versions b/.meteor/versions index db53171f666..b4428f44654 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -1,22 +1,22 @@ -accounts-base@1.2.17 -accounts-facebook@1.1.1 -accounts-github@1.2.1 -accounts-google@1.1.2 -accounts-meteor-developer@1.2.1 +accounts-base@1.3.0 +accounts-facebook@1.2.0 +accounts-github@1.3.0 +accounts-google@1.2.0 +accounts-meteor-developer@1.3.0 accounts-oauth@1.1.15 accounts-password@1.3.6 -accounts-twitter@1.2.1 +accounts-twitter@1.3.0 aldeed:simple-schema@1.5.3 allow-deny@1.0.5 autoupdate@1.3.12 -babel-compiler@6.18.2 +babel-compiler@6.19.1 babel-runtime@1.0.1 base64@1.0.10 binary-heap@1.0.10 blaze@2.3.2 blaze-html-templates@1.1.2 blaze-tools@1.0.10 -boilerplate-generator@1.0.11 +boilerplate-generator@1.1.0 caching-compiler@1.1.9 caching-html-compiler@1.1.2 callback-hook@1.0.10 @@ -33,13 +33,16 @@ deepwell:bootstrap-datepicker2@1.3.0 deps@1.0.12 diff-sequence@1.0.7 dispatch:run-as-user@1.1.1 -ecmascript@0.7.3 -ecmascript-runtime@0.3.15 +dynamic-import@0.1.0 +ecmascript@0.8.0 +ecmascript-runtime@0.4.1 +ecmascript-runtime-client@0.4.1 +ecmascript-runtime-server@0.4.1 edgee:slingshot@0.7.1 ejson@1.0.13 email@1.2.1 emojione:emojione@2.2.6 -facebook-oauth@1.3.0 +facebook-oauth@1.3.1 fastclick@1.0.13 francocatena:status@1.5.3 geojson-utils@1.0.10 @@ -69,26 +72,26 @@ konecty:user-presence@1.2.9 launch-screen@1.1.1 less@2.7.9 livedata@1.0.18 -localstorage@1.0.12 +localstorage@1.1.0 logging@1.1.17 matb33:collection-hooks@0.8.4 mdg:validation-error@0.5.1 meteor@1.6.1 -meteor-base@1.0.4 +meteor-base@1.1.0 meteor-developer-oauth@1.2.0 meteorhacks:inject-initial@1.0.4 meteorhacks:meteorx@1.4.1 meteorspark:util@0.2.0 minifier-css@1.2.16 -minifier-js@2.0.0 -minimongo@1.0.23 +minifier-js@2.1.0 +minimongo@1.2.0 mizzao:autocomplete@0.5.1 mizzao:timesync@0.3.4 mobile-experience@1.0.4 mobile-status-bar@1.0.14 -modules@0.8.2 -modules-runtime@0.7.10 -mongo@1.1.17 +modules@0.9.0 +modules-runtime@0.8.0 +mongo@1.1.18 mongo-id@1.0.6 mongo-livedata@1.0.12 mrt:reactive-store@0.0.1 @@ -108,7 +111,7 @@ pauli:linkedin-oauth@1.1.0 peerlibrary:aws-sdk@2.4.9_1 peerlibrary:blocking@0.5.2 percolate:synced-cron@1.3.2 -promise@0.8.8 +promise@0.8.9 raix:eventemitter@0.1.3 raix:eventstate@0.0.4 raix:handlebar-helpers@0.2.5 @@ -116,7 +119,7 @@ raix:push@3.0.3-rc.7 raix:ui-dropped-event@0.0.7 random@1.0.10 rate-limit@1.0.8 -reactive-dict@1.1.8 +reactive-dict@1.1.9 reactive-var@1.0.11 reload@1.1.11 retry@1.0.9 @@ -232,7 +235,7 @@ smoral:sweetalert@1.1.1 spacebars@1.0.15 spacebars-compiler@1.1.2 srp@1.0.10 -standard-minifier-js@2.0.0 +standard-minifier-js@2.1.0 steffo:meteor-accounts-saml@0.0.1 tap:i18n@1.8.2 templating@1.3.2 @@ -248,7 +251,7 @@ ui@1.0.13 underscore@1.0.10 underscorestring:underscore.string@3.3.4 url@1.1.0 -webapp@1.3.15 +webapp@1.3.16 webapp-hashing@1.0.9 yasaricli:slugify@0.0.7 yasinuslu:blaze-meta@0.3.3 diff --git a/packages/rocketchat-theme/server/server.js b/packages/rocketchat-theme/server/server.js index 2c29415c57d..102129dcb42 100644 --- a/packages/rocketchat-theme/server/server.js +++ b/packages/rocketchat-theme/server/server.js @@ -128,7 +128,7 @@ RocketChat.theme = new class { type, editor: editor || type, section, - 'public': false, + 'public': true, allowedTypes, property }; diff --git a/packages/rocketchat-ui-master/.npm/package/npm-shrinkwrap.json b/packages/rocketchat-ui-master/.npm/package/npm-shrinkwrap.json index 7db964c3bb1..6a227016546 100644 --- a/packages/rocketchat-ui-master/.npm/package/npm-shrinkwrap.json +++ b/packages/rocketchat-ui-master/.npm/package/npm-shrinkwrap.json @@ -1,28 +1,28 @@ { "dependencies": { "clipboard": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-1.5.12.tgz", - "from": "clipboard@1.5.12" + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-1.6.1.tgz", + "from": "clipboard@1.6.1" }, "delegate": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.1.0.tgz", - "from": "delegate@>=3.1.0 <4.0.0" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.1.2.tgz", + "from": "delegate@>=3.1.2 <4.0.0" }, "good-listener": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.0.tgz", - "from": "good-listener@>=1.1.6 <2.0.0" + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", + "from": "good-listener@>=1.2.0 <2.0.0" }, "select": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/select/-/select-1.1.0.tgz", - "from": "select@>=1.0.6 <2.0.0" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", + "from": "select@>=1.1.2 <2.0.0" }, "tiny-emitter": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-1.1.0.tgz", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-1.2.0.tgz", "from": "tiny-emitter@>=1.0.0 <2.0.0" } } diff --git a/packages/rocketchat-ui-master/client/main.js b/packages/rocketchat-ui-master/client/main.js index 9e91eea3687..6301a72dde6 100644 --- a/packages/rocketchat-ui-master/client/main.js +++ b/packages/rocketchat-ui-master/client/main.js @@ -1,6 +1,8 @@ /* globals toolbarSearch, menu, isRtl, fireGlobalEvent, CachedChatSubscription */ import Clipboard from 'clipboard'; +RocketChat.settings.collection.find({_id:/theme/}, {fields:{ value: 1 }}).observe({changed: (key) => { console.log(key); }}); + Template.body.onRendered(function() { new Clipboard('.clipboard'); diff --git a/packages/rocketchat-ui-master/server/dynamic-css.js b/packages/rocketchat-ui-master/server/dynamic-css.js new file mode 100644 index 00000000000..16c1ad6b9e7 --- /dev/null +++ b/packages/rocketchat-ui-master/server/dynamic-css.js @@ -0,0 +1,35 @@ +'use strict'; +export default () => { + const debounce = (func, wait, immediate) => { + let timeout; + return function(...args) { + const later = () => { + timeout = null; + !immediate && func.apply(this, args); + }; + const callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + callNow && func.apply(this, args); + }; + }; + + const style = document.createElement('style'); + style.type = 'text/css'; + + DynamicCss = typeof DynamicCss !=='undefined'? DynamicCss : {list:[]}; + + const settingBackground = (setting) => `.${ setting._id }-background { background-color: ${ setting.value }; }`; + const settingColor = (setting) => `.${ setting._id }-color { color: ${ setting.value }; }`; + + const properties = [settingBackground, settingColor]; + const run = list => list.map(setting => properties.map(f => f(setting)).join('')).join(''); + + DynamicCss.run = debounce(() => { + const list = typeof RocketChat !== 'undefined' ? RocketChat.settings.collection.find({_id:/theme/}).fetch() : []; + return style.innerHTML = run(list.length && list || DynamicCss.list); + }, 1000); + + document.head.appendChild(style); + DynamicCss.run(); +}; diff --git a/packages/rocketchat-ui-master/server/inject.js b/packages/rocketchat-ui-master/server/inject.js index 5c022c0ca76..521749ae727 100644 --- a/packages/rocketchat-ui-master/server/inject.js +++ b/packages/rocketchat-ui-master/server/inject.js @@ -1,49 +1,13 @@ /* globals Inject */ +const variables = RocketChat.models.Settings.find({_id:/theme-/}, {fields: { value: 1 }}).fetch(); +Inject.rawHead('dynamic-variables', ``); +Inject.rawHead('dynamic', ``); -Inject.rawHead('page-loading', ` -`); + +// Inject.rawHead('page-loading', ` `); Inject.rawBody('page-loading-div', `
@@ -152,4 +116,3 @@ Meteor.defer(() => { } Inject.rawHead('base', ``); }); - diff --git a/packages/rocketchat-ui-master/server/page-loading.css b/packages/rocketchat-ui-master/server/page-loading.css new file mode 100644 index 00000000000..54a198723b6 --- /dev/null +++ b/packages/rocketchat-ui-master/server/page-loading.css @@ -0,0 +1,41 @@ +.loading-animation { + top: 0; + right: 0; + bottom: 0; + left: 0; + display: flex; + align-items: center; + position: absolute; + justify-content: center; + text-align: center; +} +.loading-animation > div { + width: 10px; + height: 10px; + margin: 2px; + border-radius: 100%; + display: inline-block; + background-color: rgba(255,255,255,0.6); + -webkit-animation: loading-bouncedelay 1.4s infinite ease-in-out both; + animation: loading-bouncedelay 1.4s infinite ease-in-out both; +} +.loading-animation .bounce1 { + -webkit-animation-delay: -0.32s; + animation-delay: -0.32s; +} +.loading-animation .bounce2 { + -webkit-animation-delay: -0.16s; + animation-delay: -0.16s; +} +@-webkit-keyframes loading-bouncedelay { + 0%, + 80%, + 100% { -webkit-transform: scale(0) } + 40% { -webkit-transform: scale(1.0) } +} +@keyframes loading-bouncedelay { + 0%, + 80%, + 100% { transform: scale(0); } + 40% { transform: scale(1.0); } +} From bbd9d856465f94e255985da36843600937d2407b Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Wed, 31 May 2017 19:38:08 -0300 Subject: [PATCH 006/473] fix observer --- packages/rocketchat-ui-master/client/main.js | 2 +- packages/rocketchat-ui-master/server/dynamic-css.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-ui-master/client/main.js b/packages/rocketchat-ui-master/client/main.js index 6301a72dde6..1c7ece111eb 100644 --- a/packages/rocketchat-ui-master/client/main.js +++ b/packages/rocketchat-ui-master/client/main.js @@ -1,7 +1,7 @@ /* globals toolbarSearch, menu, isRtl, fireGlobalEvent, CachedChatSubscription */ import Clipboard from 'clipboard'; -RocketChat.settings.collection.find({_id:/theme/}, {fields:{ value: 1 }}).observe({changed: (key) => { console.log(key); }}); +RocketChat.settings.collection.find({_id:/theme/}, {fields:{ value: 1 }}).observe({changed: () => { DynamicCss.run(); }}); Template.body.onRendered(function() { new Clipboard('.clipboard'); diff --git a/packages/rocketchat-ui-master/server/dynamic-css.js b/packages/rocketchat-ui-master/server/dynamic-css.js index 16c1ad6b9e7..e1ab1a7e60e 100644 --- a/packages/rocketchat-ui-master/server/dynamic-css.js +++ b/packages/rocketchat-ui-master/server/dynamic-css.js @@ -16,6 +16,7 @@ export default () => { const style = document.createElement('style'); style.type = 'text/css'; + style.id = 'rocketchat-dynamic-css'; DynamicCss = typeof DynamicCss !=='undefined'? DynamicCss : {list:[]}; From 98a5e80b2cef1c838f12d33b7870b7157c0ca7db Mon Sep 17 00:00:00 2001 From: Karl Prieb Date: Thu, 1 Jun 2017 10:02:25 -0300 Subject: [PATCH 007/473] . --- .../rocketchat-lib/client/lib/settings.js | 9 +-- .../rocketchat-lib/server/startup/settings.js | 70 ++++++++++--------- packages/rocketchat-theme/server/server.js | 13 ++++ packages/rocketchat-theme/server/variables.js | 6 +- packages/rocketchat-ui-master/client/main.js | 4 +- .../server/dynamic-css.js | 11 +-- .../rocketchat-ui-master/server/inject.js | 2 +- 7 files changed, 67 insertions(+), 48 deletions(-) diff --git a/packages/rocketchat-lib/client/lib/settings.js b/packages/rocketchat-lib/client/lib/settings.js index 0f0c946ecd8..76ba9cba5eb 100644 --- a/packages/rocketchat-lib/client/lib/settings.js +++ b/packages/rocketchat-lib/client/lib/settings.js @@ -28,20 +28,21 @@ RocketChat.settings.init = function() { added(record) { Meteor.settings[record._id] = record.value; RocketChat.settings.dict.set(record._id, record.value); - return RocketChat.settings.load(record._id, record.value, initialLoad); + RocketChat.settings.load(record._id, record.value, initialLoad); }, changed(record) { + console.log('changed', record); Meteor.settings[record._id] = record.value; RocketChat.settings.dict.set(record._id, record.value); - return RocketChat.settings.load(record._id, record.value, initialLoad); + RocketChat.settings.load(record._id, record.value, initialLoad); }, removed(record) { delete Meteor.settings[record._id]; RocketChat.settings.dict.set(record._id, null); - return RocketChat.settings.load(record._id, null, initialLoad); + RocketChat.settings.load(record._id, null, initialLoad); } }); - return initialLoad = false; + initialLoad = false; }; RocketChat.settings.init(); diff --git a/packages/rocketchat-lib/server/startup/settings.js b/packages/rocketchat-lib/server/startup/settings.js index e62787932de..02b73ae93bf 100644 --- a/packages/rocketchat-lib/server/startup/settings.js +++ b/packages/rocketchat-lib/server/startup/settings.js @@ -188,7 +188,7 @@ RocketChat.settings.addGroup('Accounts', function() { value: 'FileSystem' } }); - return this.add('Accounts_SetDefaultAvatar', true, { + this.add('Accounts_SetDefaultAvatar', true, { type: 'boolean' }); }); @@ -212,7 +212,7 @@ RocketChat.settings.addGroup('OAuth', function() { type: 'string', enableQuery }); - return this.add('Accounts_OAuth_Facebook_callback_url', '_oauth/facebook', { + this.add('Accounts_OAuth_Facebook_callback_url', '_oauth/facebook', { type: 'relativeUrl', readonly: true, force: true, @@ -236,7 +236,7 @@ RocketChat.settings.addGroup('OAuth', function() { type: 'string', enableQuery }); - return this.add('Accounts_OAuth_Google_callback_url', '_oauth/google', { + this.add('Accounts_OAuth_Google_callback_url', '_oauth/google', { type: 'relativeUrl', readonly: true, force: true, @@ -260,7 +260,7 @@ RocketChat.settings.addGroup('OAuth', function() { type: 'string', enableQuery }); - return this.add('Accounts_OAuth_Github_callback_url', '_oauth/github', { + this.add('Accounts_OAuth_Github_callback_url', '_oauth/github', { type: 'relativeUrl', readonly: true, force: true, @@ -284,7 +284,7 @@ RocketChat.settings.addGroup('OAuth', function() { type: 'string', enableQuery }); - return this.add('Accounts_OAuth_Linkedin_callback_url', '_oauth/linkedin', { + this.add('Accounts_OAuth_Linkedin_callback_url', '_oauth/linkedin', { type: 'relativeUrl', readonly: true, force: true, @@ -308,7 +308,7 @@ RocketChat.settings.addGroup('OAuth', function() { type: 'string', enableQuery }); - return this.add('Accounts_OAuth_Meteor_callback_url', '_oauth/meteor', { + this.add('Accounts_OAuth_Meteor_callback_url', '_oauth/meteor', { type: 'relativeUrl', readonly: true, force: true, @@ -332,19 +332,19 @@ RocketChat.settings.addGroup('OAuth', function() { type: 'string', enableQuery }); - return this.add('Accounts_OAuth_Twitter_callback_url', '_oauth/twitter', { + this.add('Accounts_OAuth_Twitter_callback_url', '_oauth/twitter', { type: 'relativeUrl', readonly: true, force: true, enableQuery }); }); - return this.section('Proxy', function() { + this.section('Proxy', function() { this.add('Accounts_OAuth_Proxy_host', 'https://oauth-proxy.rocket.chat', { type: 'string', 'public': true }); - return this.add('Accounts_OAuth_Proxy_services', '', { + this.add('Accounts_OAuth_Proxy_services', '', { type: 'string', 'public': true }); @@ -402,25 +402,25 @@ RocketChat.settings.addGroup('General', function() { 'public': true, i18nDescription: 'UTF8_Names_Validation_Description' }); - return this.add('UTF8_Names_Slugify', true, { + this.add('UTF8_Names_Slugify', true, { type: 'boolean', 'public': true }); }); this.section('Reporting', function() { - return this.add('Statistics_reporting', true, { + this.add('Statistics_reporting', true, { type: 'boolean' }); }); this.section('Notifications', function() { - return this.add('Desktop_Notifications_Duration', 0, { + this.add('Desktop_Notifications_Duration', 0, { type: 'int', 'public': true, i18nDescription: 'Desktop_Notification_Durations_Description' }); }); this.section('REST API', function() { - return this.add('API_User_Limit', 500, { + this.add('API_User_Limit', 500, { type: 'int', 'public': true, i18nDescription: 'API_User_Limit' @@ -443,7 +443,7 @@ RocketChat.settings.addGroup('General', function() { type: 'boolean', 'public': true }); - return this.add('Iframe_Integration_receive_origin', '*', { + this.add('Iframe_Integration_receive_origin', '*', { type: 'string', 'public': true, enableQuery: { @@ -453,13 +453,13 @@ RocketChat.settings.addGroup('General', function() { }); }); this.section('Translations', function() { - return this.add('Custom_Translations', '', { + this.add('Custom_Translations', '', { type: 'code', 'public': true }); }); - return this.section('Stream_Cast', function() { - return this.add('Stream_Cast_Address', '', { + this.section('Stream_Cast', function() { + this.add('Stream_Cast_Address', '', { type: 'string' }); }); @@ -473,7 +473,7 @@ RocketChat.settings.addGroup('Email', function() { multiline: true, i18nLabel: 'Header' }); - return this.add('Email_Footer', 'Powered by Rocket.Chat', { + this.add('Email_Footer', 'Powered by Rocket.Chat', { type: 'code', code: 'text/html', multiline: true, @@ -533,7 +533,7 @@ RocketChat.settings.addGroup('Email', function() { type: 'string', placeholder: 'email@domain' }); - return this.add('SMTP_Test_Button', 'sendSMTPTestEmail', { + this.add('SMTP_Test_Button', 'sendSMTPTestEmail', { type: 'action', actionText: 'Send_a_test_mail_to_my_user' }); @@ -555,7 +555,7 @@ RocketChat.settings.addGroup('Email', function() { value: false } }); - return this.add('Invitation_HTML', '', { + this.add('Invitation_HTML', '', { type: 'code', code: 'text/html', multiline: true, @@ -588,7 +588,7 @@ RocketChat.settings.addGroup('Email', function() { value: false } }); - return this.add('Accounts_Enrollment_Email', '', { + this.add('Accounts_Enrollment_Email', '', { type: 'code', code: 'text/html', multiline: true, @@ -620,7 +620,7 @@ RocketChat.settings.addGroup('Email', function() { value: false } }); - return this.add('Accounts_UserAddedEmail', '', { + this.add('Accounts_UserAddedEmail', '', { type: 'code', code: 'text/html', multiline: true, @@ -653,7 +653,7 @@ RocketChat.settings.addGroup('Email', function() { value: false } }); - return this.add('Forgot_Password_Email', '', { + this.add('Forgot_Password_Email', '', { type: 'code', code: 'text/html', multiline: true, @@ -669,7 +669,7 @@ RocketChat.settings.addGroup('Email', function() { } }); }); - return this.section('Verification', function() { + this.section('Verification', function() { this.add('Verification_Customized', false, { type: 'boolean', i18nLabel: 'Custom' @@ -686,7 +686,7 @@ RocketChat.settings.addGroup('Email', function() { value: false } }); - return this.add('Verification_Email', '', { + this.add('Verification_Email', '', { type: 'code', code: 'text/html', multiline: true, @@ -840,7 +840,7 @@ RocketChat.settings.addGroup('Message', function() { type: 'boolean', 'public': true }); - return this.add('Message_HideType_mute_unmute', false, { + this.add('Message_HideType_mute_unmute', false, { type: 'boolean', 'public': true }); @@ -862,7 +862,7 @@ RocketChat.settings.addGroup('Meta', function() { this.add('Meta_msvalidate01', '', { type: 'string' }); - return this.add('Meta_custom', '', { + this.add('Meta_custom', '', { type: 'code', code: 'text/html', multiline: true @@ -948,23 +948,25 @@ RocketChat.settings.addGroup('Push', function() { this.add('Push_gcm_api_key', '', { type: 'string' }); - return this.add('Push_gcm_project_number', '', { + this.add('Push_gcm_project_number', '', { type: 'string', 'public': true }); }); - return this.section('Privacy', function() { + this.section('Privacy', function() { this.add('Push_show_username_room', true, { type: 'boolean', 'public': true }); - return this.add('Push_show_message', true, { + this.add('Push_show_message', true, { type: 'boolean', 'public': true }); }); }); +RocketChat.settings.addGroup('Colors'); + RocketChat.settings.addGroup('Layout', function() { this.section('Content', function() { this.add('Layout_Home_Title', 'Home', { @@ -994,7 +996,7 @@ RocketChat.settings.addGroup('Layout', function() { multiline: true, 'public': true }); - return this.add('Layout_Sidenav_Footer', '', { + this.add('Layout_Sidenav_Footer', '', { type: 'code', code: 'text/html', 'public': true, @@ -1007,13 +1009,13 @@ RocketChat.settings.addGroup('Layout', function() { multiline: true, 'public': true }); - return this.add('Custom_Script_Logged_In', '//Add your script', { + this.add('Custom_Script_Logged_In', '//Add your script', { type: 'code', multiline: true, 'public': true }); }); - return this.section('User_Interface', function() { + this.section('User_Interface', function() { this.add('UI_DisplayRoles', true, { type: 'boolean', 'public': true @@ -1058,7 +1060,7 @@ RocketChat.settings.addGroup('Logs', function() { type: 'boolean', 'public': true }); - return this.add('Log_View_Limit', 1000, { + this.add('Log_View_Limit', 1000, { type: 'int' }); }); diff --git a/packages/rocketchat-theme/server/server.js b/packages/rocketchat-theme/server/server.js index 102129dcb42..04018ed14f3 100644 --- a/packages/rocketchat-theme/server/server.js +++ b/packages/rocketchat-theme/server/server.js @@ -117,6 +117,19 @@ RocketChat.theme = new class { }); } + addColor(name, value, section, property) { + const config = { + group: 'Colors', + type: 'color', + editor: 'color', + public: true, + property, + section + }; + + return RocketChat.settings.add(`theme-color-${ name }`, value, config); + } + addVariable(type, name, value, section, persist = true, editor, allowedTypes, property) { this.variables[name] = { type, diff --git a/packages/rocketchat-theme/server/variables.js b/packages/rocketchat-theme/server/variables.js index 4977435b353..e6d46be05bf 100644 --- a/packages/rocketchat-theme/server/variables.js +++ b/packages/rocketchat-theme/server/variables.js @@ -87,7 +87,7 @@ const sidebar = [ } ]; -sidebar.forEach(setting => RocketChat.theme.addPublicColor(setting.class, setting.value, 'Sidebar', 'color', setting.property)); +sidebar.forEach(setting => RocketChat.theme.addColor(setting.class, setting.value, 'Sidebar', setting.property)); // Bulk-add settings for color scheme @@ -106,8 +106,8 @@ RocketChat.theme.addPublicFont('body-font-family', '-apple-system, BlinkMacSyste RocketChat.settings.add('theme-custom-css', '', { group: 'Layout', type: 'code', - code: 'text/x-less', + code: 'text/css', multiline: true, section: 'Custom CSS', - public: false + public: true }); diff --git a/packages/rocketchat-ui-master/client/main.js b/packages/rocketchat-ui-master/client/main.js index 1c7ece111eb..fde1a82aaee 100644 --- a/packages/rocketchat-ui-master/client/main.js +++ b/packages/rocketchat-ui-master/client/main.js @@ -1,7 +1,7 @@ -/* globals toolbarSearch, menu, isRtl, fireGlobalEvent, CachedChatSubscription */ +/* globals toolbarSearch, menu, isRtl, fireGlobalEvent, CachedChatSubscription, DynamicCss */ import Clipboard from 'clipboard'; -RocketChat.settings.collection.find({_id:/theme/}, {fields:{ value: 1 }}).observe({changed: () => { DynamicCss.run(); }}); +RocketChat.settings.collection.find({_id:/theme/}, {fields:{ value: 1, property: 1, type: 1 }}).observe({changed: () => { DynamicCss.run(); }}); Template.body.onRendered(function() { new Clipboard('.clipboard'); diff --git a/packages/rocketchat-ui-master/server/dynamic-css.js b/packages/rocketchat-ui-master/server/dynamic-css.js index e1ab1a7e60e..4d78f701315 100644 --- a/packages/rocketchat-ui-master/server/dynamic-css.js +++ b/packages/rocketchat-ui-master/server/dynamic-css.js @@ -1,3 +1,5 @@ +/* global DynamicCss */ + 'use strict'; export default () => { const debounce = (func, wait, immediate) => { @@ -20,11 +22,12 @@ export default () => { DynamicCss = typeof DynamicCss !=='undefined'? DynamicCss : {list:[]}; - const settingBackground = (setting) => `.${ setting._id }-background { background-color: ${ setting.value }; }`; - const settingColor = (setting) => `.${ setting._id }-color { color: ${ setting.value }; }`; + const colors = setting => setting._id.indexOf('theme-color') > -1 ? `.${ setting._id.replace('theme-color-', '') }{${ setting.property }:${ setting.value }}` : ''; + const customCss = setting => setting._id.indexOf('theme-custom-css') > -1 ? setting.value : ''; + const fontFamily = setting => setting._id.indexOf('theme-font-body-font-family') > -1 ? `body{${ setting.value }}` : ''; - const properties = [settingBackground, settingColor]; - const run = list => list.map(setting => properties.map(f => f(setting)).join('')).join(''); + const properties = [fontFamily, colors, customCss]; + const run = list => list.filter(setting => setting.value && setting.property || setting.type !== 'color').map(setting => properties.reduce((ret, f) => ret || f(setting), '')).join('\n'); DynamicCss.run = debounce(() => { const list = typeof RocketChat !== 'undefined' ? RocketChat.settings.collection.find({_id:/theme/}).fetch() : []; diff --git a/packages/rocketchat-ui-master/server/inject.js b/packages/rocketchat-ui-master/server/inject.js index 521749ae727..4130a8fa525 100644 --- a/packages/rocketchat-ui-master/server/inject.js +++ b/packages/rocketchat-ui-master/server/inject.js @@ -1,5 +1,5 @@ /* globals Inject */ -const variables = RocketChat.models.Settings.find({_id:/theme-/}, {fields: { value: 1 }}).fetch(); +const variables = RocketChat.models.Settings.find({_id:/theme-/}, {fields: { value: 1, property: 1, type: 1 }}).fetch(); Inject.rawHead('dynamic-variables', ``); -Inject.rawHead('dynamic', ``); +const renderDynamicCssList = () => { + const variables = RocketChat.models.Settings.find({_id:/theme-/}, {fields: { value: 1, property: 1, type: 1 }}).fetch(); + + Inject.rawHead('dynamic-variables', + ``); +}; + +renderDynamicCssList(); +RocketChat.models.Settings.find({_id:/theme-/}, {fields: { value: 1, property: 1, type: 1 }}).observe({ + changed: renderDynamicCssList +}); + +Inject.rawHead('dynamic', ``); -// Inject.rawHead('page-loading', ` `); +Inject.rawHead('page-loading', ``); Inject.rawBody('page-loading-div', `
From 72f3f4611282a252e7448b66cab8bbfe74517682 Mon Sep 17 00:00:00 2001 From: Karl Prieb Date: Thu, 1 Jun 2017 16:04:50 -0300 Subject: [PATCH 010/473] change sidebar background color --- packages/rocketchat-theme/server/colors.less | 4 ---- packages/rocketchat-ui-sidenav/client/accountBox.html | 4 ++-- packages/rocketchat-ui-sidenav/client/sideNav.html | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/rocketchat-theme/server/colors.less b/packages/rocketchat-theme/server/colors.less index 0c191b7c3f1..46cc6acbe6b 100755 --- a/packages/rocketchat-theme/server/colors.less +++ b/packages/rocketchat-theme/server/colors.less @@ -641,10 +641,6 @@ a:hover { background-color: @tertiary-font-color; } - .rooms-list { - background-color: lighten(@primary-background-color, 2.5%); - } - li.active { background-color: @transparent-light !important; } diff --git a/packages/rocketchat-ui-sidenav/client/accountBox.html b/packages/rocketchat-ui-sidenav/client/accountBox.html index f7151a3442a..1d63a7df9de 100644 --- a/packages/rocketchat-ui-sidenav/client/accountBox.html +++ b/packages/rocketchat-ui-sidenav/client/accountBox.html @@ -1,7 +1,7 @@