From 36c4a9be4fc018ade884ac61aebbc144821892b4 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 29 Mar 2016 20:59:22 -0300 Subject: [PATCH 1/7] Do not redirect assets, pass to static files middleware --- packages/rocketchat-assets/server/assets.coffee | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/rocketchat-assets/server/assets.coffee b/packages/rocketchat-assets/server/assets.coffee index 64df1800b7a7..45a4508b38bf 100644 --- a/packages/rocketchat-assets/server/assets.coffee +++ b/packages/rocketchat-assets/server/assets.coffee @@ -139,15 +139,14 @@ WebApp.connectHandlers.use '/assets/', Meteor.bindEnvironment (req, res, next) - file = RocketChatAssetsInstance.getFileWithReadStream params.asset - # res.setHeader 'Content-Disposition', 'inline' - if not file? if assets[params.asset]?.defaultUrl? - res.writeHead 301, - Location: Meteor.absoluteUrl(assets[params.asset].defaultUrl) + req.url = '/'+assets[params.asset].defaultUrl + WebAppInternals.staticFilesMiddleware WebAppInternals.staticFiles, req, res, next else res.writeHead 404 - res.end() + res.end() + return reqModifiedHeader = req.headers["if-modified-since"]; From 07adf0b84fad406e05f168350ad14227628b7b2b Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Fri, 1 Apr 2016 09:46:01 -0300 Subject: [PATCH 2/7] Serve assets with extensions --- packages/rocketchat-assets/package.js | 3 +- .../rocketchat-assets/server/assets.coffee | 145 +++++++++++++++--- packages/rocketchat-ui-admin/admin/admin.html | 4 +- .../rocketchat-ui-login/login/header.coffee | 6 +- .../rocketchat-ui-login/login/header.html | 2 +- 5 files changed, 131 insertions(+), 29 deletions(-) diff --git a/packages/rocketchat-assets/package.js b/packages/rocketchat-assets/package.js index b4e51c031662..19d0477df392 100644 --- a/packages/rocketchat-assets/package.js +++ b/packages/rocketchat-assets/package.js @@ -13,7 +13,8 @@ Package.onUse(function(api) { 'underscore', 'webapp', 'rocketchat:file', - 'rocketchat:lib' + 'rocketchat:lib', + 'webapp-hashing' ]); api.addFiles('server/assets.coffee', 'server'); diff --git a/packages/rocketchat-assets/server/assets.coffee b/packages/rocketchat-assets/server/assets.coffee index 45a4508b38bf..393932ece012 100644 --- a/packages/rocketchat-assets/server/assets.coffee +++ b/packages/rocketchat-assets/server/assets.coffee @@ -1,5 +1,6 @@ sizeOf = Npm.require 'image-size' mime = Npm.require 'mime-types' +crypto = Npm.require 'crypto' mime.extensions['image/vnd.microsoft.icon'] = ['ico'] @@ -10,73 +11,164 @@ mime.extensions['image/vnd.microsoft.icon'] = ['ico'] assets = 'logo': label: 'logo (svg, png)' - defaultUrl: 'images/logo/logo.svg?v=3' + defaultUrl: 'images/logo/logo.svg' constraints: type: 'image' extensions: ['svg', 'png'] width: undefined height: undefined - 'favicon.ico': + 'favicon': label: 'favicon.ico' - defaultUrl: 'favicon.ico?v=3' + defaultUrl: 'favicon.ico' constraints: type: 'image' extensions: ['ico'] width: undefined height: undefined - 'favicon.svg': + 'favicon': label: 'favicon.svg' - defaultUrl: 'images/logo/icon.svg?v=3' + defaultUrl: 'images/logo/icon.svg' constraints: type: 'image' extensions: ['svg'] width: undefined height: undefined - 'favicon_64.png': + 'favicon_64': label: 'favicon.png (64x64)' - defaultUrl: 'images/logo/favicon-64x64.png?v=3' + defaultUrl: 'images/logo/favicon-64x64.png' constraints: type: 'image' extensions: ['png'] width: 64 height: 64 - 'favicon_96.png': + 'favicon_96': label: 'favicon.png (96x96)' - defaultUrl: 'images/logo/favicon-96x96.png?v=3' + defaultUrl: 'images/logo/favicon-96x96.png' constraints: type: 'image' extensions: ['png'] width: 96 height: 96 - 'favicon_128.png': + 'favicon_128': label: 'favicon.png (128x128)' - defaultUrl: 'images/logo/favicon-128x128.png?v=3' + defaultUrl: 'images/logo/favicon-128x128.png' constraints: type: 'image' extensions: ['png'] width: 128 height: 128 - 'favicon_192.png': + 'favicon_192': label: 'favicon.png (192x192)' - defaultUrl: 'images/logo/android-chrome-192x192.png?v=3' + defaultUrl: 'images/logo/android-chrome-192x192.png' constraints: type: 'image' extensions: ['png'] width: 192 height: 192 - 'favicon_256.png': + 'favicon_256': label: 'favicon.png (256x256)' - defaultUrl: 'images/logo/favicon-256x256.png?v=3' + defaultUrl: 'images/logo/favicon-256x256.png' constraints: type: 'image' extensions: ['png'] width: 256 height: 256 +refreshClient = _.debounce -> + console.log 'refreshClient' + process.emit('message', {refresh: 'client'}) +, 1000 RocketChat.settings.addGroup 'Assets' for key, value of assets - RocketChat.settings.add "Assets_#{key}", '', { type: 'asset', group: 'Assets', fileConstraints: value.constraints, i18nLabel: value.label, asset: key } + do (key, value) -> + RocketChat.settings.add "Assets_#{key}", {defaultUrl: value.defaultUrl}, { type: 'asset', group: 'Assets', fileConstraints: value.constraints, i18nLabel: value.label, asset: key, public: true } + + RocketChat.settings.get "Assets_#{key}", (settingKey, settingValue) -> + if settingValue is undefined + value.cache = undefined + refreshClient() + return + + file = RocketChatAssetsInstance.getFileWithReadStream key + if not file + value.cache = undefined + refreshClient() + return + + data = [] + file.readStream.on 'data', Meteor.bindEnvironment (chunk) -> + data.push chunk + + file.readStream.on 'end', Meteor.bindEnvironment -> + data = Buffer.concat(data) + hash = crypto.createHash('sha1').update(data).digest('hex') + console.log 'file end', key, hash + extension = settingValue.url.split('.').pop() + value.cache = + path: "assets/#{key}.#{extension}" + cacheable: false + sourceMapUrl: undefined + where: 'client' + type: 'asset' + content: data + extension: extension + url: "/assets/#{key}.#{extension}?#{hash}" + size: file.length + uploadDate: file.uploadDate + contentType: file.contentType + hash: hash + + refreshClient() + +calculateClientHash = WebAppHashing.calculateClientHash +WebAppHashing.calculateClientHash = (manifest, includeFilter, runtimeConfigOverride) -> + console.log 'WebAppHashing.calculateClientHash' + for key, value of assets + if not value.cache? && not value.defaultUrl? + continue + + manifestItem = _.find manifest, (item) -> + return item.path is key + + cache = {} + if value.cache + cache = + path: value.cache.path + cacheable: value.cache.cacheable + sourceMapUrl: value.cache.sourceMapUrl + where: value.cache.where + type: value.cache.type + url: value.cache.url + size: value.cache.size + hash: value.cache.hash + + WebAppInternals.staticFiles["/__cordova/assets/#{key}"] = value.cache + WebAppInternals.staticFiles["/__cordova/assets/#{key}.#{value.cache.extension}"] = value.cache + else + extension = value.defaultUrl.split('.').pop() + cache = + path: "assets/#{key}.#{extension}" + cacheable: false + sourceMapUrl: undefined + where: 'client' + type: 'asset' + url: "/assets/#{key}.#{extension}?v3" + # size: value.cache.size + hash: 'v3' + + WebAppInternals.staticFiles["/__cordova/assets/#{key}"] = WebAppInternals.staticFiles["/__cordova/#{value.defaultUrl}"] + WebAppInternals.staticFiles["/__cordova/assets/#{key}.#{extension}"] = WebAppInternals.staticFiles["/__cordova/#{value.defaultUrl}"] + + + if manifestItem? + index = manifest.indexOf(manifestItem) + + manifest[index] = cache + else + manifest.push cache + + calculateClientHash.call this, manifest, includeFilter, runtimeConfigOverride Meteor.methods @@ -92,7 +184,8 @@ Meteor.methods throw new Meteor.Error "Invalid_asset" RocketChatAssetsInstance.deleteFile asset - RocketChat.settings.clearById "Assets_#{asset}" + + RocketChat.settings.updateById "Assets_#{asset}", {defaultUrl: assets[asset].defaultUrl} Meteor.methods @@ -107,7 +200,8 @@ Meteor.methods if not assets[asset]? throw new Meteor.Error "Invalid_asset" - if mime.extension(contentType) not in assets[asset].constraints.extensions + extension = mime.extension(contentType) + if extension not in assets[asset].constraints.extensions throw new Meteor.Error "Invalid_file_type", contentType file = new Buffer(binaryContent, 'binary') @@ -126,7 +220,10 @@ Meteor.methods ws = RocketChatAssetsInstance.createWriteStream asset, contentType ws.on 'end', Meteor.bindEnvironment -> Meteor.setTimeout -> - RocketChat.settings.updateById "Assets_#{asset}", "/assets/#{asset}" + RocketChat.settings.updateById "Assets_#{asset}", { + url: "/assets/#{asset}.#{extension}" + defaultUrl: assets[asset].defaultUrl + } , 200 rs.pipe ws @@ -135,9 +232,10 @@ Meteor.methods WebApp.connectHandlers.use '/assets/', Meteor.bindEnvironment (req, res, next) -> params = - asset: decodeURIComponent(req.url.replace(/^\//, '').replace(/\?.*$/, '')) + asset: decodeURIComponent(req.url.replace(/^\//, '').replace(/\?.*$/, '')).replace(/\.[^.]*$/, '') - file = RocketChatAssetsInstance.getFileWithReadStream params.asset + console.log params.asset + file = assets[params.asset]?.cache if not file? if assets[params.asset]?.defaultUrl? @@ -161,7 +259,8 @@ WebApp.connectHandlers.use '/assets/', Meteor.bindEnvironment (req, res, next) - res.setHeader 'Expires', '-1' res.setHeader 'Last-Modified', file.uploadDate?.toUTCString() or new Date().toUTCString() res.setHeader 'Content-Type', file.contentType - res.setHeader 'Content-Length', file.length + res.setHeader 'Content-Length', file.size - file.readStream.pipe res + res.writeHead 200 + res.end(file.content) return diff --git a/packages/rocketchat-ui-admin/admin/admin.html b/packages/rocketchat-ui-admin/admin/admin.html index 3dee317da557..3e5f900583d0 100644 --- a/packages/rocketchat-ui-admin/admin/admin.html +++ b/packages/rocketchat-ui-admin/admin/admin.html @@ -117,9 +117,9 @@

