From 72e0d6f4dceb5aee729cffbd4d36ea9548919125 Mon Sep 17 00:00:00 2001 From: r0p0s3c Date: Mon, 14 Mar 2016 09:01:33 -0400 Subject: [PATCH 1/6] Fixes to package file/versions: - Do not depend on specific version of ostrio:cookies to use newer versions with fixes - Update all packages with latest versions --- .meteor/packages | 2 +- .meteor/versions | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.meteor/packages b/.meteor/packages index a9d0810a1483..d8f18acd013a 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -122,7 +122,7 @@ mrt:reactive-store mystor:device-detection nimble:restivus nooitaf:colors -ostrio:cookies@2.0.1 +ostrio:cookies pauli:accounts-linkedin perak:codemirror percolate:synced-cron diff --git a/.meteor/versions b/.meteor/versions index 6dfb4c60c220..3a1572e53662 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -62,7 +62,7 @@ jparker:gravatar@0.4.1 jquery@1.11.4 kadira:blaze-layout@2.3.0 kadira:flow-router@2.10.1 -kenton:accounts-sandstorm@0.1.8 +kenton:accounts-sandstorm@0.2.2 konecty:autolinker@1.0.3 konecty:change-case@2.3.0 konecty:delayed-task@1.0.0 @@ -89,7 +89,7 @@ meteorspark:util@0.2.0 minifiers@1.1.7 minimongo@1.0.10 mizzao:autocomplete@0.5.1 -mizzao:timesync@0.3.4 +mizzao:timesync@0.3.5 mobile-experience@1.0.1 mobile-status-bar@1.0.6 momentjs:moment@2.12.0 @@ -101,7 +101,7 @@ mrt:moment@2.8.1 mrt:moment-timezone@0.2.1 mrt:reactive-store@0.0.1 mystor:device-detection@0.2.0 -nimble:restivus@0.8.7 +nimble:restivus@0.8.8 nooitaf:colors@0.0.3 npm-bcrypt@0.7.8_2 npm-mongo@1.4.39_1 @@ -110,7 +110,7 @@ oauth1@1.1.5 oauth2@1.1.5 observe-sequence@1.0.7 ordered-dict@1.0.4 -ostrio:cookies@2.0.1 +ostrio:cookies@2.0.2 pauli:accounts-linkedin@1.2.0 pauli:linkedin@1.2.0 peerlibrary:aws-sdk@2.0.17_2 @@ -196,7 +196,7 @@ service-configuration@1.0.5 session@1.1.1 sha@1.0.4 simple:highlight.js@1.2.0 -simple:json-routes@2.0.1 +simple:json-routes@2.1.0 smoral:sweetalert@1.1.1 spacebars@1.0.7 spacebars-compiler@1.0.7 From f2645ce358dfbc032cd4cb1e5d4f0a3eb3d1ec05 Mon Sep 17 00:00:00 2001 From: r0p0s3c Date: Mon, 14 Mar 2016 10:20:52 -0400 Subject: [PATCH 2/6] Misc fixes to allow running from subdirectory rather than root (/) --- .../rocketchat-assets/server/assets.coffee | 2 +- .../server/startup/settings.coffee | 4 +- .../app/client/stylesheets/fontello.css | 12 +++--- .../client/views/mailerUnsubscribe.html | 2 +- .../views/stylesheets/mentionsFlexTab.less | 2 +- .../sharedsecret.coffee | 2 +- .../assets/stylesheets/base.less | 8 ++-- .../assets/stylesheets/fontello.css | 10 ++--- .../assets/stylesheets/utils/_octicons.less | 2 +- .../rocketchat-ui-master/master/error.html | 2 +- .../master/logoLayout.html | 2 +- .../rocketchat-ui-master/master/main.html | 38 +++++++++---------- .../lib/getAvatarUrlFromUsername.coffee | 5 +-- .../views/app/audioNotification.html | 6 +-- packages/rocketchat-ui/views/fxos.html | 8 ++-- server/startup/avatar.coffee | 2 +- 16 files changed, 53 insertions(+), 54 deletions(-) diff --git a/packages/rocketchat-assets/server/assets.coffee b/packages/rocketchat-assets/server/assets.coffee index e08e9f4bf6e3..059013371926 100644 --- a/packages/rocketchat-assets/server/assets.coffee +++ b/packages/rocketchat-assets/server/assets.coffee @@ -18,7 +18,7 @@ assets = height: undefined 'favicon.svg': label: 'favicon.svg' - defaultUrl: '/images/logo/icon.svg?v=3' + defaultUrl: 'images/logo/icon.svg?v=3' constraints: type: 'image' extension: 'svg' diff --git a/packages/rocketchat-lib/server/startup/settings.coffee b/packages/rocketchat-lib/server/startup/settings.coffee index 09e5a6991b55..78a864e62d90 100644 --- a/packages/rocketchat-lib/server/startup/settings.coffee +++ b/packages/rocketchat-lib/server/startup/settings.coffee @@ -158,10 +158,10 @@ RocketChat.settings.addGroup 'Layout', -> @add 'Layout_Home_Body', 'Welcome to Rocket.Chat
Go to APP SETTINGS -> Layout to customize this intro.', { type: 'string', multiline: true, public: true } @add 'Layout_Terms_of_Service', 'Terms of Service
Go to APP SETTINGS -> Layout to customize this page.', { type: 'string', multiline: true, public: true } @add 'Layout_Privacy_Policy', 'Privacy Policy
Go to APP SETTINGS -> Layout to customize this page.', { type: 'string', multiline: true, public: true } - @add 'Layout_Sidenav_Footer', '
with on
', { type: 'string', public: true, i18nDescription: 'Layout_Sidenav_Footer_description' } + @add 'Layout_Sidenav_Footer', '
with on
', { type: 'string', public: true, i18nDescription: 'Layout_Sidenav_Footer_description' } @section 'Login', -> - @add 'Layout_Login_Header', '', { type: 'string', multiline: true, public: true } + @add 'Layout_Login_Header', '', { type: 'string', multiline: true, public: true } @add 'Layout_Login_Terms', 'By proceeding to create your account and use Rocket.Chat, you are agreeing to our Terms of Service and Privacy Policy. If you do not agree, you cannot use Rocket.Chat.', { type: 'string', multiline: true, public: true } diff --git a/packages/rocketchat-livechat/app/client/stylesheets/fontello.css b/packages/rocketchat-livechat/app/client/stylesheets/fontello.css index fc28243c86e7..ee84408162dd 100644 --- a/packages/rocketchat-livechat/app/client/stylesheets/fontello.css +++ b/packages/rocketchat-livechat/app/client/stylesheets/fontello.css @@ -1,10 +1,10 @@ @font-face { font-family: 'fontello'; - src: url('/fonts/fontello.eot?52343198'); - src: url('/fonts/fontello.eot?52343198#iefix') format('embedded-opentype'), - url('/fonts/fontello.woff?52343198') format('woff'), - url('/fonts/fontello.ttf?52343198') format('truetype'), - url('/fonts/fontello.svg?52343198#fontello') format('svg'); + src: url('fonts/fontello.eot?52343198'); + src: url('fonts/fontello.eot?52343198#iefix') format('embedded-opentype'), + url('fonts/fontello.woff?52343198') format('woff'), + url('fonts/fontello.ttf?52343198') format('truetype'), + url('fonts/fontello.svg?52343198#fontello') format('svg'); font-weight: normal; font-style: normal; } @@ -14,7 +14,7 @@ @media screen and (-webkit-min-device-pixel-ratio:0) { @font-face { font-family: 'fontello'; - src: url('/fonts/fontello.svg?52343198#fontello') format('svg'); + src: url('fonts/fontello.svg?52343198#fontello') format('svg'); } } */ diff --git a/packages/rocketchat-mailer/client/views/mailerUnsubscribe.html b/packages/rocketchat-mailer/client/views/mailerUnsubscribe.html index c308fb973f9e..1f2739055cdd 100644 --- a/packages/rocketchat-mailer/client/views/mailerUnsubscribe.html +++ b/packages/rocketchat-mailer/client/views/mailerUnsubscribe.html @@ -3,7 +3,7 @@
diff --git a/packages/rocketchat-mentions-flextab/client/views/stylesheets/mentionsFlexTab.less b/packages/rocketchat-mentions-flextab/client/views/stylesheets/mentionsFlexTab.less index a8956d799c8e..2bdf1593b385 100644 --- a/packages/rocketchat-mentions-flextab/client/views/stylesheets/mentionsFlexTab.less +++ b/packages/rocketchat-mentions-flextab/client/views/stylesheets/mentionsFlexTab.less @@ -1,6 +1,6 @@ .mentioned-messages-list { &.notready { - background-image: url(/images/logo/loading.gif); + background-image: url(images/logo/loading.gif); background-repeat: no-repeat; background-position: 50% 50%; height: 100px; diff --git a/packages/rocketchat-sharedsecret/sharedsecret.coffee b/packages/rocketchat-sharedsecret/sharedsecret.coffee index 19b72c746ad3..d74265ec7411 100644 --- a/packages/rocketchat-sharedsecret/sharedsecret.coffee +++ b/packages/rocketchat-sharedsecret/sharedsecret.coffee @@ -53,7 +53,7 @@ if (Meteor.isClient) message.msg = "~ encrypted message ~" message.html = "~ encrypted message ~" else - lockImage = "/images/lock8.png" + lockImage = "images/lock8.png" message.msg = " " + decrypted message.html = " " + decrypted diff --git a/packages/rocketchat-theme/assets/stylesheets/base.less b/packages/rocketchat-theme/assets/stylesheets/base.less index f40b38d00041..7621aa044380 100644 --- a/packages/rocketchat-theme/assets/stylesheets/base.less +++ b/packages/rocketchat-theme/assets/stylesheets/base.less @@ -556,7 +556,7 @@ textarea[disabled] { &:after { content: " "; visibility: visible; - background-image: url('/images/logo/loading.gif'); + background-image: url('images/logo/loading.gif'); background-position: center; background-repeat: no-repeat; display: block; @@ -604,7 +604,7 @@ label.required:after { } .loading { - background-image: url('/images/loading.gif'); + background-image: url('images/loading.gif'); background-repeat: no-repeat; background-position: 50%; width: 100%; @@ -3892,7 +3892,7 @@ a.github-fork { bottom: 20px; width: 100px; height: 50px; - background: url(/images/meteor.png) no-repeat center center; + background: url(images/meteor.png) no-repeat center center; background-size: 100% auto; text-indent: -9999em; } @@ -4211,7 +4211,7 @@ a.github-fork { .message-popup-results { &.notready { .message-popup-items { - background-image: url(/images/logo/loading.gif); + background-image: url(images/logo/loading.gif); background-repeat: no-repeat; background-position: 50% 50%; height: 100px; diff --git a/packages/rocketchat-theme/assets/stylesheets/fontello.css b/packages/rocketchat-theme/assets/stylesheets/fontello.css index ec23624c697a..394dae670497 100644 --- a/packages/rocketchat-theme/assets/stylesheets/fontello.css +++ b/packages/rocketchat-theme/assets/stylesheets/fontello.css @@ -1,10 +1,10 @@ @font-face { font-family: 'fontello'; - src: url('/fonts/fontello.eot?33681247'); - src: url('/fonts/fontello.eot?33681247#iefix') format('embedded-opentype'), - url('/fonts/fontello.woff?33681247') format('woff'), - url('/fonts/fontello.ttf?33681247') format('truetype'), - url('/fonts/fontello.svg?33681247#fontello') format('svg'); + src: url('fonts/fontello.eot?33681247'); + src: url('fonts/fontello.eot?33681247#iefix') format('embedded-opentype'), + url('fonts/fontello.woff?33681247') format('woff'), + url('fonts/fontello.ttf?33681247') format('truetype'), + url('fonts/fontello.svg?33681247#fontello') format('svg'); font-weight: normal; font-style: normal; } diff --git a/packages/rocketchat-theme/assets/stylesheets/utils/_octicons.less b/packages/rocketchat-theme/assets/stylesheets/utils/_octicons.less index f7b02c4ed545..3f2b38785b55 100644 --- a/packages/rocketchat-theme/assets/stylesheets/utils/_octicons.less +++ b/packages/rocketchat-theme/assets/stylesheets/utils/_octicons.less @@ -1,4 +1,4 @@ -@octicons-font-path: "/fonts/github"; +@octicons-font-path: "fonts/github"; @octicons-version: "396334ee3da78f4302d25c758ae3e3ce5dc3c97d"; @font-face { diff --git a/packages/rocketchat-ui-master/master/error.html b/packages/rocketchat-ui-master/master/error.html index c818e16b9b95..4290413f22fa 100644 --- a/packages/rocketchat-ui-master/master/error.html +++ b/packages/rocketchat-ui-master/master/error.html @@ -3,7 +3,7 @@

{{_ "Not_found_or_not_allowed"}}

diff --git a/packages/rocketchat-ui-master/master/logoLayout.html b/packages/rocketchat-ui-master/master/logoLayout.html index e1228b4a62f9..c7decca4f52c 100644 --- a/packages/rocketchat-ui-master/master/logoLayout.html +++ b/packages/rocketchat-ui-master/master/logoLayout.html @@ -3,7 +3,7 @@
{{> Template.dynamic template=render}} diff --git a/packages/rocketchat-ui-master/master/main.html b/packages/rocketchat-ui-master/master/main.html index 533296138fad..dbb54db5b8e4 100644 --- a/packages/rocketchat-ui-master/master/main.html +++ b/packages/rocketchat-ui-master/master/main.html @@ -9,32 +9,32 @@ - - + + - + - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + + diff --git a/packages/rocketchat-ui/lib/getAvatarUrlFromUsername.coffee b/packages/rocketchat-ui/lib/getAvatarUrlFromUsername.coffee index b913816c52d2..215c6615173d 100644 --- a/packages/rocketchat-ui/lib/getAvatarUrlFromUsername.coffee +++ b/packages/rocketchat-ui/lib/getAvatarUrlFromUsername.coffee @@ -3,9 +3,8 @@ random = Session?.keys[key] or 0 if not username? return - if Meteor.isCordova path = Meteor.absoluteUrl() else - path = '/' - "#{path}avatar/#{encodeURIComponent(username)}.jpg?_dc=#{random}" + path = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX || ''; + "#{path}/avatar/#{encodeURIComponent(username)}.jpg?_dc=#{random}" diff --git a/packages/rocketchat-ui/views/app/audioNotification.html b/packages/rocketchat-ui/views/app/audioNotification.html index 8441e702ddd6..d64d58f1508f 100644 --- a/packages/rocketchat-ui/views/app/audioNotification.html +++ b/packages/rocketchat-ui/views/app/audioNotification.html @@ -1,9 +1,9 @@ diff --git a/packages/rocketchat-ui/views/fxos.html b/packages/rocketchat-ui/views/fxos.html index 34418ad7ddf2..23c767884d16 100644 --- a/packages/rocketchat-ui/views/fxos.html +++ b/packages/rocketchat-ui/views/fxos.html @@ -3,7 +3,7 @@
@@ -19,7 +19,7 @@

{{_ "Install_FxOs"}}

@@ -35,7 +35,7 @@

{{_ "Install_FxOs"}}

@@ -45,4 +45,4 @@

{{_ "Install_FxOs"}}

- \ No newline at end of file + diff --git a/server/startup/avatar.coffee b/server/startup/avatar.coffee index 7392b051e3f4..00ed7f522412 100644 --- a/server/startup/avatar.coffee +++ b/server/startup/avatar.coffee @@ -30,7 +30,7 @@ Meteor.startup -> absolutePath: path transformWrite: transformWrite - WebApp.connectHandlers.use '/avatar/', Meteor.bindEnvironment (req, res, next) -> + WebApp.connectHandlers.use 'avatar/', Meteor.bindEnvironment (req, res, next) -> params = username: decodeURIComponent(req.url.replace(/^\//, '').replace(/\?.*$/, '')) From d6a1e66227a950597f83f55d5e3b7039ac1fbcd5 Mon Sep 17 00:00:00 2001 From: r0p0s3c Date: Mon, 14 Mar 2016 14:42:45 -0400 Subject: [PATCH 3/6] Use absoluteUrl instead of location.origin so ROOT_URL is taken into account --- packages/rocketchat-lib/client/lib/settings.coffee | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/rocketchat-lib/client/lib/settings.coffee b/packages/rocketchat-lib/client/lib/settings.coffee index 7a19eb1d3fb3..b0d9e95c7633 100644 --- a/packages/rocketchat-lib/client/lib/settings.coffee +++ b/packages/rocketchat-lib/client/lib/settings.coffee @@ -41,12 +41,11 @@ Meteor.startup -> if RocketChat.authz.hasRole(Meteor.userId(), 'admin') is false or Meteor.settings.public.sandstorm return c.stop() - siteUrl = siteUrl.replace /\/$/, '' - if siteUrl isnt location.origin + if siteUrl isnt Meteor.absoluteUrl() swal type: 'warning' title: t('Warning') - text: t("The_setting_s_is_configured_to_s_and_you_are_accessing_from_s", t('Site_Url'), siteUrl, location.origin) + '

' + t("Do_you_want_to_change_to_s_question", location.origin) + text: t("The_setting_s_is_configured_to_s_and_you_are_accessing_from_s", t('Site_Url'), siteUrl, Meteor.absoluteUrl()) + '

' + t("Do_you_want_to_change_to_s_question", Meteor.absoluteUrl()) showCancelButton: true confirmButtonText: t('Yes') cancelButtonText: t('Cancel') From 10c61727f6b9a0639545adfddef1349e3c4aac2e Mon Sep 17 00:00:00 2001 From: r0p0s3c Date: Tue, 15 Mar 2016 16:25:18 -0400 Subject: [PATCH 4/6] Fix regressions due to previous commits - downgrade sandstorm to working (original) version - avatar path fixup --- .meteor/versions | 2 +- server/startup/avatar.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.meteor/versions b/.meteor/versions index a8c215e314cb..15b3d2aa85f6 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -62,7 +62,7 @@ jparker:gravatar@0.4.1 jquery@1.11.4 kadira:blaze-layout@2.3.0 kadira:flow-router@2.10.1 -kenton:accounts-sandstorm@0.2.2 +kenton:accounts-sandstorm@0.1.8 konecty:autolinker@1.0.3 konecty:change-case@2.3.0 konecty:delayed-task@1.0.0 diff --git a/server/startup/avatar.coffee b/server/startup/avatar.coffee index 00ed7f522412..7392b051e3f4 100644 --- a/server/startup/avatar.coffee +++ b/server/startup/avatar.coffee @@ -30,7 +30,7 @@ Meteor.startup -> absolutePath: path transformWrite: transformWrite - WebApp.connectHandlers.use 'avatar/', Meteor.bindEnvironment (req, res, next) -> + WebApp.connectHandlers.use '/avatar/', Meteor.bindEnvironment (req, res, next) -> params = username: decodeURIComponent(req.url.replace(/^\//, '').replace(/\?.*$/, '')) From 396fec57f51b36c651c5f55c7877b1c3b9071522 Mon Sep 17 00:00:00 2001 From: r0p0s3c Date: Wed, 16 Mar 2016 12:48:06 -0400 Subject: [PATCH 5/6] revert back to previous version of timesync until new/fixed version is publicly available --- .meteor/versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.meteor/versions b/.meteor/versions index 15b3d2aa85f6..ac61794cf766 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -89,7 +89,7 @@ meteorspark:util@0.2.0 minifiers@1.1.7 minimongo@1.0.10 mizzao:autocomplete@0.5.1 -mizzao:timesync@0.3.5 +mizzao:timesync@0.3.4 mobile-experience@1.0.1 mobile-status-bar@1.0.6 momentjs:moment@2.12.0 From 8394d9acc0fa0c7100ea76c75cc6b14513373365 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Wed, 23 Mar 2016 17:16:17 -0300 Subject: [PATCH 6/6] Fix ROOT_URL_PATH_PREFIX and add tab base --- .jshintrc | 203 +++++++++--------- .../rocketchat-lib/client/lib/settings.coffee | 37 ++-- .../lib/startup/settingsOnLoadSiteUrl.coffee | 23 +- .../rocketchat-ui-master/server/inject.js | 21 +- .../lib/getAvatarUrlFromUsername.coffee | 2 +- 5 files changed, 157 insertions(+), 129 deletions(-) diff --git a/.jshintrc b/.jshintrc index d9e16c2c6297..17d1837f25f4 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,107 +1,108 @@ { - "maxerr" : 50, // {int} Maximum error before stopping + "maxerr" : 50, // {int} Maximum error before stopping - // Enforcing - "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) - "camelcase" : true, // true: Identifiers must be in camelCase - "curly" : true, // true: Require {} for every new block or scope - "eqeqeq" : true, // true: Require triple equals (===) for comparison - "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty() - "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. - "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` - "indent" : 2, // {int} Number of spaces to use for indentation - "latedef" : false, // true: Require variables/functions to be defined before being used - "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` - "noarg" : false, // true: Prohibit use of `arguments.caller` and `arguments.callee` - "noempty" : true, // true: Prohibit use of empty blocks - "nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters. - "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) - "plusplus" : false, // true: Prohibit use of `++` & `--` - "quotmark" : "single", // Quotation mark consistency: - // false : do nothing (default) - // true : ensure whatever is used is consistent - // "single" : require single quotes - // "double" : require double quotes - "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) - "unused" : true, // true: Require all defined variables be used - "strict" : false, // true: Requires all functions run in ES5 Strict Mode - "maxparams" : false, // {int} Max number of formal params allowed per function - "maxdepth" : false, // {int} Max depth of nested blocks (within functions) - "maxstatements" : false, // {int} Max number statements per function - "maxcomplexity" : false, // {int} Max cyclomatic complexity per function - "maxlen" : false, // {int} Max number of characters per line + // Enforcing + "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) + "camelcase" : true, // true: Identifiers must be in camelCase + "curly" : true, // true: Require {} for every new block or scope + "eqeqeq" : true, // true: Require triple equals (===) for comparison + "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty() + "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. + "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` + "indent" : 2, // {int} Number of spaces to use for indentation + "latedef" : false, // true: Require variables/functions to be defined before being used + "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()` + "noarg" : false, // true: Prohibit use of `arguments.caller` and `arguments.callee` + "noempty" : true, // true: Prohibit use of empty blocks + "nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters. + "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) + "plusplus" : false, // true: Prohibit use of `++` & `--` + "quotmark" : "single", // Quotation mark consistency: + // false : do nothing (default) + // true : ensure whatever is used is consistent + // "single" : require single quotes + // "double" : require double quotes + "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) + "unused" : true, // true: Require all defined variables be used + "strict" : false, // true: Requires all functions run in ES5 Strict Mode + "maxparams" : false, // {int} Max number of formal params allowed per function + "maxdepth" : false, // {int} Max depth of nested blocks (within functions) + "maxstatements" : false, // {int} Max number statements per function + "maxcomplexity" : false, // {int} Max cyclomatic complexity per function + "maxlen" : false, // {int} Max number of characters per line - // Relaxing - "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) - "boss" : false, // true: Tolerate assignments where comparisons would be expected - "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. - "eqnull" : true, // true: Tolerate use of `== null` - "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) - "esnext" : true, // true: Allow ES.next (ES6) syntax (ex: `const`) - "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) - // (ex: `for each`, multiple try/catch, function expression…) - "evil" : false, // true: Tolerate use of `eval` and `new Function()` - "expr" : false, // true: Tolerate `ExpressionStatement` as Programs - "funcscope" : false, // true: Tolerate defining variables inside control statements - "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') - "iterator" : false, // true: Tolerate using the `__iterator__` property - "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block - "laxbreak" : false, // true: Tolerate possibly unsafe line breakings - "laxcomma" : false, // true: Tolerate comma-first style coding - "loopfunc" : false, // true: Tolerate functions being defined in loops - "multistr" : false, // true: Tolerate multi-line strings - "noyield" : false, // true: Tolerate generator functions with no yield statement in them. - "notypeof" : false, // true: Tolerate invalid typeof operator values - "proto" : false, // true: Tolerate using the `__proto__` property - "scripturl" : false, // true: Tolerate script-targeted URLs - "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` - "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation - "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` - "validthis" : false, // true: Tolerate using this in a non-constructor function + // Relaxing + "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) + "boss" : false, // true: Tolerate assignments where comparisons would be expected + "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. + "eqnull" : true, // true: Tolerate use of `== null` + "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) + "esnext" : true, // true: Allow ES.next (ES6) syntax (ex: `const`) + "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) + // (ex: `for each`, multiple try/catch, function expression…) + "evil" : false, // true: Tolerate use of `eval` and `new Function()` + "expr" : false, // true: Tolerate `ExpressionStatement` as Programs + "funcscope" : false, // true: Tolerate defining variables inside control statements + "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') + "iterator" : false, // true: Tolerate using the `__iterator__` property + "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block + "laxbreak" : false, // true: Tolerate possibly unsafe line breakings + "laxcomma" : false, // true: Tolerate comma-first style coding + "loopfunc" : false, // true: Tolerate functions being defined in loops + "multistr" : false, // true: Tolerate multi-line strings + "noyield" : false, // true: Tolerate generator functions with no yield statement in them. + "notypeof" : false, // true: Tolerate invalid typeof operator values + "proto" : false, // true: Tolerate using the `__proto__` property + "scripturl" : false, // true: Tolerate script-targeted URLs + "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` + "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation + "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` + "validthis" : false, // true: Tolerate using this in a non-constructor function - // Environments - "browser" : true, // Web Browser (window, document, etc) - "browserify" : false, // Browserify (node.js code in the browser) - "couch" : false, // CouchDB - "devel" : false, // Development/debugging (alert, confirm, etc) - "dojo" : false, // Dojo Toolkit - "jasmine" : false, // Jasmine - "jquery" : true, // jQuery - "mocha" : false, // Mocha - "mootools" : false, // MooTools - "node" : true, // Node.js - "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) - "prototypejs" : false, // Prototype and Scriptaculous - "qunit" : false, // QUnit - "rhino" : false, // Rhino - "shelljs" : false, // ShellJS - "worker" : false, // Web Workers - "wsh" : false, // Windows Scripting Host - "yui" : false, // Yahoo User Interface + // Environments + "browser" : true, // Web Browser (window, document, etc) + "browserify" : false, // Browserify (node.js code in the browser) + "couch" : false, // CouchDB + "devel" : false, // Development/debugging (alert, confirm, etc) + "dojo" : false, // Dojo Toolkit + "jasmine" : false, // Jasmine + "jquery" : true, // jQuery + "mocha" : false, // Mocha + "mootools" : false, // MooTools + "node" : true, // Node.js + "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) + "prototypejs" : false, // Prototype and Scriptaculous + "qunit" : false, // QUnit + "rhino" : false, // Rhino + "shelljs" : false, // ShellJS + "worker" : false, // Web Workers + "wsh" : false, // Windows Scripting Host + "yui" : false, // Yahoo User Interface - // Custom Globals - "globals" : { - "_" : true, - "Assets" : true, - "Blaze" : true, - "crypto" : true, - "EJSON" : true, - "FlowRouter" : true, - "Meteor" : true, - "Npm" : true, - "Package" : true, - "Promise" : true, // Avoid "redefinition of Promise" warning - "Random" : true, - "ReactiveVar" : true, - "RocketChat" : true, - "s" : true, - "Session" : true, - "swal" : true, - "t" : true, - "TAPi18n" : true, - "Template" : true, - "TimeSync" : true, - "toastr" : true, - "Tracker" : true - } + // Custom Globals + "globals" : { + "_" : true, + "Assets" : true, + "Blaze" : true, + "crypto" : true, + "EJSON" : true, + "FlowRouter" : true, + "Meteor" : true, + "Npm" : true, + "Package" : true, + "Promise" : true, // Avoid "redefinition of Promise" warning + "Random" : true, + "ReactiveVar" : true, + "RocketChat" : true, + "s" : true, + "Session" : true, + "swal" : true, + "t" : true, + "TAPi18n" : true, + "Template" : true, + "TimeSync" : true, + "toastr" : true, + "Tracker" : true, + "__meteor_runtime_config__": true + } } diff --git a/packages/rocketchat-lib/client/lib/settings.coffee b/packages/rocketchat-lib/client/lib/settings.coffee index b0d9e95c7633..c6ad33d2dbca 100644 --- a/packages/rocketchat-lib/client/lib/settings.coffee +++ b/packages/rocketchat-lib/client/lib/settings.coffee @@ -41,22 +41,25 @@ Meteor.startup -> if RocketChat.authz.hasRole(Meteor.userId(), 'admin') is false or Meteor.settings.public.sandstorm return c.stop() - if siteUrl isnt Meteor.absoluteUrl() - swal - type: 'warning' - title: t('Warning') - text: t("The_setting_s_is_configured_to_s_and_you_are_accessing_from_s", t('Site_Url'), siteUrl, Meteor.absoluteUrl()) + '

' + t("Do_you_want_to_change_to_s_question", Meteor.absoluteUrl()) - showCancelButton: true - confirmButtonText: t('Yes') - cancelButtonText: t('Cancel') - closeOnConfirm: false - html: true - , -> - Meteor.call 'saveSetting', 'Site_Url', location.origin, -> - swal - title: t('Saved') - type: 'success' - timer: 1000 - showConfirmButton: false + Meteor.setTimeout -> + if __meteor_runtime_config__.ROOT_URL isnt location.origin + currentUrl = location.origin + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX + swal + type: 'warning' + title: t('Warning') + text: t("The_setting_s_is_configured_to_s_and_you_are_accessing_from_s", t('Site_Url'), siteUrl, currentUrl) + '

' + t("Do_you_want_to_change_to_s_question", currentUrl) + showCancelButton: true + confirmButtonText: t('Yes') + cancelButtonText: t('Cancel') + closeOnConfirm: false + html: true + , -> + Meteor.call 'saveSetting', 'Site_Url', currentUrl, -> + swal + title: t('Saved') + type: 'success' + timer: 1000 + showConfirmButton: false + , 100 return c.stop() diff --git a/packages/rocketchat-lib/lib/startup/settingsOnLoadSiteUrl.coffee b/packages/rocketchat-lib/lib/startup/settingsOnLoadSiteUrl.coffee index dffbc0918bb5..6398862f3814 100644 --- a/packages/rocketchat-lib/lib/startup/settingsOnLoadSiteUrl.coffee +++ b/packages/rocketchat-lib/lib/startup/settingsOnLoadSiteUrl.coffee @@ -1,17 +1,22 @@ -if Meteor.isServer - url = Npm.require('url') - RocketChat.settings.get 'Site_Url', (key, value) -> if value?.trim() isnt '' - __meteor_runtime_config__.ROOT_URL = value - __meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL = value + host = value.replace(/\/$/, '') + prefix = "" + match = value.match(/([^/]+\/{2}[^/]+)(\/.+)/) + if match? + host = match[1] + prefix = match[2].replace(/\/$/, '') + + __meteor_runtime_config__.ROOT_URL = host + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX = prefix + __meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL = host if Meteor.absoluteUrl.defaultOptions?.rootUrl? - Meteor.absoluteUrl.defaultOptions.rootUrl = value + Meteor.absoluteUrl.defaultOptions.rootUrl = host if Meteor.isServer - RocketChat.hostname = url.parse(value).hostname + RocketChat.hostname = host - process.env.MOBILE_ROOT_URL = value - process.env.MOBILE_DDP_URL = value + process.env.MOBILE_ROOT_URL = host + process.env.MOBILE_DDP_URL = host if WebAppInternals?.generateBoilerplate WebAppInternals.generateBoilerplate() diff --git a/packages/rocketchat-ui-master/server/inject.js b/packages/rocketchat-ui-master/server/inject.js index 4555a2e74ec3..588471fef127 100644 --- a/packages/rocketchat-ui-master/server/inject.js +++ b/packages/rocketchat-ui-master/server/inject.js @@ -1,3 +1,5 @@ +/* globals Inject */ + Inject.rawBody('page-loading', `
@@ -7,4 +9,21 @@ Inject.rawBody('page-loading', `
-
`); +
` +); + +RocketChat.settings.get('Site_Url', function() { + Meteor.defer(function() { + if (__meteor_runtime_config__.ROOT_URL_PATH_PREFIX && __meteor_runtime_config__.ROOT_URL_PATH_PREFIX.trim() !== '') { + let base_url = __meteor_runtime_config__.ROOT_URL+__meteor_runtime_config__.ROOT_URL_PATH_PREFIX; + + if(/\/$/.test(base_url) === false) { + base_url += '/'; + } + + Inject.rawHead('base', ``); + } else { + Inject.rawHead('base', ''); + } + }); +}); diff --git a/packages/rocketchat-ui/lib/getAvatarUrlFromUsername.coffee b/packages/rocketchat-ui/lib/getAvatarUrlFromUsername.coffee index 215c6615173d..392e2ebfe4aa 100644 --- a/packages/rocketchat-ui/lib/getAvatarUrlFromUsername.coffee +++ b/packages/rocketchat-ui/lib/getAvatarUrlFromUsername.coffee @@ -4,7 +4,7 @@ if not username? return if Meteor.isCordova - path = Meteor.absoluteUrl() + path = Meteor.absoluteUrl().replace /\/$/, '' else path = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX || ''; "#{path}/avatar/#{encodeURIComponent(username)}.jpg?_dc=#{random}"