{{/if}} {{#if $eq type 'asset'}} - {{#if value}} + {{#if value.url}}
-
+
diff --git a/packages/rocketchat-ui-login/login/header.coffee b/packages/rocketchat-ui-login/login/header.coffee index de15c0a07ae8..b9bcec6c49f3 100644 --- a/packages/rocketchat-ui-login/login/header.coffee +++ b/packages/rocketchat-ui-login/login/header.coffee @@ -1,3 +1,5 @@ Template.loginHeader.helpers - header: -> - RocketChat.settings.get 'Layout_Login_Header' \ No newline at end of file + logoUrl: -> + asset = RocketChat.settings.get('Assets_logo') + if asset? + return asset.url or asset.defaultUrl diff --git a/packages/rocketchat-ui-login/login/header.html b/packages/rocketchat-ui-login/login/header.html index d48ab3d02fce..b5c01151ae4d 100644 --- a/packages/rocketchat-ui-login/login/header.html +++ b/packages/rocketchat-ui-login/login/header.html @@ -1,5 +1,5 @@ From 153701e6cb42d4571051577d446303ec33657b7f Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Sat, 2 Apr 2016 17:19:08 -0300 Subject: [PATCH 3/7] Finish assets --- .../rocketchat-assets/server/assets.coffee | 27 +++++++++++-------- packages/rocketchat-lib/i18n/en.i18n.json | 2 ++ .../rocketchat-ui-admin/admin/admin.coffee | 4 +++ packages/rocketchat-ui-admin/admin/admin.html | 3 +++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/packages/rocketchat-assets/server/assets.coffee b/packages/rocketchat-assets/server/assets.coffee index 393932ece012..a4880826ab7a 100644 --- a/packages/rocketchat-assets/server/assets.coffee +++ b/packages/rocketchat-assets/server/assets.coffee @@ -74,26 +74,22 @@ assets = width: 256 height: 256 -refreshClient = _.debounce -> - console.log 'refreshClient' - process.emit('message', {refresh: 'client'}) -, 1000 RocketChat.settings.addGroup 'Assets' for key, value of assets do (key, value) -> RocketChat.settings.add "Assets_#{key}", {defaultUrl: value.defaultUrl}, { type: 'asset', group: 'Assets', fileConstraints: value.constraints, i18nLabel: value.label, asset: key, public: true } +Meteor.startup -> + forEachAsset = (key, value) -> RocketChat.settings.get "Assets_#{key}", (settingKey, settingValue) -> if settingValue is undefined value.cache = undefined - refreshClient() return file = RocketChatAssetsInstance.getFileWithReadStream key if not file value.cache = undefined - refreshClient() return data = [] @@ -103,7 +99,6 @@ for key, value of assets file.readStream.on 'end', Meteor.bindEnvironment -> data = Buffer.concat(data) hash = crypto.createHash('sha1').update(data).digest('hex') - console.log 'file end', key, hash extension = settingValue.url.split('.').pop() value.cache = path: "assets/#{key}.#{extension}" @@ -119,11 +114,11 @@ for key, value of assets contentType: file.contentType hash: hash - refreshClient() + + forEachAsset(key, value) for key, value of assets calculateClientHash = WebAppHashing.calculateClientHash WebAppHashing.calculateClientHash = (manifest, includeFilter, runtimeConfigOverride) -> - console.log 'WebAppHashing.calculateClientHash' for key, value of assets if not value.cache? && not value.defaultUrl? continue @@ -168,8 +163,19 @@ WebAppHashing.calculateClientHash = (manifest, includeFilter, runtimeConfigOverr else manifest.push cache - calculateClientHash.call this, manifest, includeFilter, runtimeConfigOverride + return calculateClientHash.call this, manifest, includeFilter, runtimeConfigOverride + + +Meteor.methods + refreshClients: -> + unless Meteor.userId() + throw new Meteor.Error 'invalid-user', "[methods] unsetAsset -> Invalid user" + + hasPermission = RocketChat.authz.hasPermission Meteor.userId(), 'manage-assets' + unless hasPermission + throw new Meteor.Error 'manage-assets-not-allowed', "[methods] unsetAsset -> Manage assets not allowed" + process.emit('message', {refresh: 'client'}) Meteor.methods unsetAsset: (asset) -> @@ -234,7 +240,6 @@ WebApp.connectHandlers.use '/assets/', Meteor.bindEnvironment (req, res, next) - params = asset: decodeURIComponent(req.url.replace(/^\//, '').replace(/\?.*$/, '')).replace(/\.[^.]*$/, '') - console.log params.asset file = assets[params.asset]?.cache if not file? diff --git a/packages/rocketchat-lib/i18n/en.i18n.json b/packages/rocketchat-lib/i18n/en.i18n.json index a393efb9825d..13874d6deaa7 100644 --- a/packages/rocketchat-lib/i18n/en.i18n.json +++ b/packages/rocketchat-lib/i18n/en.i18n.json @@ -128,6 +128,7 @@ "Application_added" : "Application added", "Application_Name" : "Application Name", "Application_updated" : "Application updated", + "Apply_and_refresh_all_clients" : "Apply and refresh all clients", "Archive" : "Archive", "Archive_Unarchive" : "Archive / Unarchive", "are_also_typing" : "are also typing", @@ -181,6 +182,7 @@ "Clear_all_unreads_question" : "Clear all unreads?", "Client_ID" : "Client ID", "Client_Secret" : "Client Secret", + "Clients_will_refresh_in_a_few_seconds" : "Clients will refresh in a few seconds", "close" : "close", "Closed" : "Closed", "coming_soon" : "coming soon", diff --git a/packages/rocketchat-ui-admin/admin/admin.coffee b/packages/rocketchat-ui-admin/admin/admin.coffee index 080474c9a824..bf2bd4b6f6ce 100644 --- a/packages/rocketchat-ui-admin/admin/admin.coffee +++ b/packages/rocketchat-ui-admin/admin/admin.coffee @@ -210,6 +210,10 @@ Template.admin.events return toastr.error TAPi18n.__ 'Error_updating_settings' if err toastr.success TAPi18n.__ 'Settings_updated' + "click .submit .refresh-clients": (e, t) -> + Meteor.call 'refreshClients', -> + toastr.success TAPi18n.__ 'Clients_will_refresh_in_a_few_seconds' + "click .submit .add-custom-oauth": (e, t) -> config = title: TAPi18n.__ 'Add_custom_oauth' diff --git a/packages/rocketchat-ui-admin/admin/admin.html b/packages/rocketchat-ui-admin/admin/admin.html index 3e5f900583d0..fe62d12adc27 100644 --- a/packages/rocketchat-ui-admin/admin/admin.html +++ b/packages/rocketchat-ui-admin/admin/admin.html @@ -167,6 +167,9 @@

{{#if $eq group._id 'OAuth'}} {{/if}} + {{#if $eq group._id 'Assets'}} + + {{/if}}

{{/unless}} From 5050bad20ef8faf7b4f421928f17604d336a7367 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 4 Apr 2016 15:07:55 -0300 Subject: [PATCH 4/7] Set _updateAt when updating setting --- packages/rocketchat-lib/server/functions/settings.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/rocketchat-lib/server/functions/settings.coffee b/packages/rocketchat-lib/server/functions/settings.coffee index 0619604923e5..5c2824080938 100644 --- a/packages/rocketchat-lib/server/functions/settings.coffee +++ b/packages/rocketchat-lib/server/functions/settings.coffee @@ -160,6 +160,8 @@ RocketChat.settings.updateById = (_id, value) -> if not _id or not value? return false + value._updatedAt = new Date + return RocketChat.models.Settings.updateValueById _id, value From a779074aec03ae6a60ce64f0935c22f0b9a6fbea Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 4 Apr 2016 15:08:13 -0300 Subject: [PATCH 5/7] Remove the creation of setting Layout_Login_Header --- packages/rocketchat-lib/i18n/de.i18n.json | 3 +-- packages/rocketchat-lib/i18n/en.i18n.json | 1 - packages/rocketchat-lib/i18n/es.i18n.json | 3 +-- packages/rocketchat-lib/i18n/fi.i18n.json | 3 +-- packages/rocketchat-lib/i18n/fr.i18n.json | 3 +-- packages/rocketchat-lib/i18n/he.i18n.json | 3 +-- packages/rocketchat-lib/i18n/ja.i18n.json | 3 +-- packages/rocketchat-lib/i18n/km.i18n.json | 3 +-- packages/rocketchat-lib/i18n/ko.i18n.json | 3 +-- packages/rocketchat-lib/i18n/ms-MY.i18n.json | 3 +-- packages/rocketchat-lib/i18n/nl.i18n.json | 3 +-- packages/rocketchat-lib/i18n/pl.i18n.json | 3 +-- packages/rocketchat-lib/i18n/pt.i18n.json | 3 +-- packages/rocketchat-lib/i18n/ro.i18n.json | 3 +-- packages/rocketchat-lib/i18n/ru.i18n.json | 3 +-- packages/rocketchat-lib/i18n/zh-HK.i18n.json | 3 +-- packages/rocketchat-lib/i18n/zh-TW.i18n.json | 3 +-- packages/rocketchat-lib/i18n/zh.i18n.json | 3 +-- packages/rocketchat-lib/server/startup/settings.coffee | 1 - 19 files changed, 17 insertions(+), 36 deletions(-) diff --git a/packages/rocketchat-lib/i18n/de.i18n.json b/packages/rocketchat-lib/i18n/de.i18n.json index 246be9488737..c76b59bfa844 100644 --- a/packages/rocketchat-lib/i18n/de.i18n.json +++ b/packages/rocketchat-lib/i18n/de.i18n.json @@ -400,7 +400,6 @@ "Layout" : "Layout", "Layout_Home_Body" : "Inhalt der Startseite", "Layout_Home_Title" : "Titel der Startseite", - "Layout_Login_Header" : "Kopfzeile der Anmeldeseite", "Layout_Login_Terms" : "Anmeldebedingungen", "Layout_Privacy_Policy" : "Datenschutzbestimmungen", "Layout_Sidenav_Footer" : "Seitenfußzeile", @@ -1011,4 +1010,4 @@ "Your_Open_Source_solution" : "Deine eigene Open-Source-Chat-Lösung.", "Your_password_is_wrong" : "Falsches Passwort", "Your_push_was_sent_to_s_devices" : "Die Push-Nachricht wurde an %s Geräte gesendet." -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/en.i18n.json b/packages/rocketchat-lib/i18n/en.i18n.json index 76ee845cd3c4..86b8762a8db4 100644 --- a/packages/rocketchat-lib/i18n/en.i18n.json +++ b/packages/rocketchat-lib/i18n/en.i18n.json @@ -409,7 +409,6 @@ "Layout" : "Layout", "Layout_Home_Body" : "Home Body", "Layout_Home_Title" : "Home Title", - "Layout_Login_Header" : "Login Header", "Layout_Login_Terms" : "Login Terms", "Layout_Privacy_Policy" : "Privacy Policy", "Layout_Sidenav_Footer" : "Side Navigation Footer", diff --git a/packages/rocketchat-lib/i18n/es.i18n.json b/packages/rocketchat-lib/i18n/es.i18n.json index 9e3bfaaa1bb9..84af7be6a4cb 100644 --- a/packages/rocketchat-lib/i18n/es.i18n.json +++ b/packages/rocketchat-lib/i18n/es.i18n.json @@ -288,7 +288,6 @@ "Layout" : "Diseño", "Layout_Home_Body" : "Cuerpo de pagina de inicio", "Layout_Home_Title" : "Titulo de pagina de inicio", - "Layout_Login_Header" : "Encabezado de Inicio de Sesión ", "Layout_Login_Terms" : "Términos de Inicio de Sesión ", "Layout_Privacy_Policy" : "Política de Privacidad", "Layout_Sidenav_Footer" : "Pie de Pagina de la Barra de Navegación Lateral", @@ -728,4 +727,4 @@ "Your_entry_has_been_deleted" : "Tu entrada ha sido eliminada", "Your_file_has_been_deleted" : "Tu archivo ha sido eliminado.", "Your_Open_Source_solution" : "Tu propia solución de chat de código abierto" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/fi.i18n.json b/packages/rocketchat-lib/i18n/fi.i18n.json index b5aee6a9b20a..4ab26bd847bf 100644 --- a/packages/rocketchat-lib/i18n/fi.i18n.json +++ b/packages/rocketchat-lib/i18n/fi.i18n.json @@ -310,7 +310,6 @@ "Layout" : "Ulkoasu", "Layout_Home_Body" : "Etusivun runko", "Layout_Home_Title" : "Etusivun otsikko", - "Layout_Login_Header" : "Kirjautumisruudun ylätunniste", "Layout_Login_Terms" : "Kirjautumisehdot", "Layout_Privacy_Policy" : "Tietosuojakäytäntö", "Layout_Sidenav_Footer" : "Sivunavigoinnin alatunniste", @@ -808,4 +807,4 @@ "Your_mail_was_sent_to_s" : "Sähköpostisi lähetettiin, vastaanottaja %s", "Your_Open_Source_solution" : "Your own Open Source chat solution", "Your_push_was_sent_to_s_devices" : "Push-viesti lähetettiin %s laitteeseen" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/fr.i18n.json b/packages/rocketchat-lib/i18n/fr.i18n.json index ccec48bea7ac..1361a21ca552 100644 --- a/packages/rocketchat-lib/i18n/fr.i18n.json +++ b/packages/rocketchat-lib/i18n/fr.i18n.json @@ -395,7 +395,6 @@ "Layout" : "Disposition", "Layout_Home_Body" : "Contenu de la page d'accueil", "Layout_Home_Title" : "Titre de la page d'accueil", - "Layout_Login_Header" : "En-tête de connexion", "Layout_Login_Terms" : "Conditions de connexion", "Layout_Privacy_Policy" : "Politique de confidentialité", "Layout_Sidenav_Footer" : "Pied de page de la sidebar", @@ -1002,4 +1001,4 @@ "Your_Open_Source_solution" : "Votre propre solution de chat Open Source", "Your_password_is_wrong" : "Votre mot de passe est incorrect !", "Your_push_was_sent_to_s_devices" : "Votre notification a été envoyée à %s appareils" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/he.i18n.json b/packages/rocketchat-lib/i18n/he.i18n.json index 07645abfee15..5f30bd793126 100644 --- a/packages/rocketchat-lib/i18n/he.i18n.json +++ b/packages/rocketchat-lib/i18n/he.i18n.json @@ -170,7 +170,6 @@ "Layout" : "פריסה", "Layout_Home_Body" : "גוף עמוד הבית", "Layout_Home_Title" : "כותרת עמוד הבית", - "Layout_Login_Header" : "כותרת כניסה", "Layout_Login_Terms" : "תנאי כניסה", "Layout_Privacy_Policy" : "מדיניות פרטיות", "Layout_Terms_of_Service" : "תנאי השירות", @@ -423,4 +422,4 @@ "You_will_not_be_able_to_recover" : "לא תהיה לך אפשרות לשחזר את ההודעה הזו!", "Your_entry_has_been_deleted" : "הרשומה שלך נמחקה", "Your_Open_Source_solution" : "הפתרון " -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/ja.i18n.json b/packages/rocketchat-lib/i18n/ja.i18n.json index d156a6de1618..dff59d987dad 100644 --- a/packages/rocketchat-lib/i18n/ja.i18n.json +++ b/packages/rocketchat-lib/i18n/ja.i18n.json @@ -384,7 +384,6 @@ "Layout" : "レイアウト", "Layout_Home_Body" : "ホーム画面の本文", "Layout_Home_Title" : "ホーム画面のタイトル", - "Layout_Login_Header" : "ログイン画面のヘッダー", "Layout_Login_Terms" : "ログイン画面の規約", "Layout_Privacy_Policy" : "プライバシーポリシー", "Layout_Sidenav_Footer" : "サイドナビゲーションのフッター", @@ -990,4 +989,4 @@ "Your_Open_Source_solution" : "独自のオープンソースチャットソリューション", "Your_password_is_wrong" : "パスワードが間違っています!", "Your_push_was_sent_to_s_devices" : "プッシュ通知が %s 台のデバイスへ送信されました" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/km.i18n.json b/packages/rocketchat-lib/i18n/km.i18n.json index 657614cbbcbf..db7675a91dec 100644 --- a/packages/rocketchat-lib/i18n/km.i18n.json +++ b/packages/rocketchat-lib/i18n/km.i18n.json @@ -209,7 +209,6 @@ "Layout" : "ប្លង់", "Layout_Home_Body" : "តួរសេចក្តីទំព័រដើម", "Layout_Home_Title" : "ចំណងជើងទំព័រដើម", - "Layout_Login_Header" : "ក្បាលទំព័រចូល", "Layout_Login_Terms" : "លក្ខ័ណចូល", "Layout_Privacy_Policy" : "គោលការណ៍ឯកជនភាព", "Layout_Sidenav_Footer" : "ចំហៀង​របស់​កម្មវិធី​រុករក​បាតកថា", @@ -516,4 +515,4 @@ "You_will_not_be_able_to_recover" : "អ្នក​នឹង​មិនអាច​ទាញ​មក​វិញ!", "Your_entry_has_been_deleted" : "ការ​បញ្ចូល​អ្នក​បាន​លប់", "Your_Open_Source_solution" : "ដំណោះ​ស្រាយ​ពិភាក្សាកូដ​ចំហរ​របស់​អ្នក" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/ko.i18n.json b/packages/rocketchat-lib/i18n/ko.i18n.json index 8fd5ada578b2..4256744c9622 100644 --- a/packages/rocketchat-lib/i18n/ko.i18n.json +++ b/packages/rocketchat-lib/i18n/ko.i18n.json @@ -221,7 +221,6 @@ "Layout" : "레이아웃", "Layout_Home_Body" : "홈 본문 내용", "Layout_Home_Title" : "홈 제목", - "Layout_Login_Header" : "로그인 헤더", "Layout_Login_Terms" : "로그인 약관", "Layout_Privacy_Policy" : "개인정보취급방침", "Layout_Sidenav_Footer" : "옆 네비 바닥글", @@ -541,4 +540,4 @@ "You_will_not_be_able_to_recover" : "이 메시지는 복구할 수 없습니다!", "Your_entry_has_been_deleted" : "항목이 삭제되었습니다.", "Your_Open_Source_solution" : "당신만의 오픈소스 채팅 솔루션" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/ms-MY.i18n.json b/packages/rocketchat-lib/i18n/ms-MY.i18n.json index ff84a04018ad..a2e7ef703b4c 100644 --- a/packages/rocketchat-lib/i18n/ms-MY.i18n.json +++ b/packages/rocketchat-lib/i18n/ms-MY.i18n.json @@ -152,7 +152,6 @@ "Layout" : "Tata atur", "Layout_Home_Body" : "Badan Laman", "Layout_Home_Title" : "Tajuk Halaman Utama", - "Layout_Login_Header" : "Login Header", "Layout_Login_Terms" : "Terma Log masuk", "Layout_Privacy_Policy" : "Dasar Privasi", "Layout_Sidenav_Footer" : "Navigasi Belah Tepi Footer", @@ -394,4 +393,4 @@ "You_need_confirm_email" : "Anda perlu mengesahkan e-mel anda untuk melog masuk!", "You_will_not_be_able_to_recover" : "Anda tidak boleh membaik pulih.", "Your_entry_has_been_deleted" : "Entri anda telah dipadam." -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/nl.i18n.json b/packages/rocketchat-lib/i18n/nl.i18n.json index 0f9c49bdf441..c922d5c1230d 100644 --- a/packages/rocketchat-lib/i18n/nl.i18n.json +++ b/packages/rocketchat-lib/i18n/nl.i18n.json @@ -320,7 +320,6 @@ "Layout" : "Lay-out", "Layout_Home_Body" : "Home Body", "Layout_Home_Title" : "Home Titel", - "Layout_Login_Header" : "Login Header", "Layout_Login_Terms" : "Login voorwaarden", "Layout_Privacy_Policy" : "Privacybeleid", "Layout_Sidenav_Footer" : "Side Navigation Footer", @@ -842,4 +841,4 @@ "Your_mail_was_sent_to_s" : "Uw e-mail werd verzonden naar %s", "Your_Open_Source_solution" : "Uw eigen Open Source chat-oplossing", "Your_push_was_sent_to_s_devices" : "Je push werd verzonden naar %s apparaten" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/pl.i18n.json b/packages/rocketchat-lib/i18n/pl.i18n.json index a441c5680d94..098df643b8f4 100644 --- a/packages/rocketchat-lib/i18n/pl.i18n.json +++ b/packages/rocketchat-lib/i18n/pl.i18n.json @@ -242,7 +242,6 @@ "Layout" : "Wygląd i treść", "Layout_Home_Body" : "Treść strony głównej", "Layout_Home_Title" : "Tytuł strony głównej", - "Layout_Login_Header" : "Nagłówek formularza logowania", "Layout_Login_Terms" : "Regulamin rejestacji", "Layout_Privacy_Policy" : "Polityka Prywatności", "Layout_Sidenav_Footer" : "Stopka panelu nawigacyjnego", @@ -601,4 +600,4 @@ "You_will_not_be_able_to_recover" : "Nie będziesz w stanie odzyskać tej wiadomości!", "Your_entry_has_been_deleted" : "Twój wpis został usunięty.", "Your_Open_Source_solution" : "Twój własny czat Open Source" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/pt.i18n.json b/packages/rocketchat-lib/i18n/pt.i18n.json index c229831c22d2..506a9500849d 100644 --- a/packages/rocketchat-lib/i18n/pt.i18n.json +++ b/packages/rocketchat-lib/i18n/pt.i18n.json @@ -229,7 +229,6 @@ "Layout" : "Layout", "Layout_Home_Body" : "Corpo da Home", "Layout_Home_Title" : "Título da Home", - "Layout_Login_Header" : "Header do Login", "Layout_Login_Terms" : "Termos de Login", "Layout_Privacy_Policy" : "Política de Privacidade", "Layout_Sidenav_Footer" : "Rodapé da Navegação Lateral", @@ -545,4 +544,4 @@ "Your_entry_has_been_deleted" : "Sua mensagem foi excluída.", "Your_Open_Source_solution" : "Sua própria solução Open Source", "Your_push_was_sent_to_s_devices" : "Sua natificação foi enviada para %s dispositivos" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/ro.i18n.json b/packages/rocketchat-lib/i18n/ro.i18n.json index d6206f7bea76..04993b731c38 100644 --- a/packages/rocketchat-lib/i18n/ro.i18n.json +++ b/packages/rocketchat-lib/i18n/ro.i18n.json @@ -354,7 +354,6 @@ "Layout" : "Layout", "Layout_Home_Body" : "Corp pagină 'Acasă'", "Layout_Home_Title" : "Titlu pagină 'Acasă'", - "Layout_Login_Header" : "Header Autentificare", "Layout_Login_Terms" : "Termeni Autentificare", "Layout_Privacy_Policy" : "Politica de confidențialitate", "Layout_Sidenav_Footer" : "Footer meniu lateral", @@ -915,4 +914,4 @@ "Your_mail_was_sent_to_s" : "E-mail-ul a fost trimis la %s", "Your_Open_Source_solution" : "Propria soluție de chat Open Source", "Your_push_was_sent_to_s_devices" : "Mesajul Push a fost trimis la %s dispozitive" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/ru.i18n.json b/packages/rocketchat-lib/i18n/ru.i18n.json index cc59336aad3c..4c0480815c70 100644 --- a/packages/rocketchat-lib/i18n/ru.i18n.json +++ b/packages/rocketchat-lib/i18n/ru.i18n.json @@ -392,7 +392,6 @@ "Layout" : "План", "Layout_Home_Body" : "Контент главной", "Layout_Home_Title" : "Название главной", - "Layout_Login_Header" : "Заголовок логина", "Layout_Login_Terms" : "Правила составления логина", "Layout_Privacy_Policy" : "Политика конфиденциальности", "Layout_Sidenav_Footer" : "Футер навигационной панели", @@ -998,4 +997,4 @@ "Your_Open_Source_solution" : "Ваш собственный чат на базе Open Source-технологий", "Your_password_is_wrong" : "Неверный пароль!", "Your_push_was_sent_to_s_devices" : "Ваше push-уведомление было отправлено на % устройств." -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/zh-HK.i18n.json b/packages/rocketchat-lib/i18n/zh-HK.i18n.json index 9cac35cd67aa..a2b4bf01dc63 100644 --- a/packages/rocketchat-lib/i18n/zh-HK.i18n.json +++ b/packages/rocketchat-lib/i18n/zh-HK.i18n.json @@ -115,7 +115,6 @@ "Layout" : "布局", "Layout_Home_Body" : "首页正文", "Layout_Home_Title" : "首页标题", - "Layout_Login_Header" : "登录页面标头", "Layout_Login_Terms" : "登录条款", "Layout_Privacy_Policy" : "隐私政策", "Layout_Sidenav_Footer" : "侧面导航页脚", @@ -319,4 +318,4 @@ "You_will_not_be_able_to_recover" : "您将无法恢复!", "Your_entry_has_been_deleted" : "您的项目已被删除。", "Your_Open_Source_solution" : "您自己的开源聊天解决方案" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/zh-TW.i18n.json b/packages/rocketchat-lib/i18n/zh-TW.i18n.json index d619e6f18e6e..26c1b24f2c65 100644 --- a/packages/rocketchat-lib/i18n/zh-TW.i18n.json +++ b/packages/rocketchat-lib/i18n/zh-TW.i18n.json @@ -142,7 +142,6 @@ "Layout" : "介面", "Layout_Home_Body" : "首页正文", "Layout_Home_Title" : "首頁標題", - "Layout_Login_Header" : "登录页面标头", "Layout_Login_Terms" : "登录条款", "Layout_Privacy_Policy" : "隱私政策", "Layout_Sidenav_Footer" : "侧面导航页脚", @@ -393,4 +392,4 @@ "Your_entry_has_been_deleted" : "您的项目已被删除。", "Your_Open_Source_solution" : "您自己的開源聊天軟體", "Your_push_was_sent_to_s_devices" : "你的推播被送到 %s 裝置" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/i18n/zh.i18n.json b/packages/rocketchat-lib/i18n/zh.i18n.json index 7111a4d9eaa9..4b77f532a95b 100644 --- a/packages/rocketchat-lib/i18n/zh.i18n.json +++ b/packages/rocketchat-lib/i18n/zh.i18n.json @@ -381,7 +381,6 @@ "Layout" : "布局", "Layout_Home_Body" : "首页正文", "Layout_Home_Title" : "首页标题", - "Layout_Login_Header" : "登录页面标头", "Layout_Login_Terms" : "登录条款", "Layout_Privacy_Policy" : "隐私政策", "Layout_Sidenav_Footer" : "侧面导航页脚", @@ -977,4 +976,4 @@ "Your_Open_Source_solution" : "您自己的开源聊天解决方案", "Your_password_is_wrong" : "密码错误!", "Your_push_was_sent_to_s_devices" : "成功向 %s 台设备推送" -} \ No newline at end of file +} diff --git a/packages/rocketchat-lib/server/startup/settings.coffee b/packages/rocketchat-lib/server/startup/settings.coffee index dffc83abf73e..d4bc1d6739b0 100644 --- a/packages/rocketchat-lib/server/startup/settings.coffee +++ b/packages/rocketchat-lib/server/startup/settings.coffee @@ -176,7 +176,6 @@ RocketChat.settings.addGroup 'Layout', -> @add 'Custom_Script_Logged_In', '//Add your script', { type: 'code', multiline: true, public: true } @section 'Login', -> - @add 'Layout_Login_Header', '', { type: 'code', code: 'text/html', 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 } From 397c8e58404422edf803b2a9f98df96900cc72d5 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 4 Apr 2016 15:08:32 -0300 Subject: [PATCH 6/7] Expose Assets methods via RocketChat.Assets --- .../rocketchat-assets/server/assets.coffee | 93 +++++++++++-------- 1 file changed, 52 insertions(+), 41 deletions(-) diff --git a/packages/rocketchat-assets/server/assets.coffee b/packages/rocketchat-assets/server/assets.coffee index a4880826ab7a..64f4fe339a79 100644 --- a/packages/rocketchat-assets/server/assets.coffee +++ b/packages/rocketchat-assets/server/assets.coffee @@ -10,11 +10,11 @@ mime.extensions['image/vnd.microsoft.icon'] = ['ico'] assets = 'logo': - label: 'logo (svg, png)' + label: 'logo (svg, png, jpg)' defaultUrl: 'images/logo/logo.svg' constraints: type: 'image' - extensions: ['svg', 'png'] + extensions: ['svg', 'png', 'jpg', 'jpeg'] width: undefined height: undefined 'favicon': @@ -75,6 +75,52 @@ assets = height: 256 +RocketChat.Assets = new class + setAsset: (binaryContent, contentType, asset) -> + if not assets[asset]? + throw new Meteor.Error "Invalid_asset" + + extension = mime.extension(contentType) + if extension not in assets[asset].constraints.extensions + throw new Meteor.Error "Invalid_file_type", contentType + + file = new Buffer(binaryContent, 'binary') + if assets[asset].constraints.width? or assets[asset].constraints.height? + dimensions = sizeOf file + + if assets[asset].constraints.width? and assets[asset].constraints.width isnt dimensions.width + throw new Meteor.Error "Invalid_file_width" + + if assets[asset].constraints.height? and assets[asset].constraints.height isnt dimensions.height + throw new Meteor.Error "Invalid_file_height" + + rs = RocketChatFile.bufferToStream file + RocketChatAssetsInstance.deleteFile asset + ws = RocketChatAssetsInstance.createWriteStream asset, contentType + ws.on 'end', Meteor.bindEnvironment -> + Meteor.setTimeout -> + RocketChat.settings.updateById "Assets_#{asset}", { + url: "/assets/#{asset}.#{extension}" + defaultUrl: assets[asset].defaultUrl + } + , 200 + + rs.pipe ws + return + + unsetAsset: (asset) -> + if not assets[asset]? + throw new Meteor.Error "Invalid_asset" + + RocketChatAssetsInstance.deleteFile asset + + RocketChat.settings.updateById "Assets_#{asset}", {defaultUrl: assets[asset].defaultUrl} + return + + refreshClients: -> + process.emit('message', {refresh: 'client'}) + + RocketChat.settings.addGroup 'Assets' for key, value of assets do (key, value) -> @@ -175,9 +221,9 @@ Meteor.methods unless hasPermission throw new Meteor.Error 'manage-assets-not-allowed', "[methods] unsetAsset -> Manage assets not allowed" - process.emit('message', {refresh: 'client'}) + RocketChat.Assets.refreshClients + -Meteor.methods unsetAsset: (asset) -> unless Meteor.userId() throw new Meteor.Error 'invalid-user', "[methods] unsetAsset -> Invalid user" @@ -186,15 +232,9 @@ Meteor.methods unless hasPermission throw new Meteor.Error 'manage-assets-not-allowed', "[methods] unsetAsset -> Manage assets not allowed" - if not assets[asset]? - throw new Meteor.Error "Invalid_asset" - - RocketChatAssetsInstance.deleteFile asset - - RocketChat.settings.updateById "Assets_#{asset}", {defaultUrl: assets[asset].defaultUrl} + RocketChat.Assets.unsetAsset asset -Meteor.methods setAsset: (binaryContent, contentType, asset) -> unless Meteor.userId() throw new Meteor.Error 'invalid-user', "[methods] setAsset -> Invalid user" @@ -203,36 +243,7 @@ Meteor.methods unless hasPermission throw new Meteor.Error 'manage-assets-not-allowed', "[methods] unsetAsset -> Manage assets not allowed" - if not assets[asset]? - throw new Meteor.Error "Invalid_asset" - - extension = mime.extension(contentType) - if extension not in assets[asset].constraints.extensions - throw new Meteor.Error "Invalid_file_type", contentType - - file = new Buffer(binaryContent, 'binary') - - if assets[asset].constraints.width? or assets[asset].constraints.height? - dimensions = sizeOf file - - if assets[asset].constraints.width? and assets[asset].constraints.width isnt dimensions.width - throw new Meteor.Error "Invalid_file_width" - - if assets[asset].constraints.height? and assets[asset].constraints.height isnt dimensions.height - throw new Meteor.Error "Invalid_file_height" - - rs = RocketChatFile.bufferToStream file - RocketChatAssetsInstance.deleteFile asset - ws = RocketChatAssetsInstance.createWriteStream asset, contentType - ws.on 'end', Meteor.bindEnvironment -> - Meteor.setTimeout -> - RocketChat.settings.updateById "Assets_#{asset}", { - url: "/assets/#{asset}.#{extension}" - defaultUrl: assets[asset].defaultUrl - } - , 200 - - rs.pipe ws + RocketChat.Assets.setAsset binaryContent, contentType, asset return From 0e93d6efc41878c3b0ffd618dadf302eadb78981 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 4 Apr 2016 15:08:45 -0300 Subject: [PATCH 7/7] Create migration for Layout_Login_Header --- server/startup/migrations/v36.coffee | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 server/startup/migrations/v36.coffee diff --git a/server/startup/migrations/v36.coffee b/server/startup/migrations/v36.coffee new file mode 100644 index 000000000000..11a63e6f3f59 --- /dev/null +++ b/server/startup/migrations/v36.coffee @@ -0,0 +1,21 @@ +url = Npm.require 'url' +RocketChat.Migrations.add + version: 35 + up: -> + loginHeader = RocketChat.models.Settings.findOne _id: 'Layout_Login_Header' + + if not loginHeader?.value? + return + + match = loginHeader.value.match(/