|
1 | 1 | less = Npm.require('less')
|
| 2 | +crypto = Npm.require('crypto') |
| 3 | + |
| 4 | +# program = WebApp.clientPrograms['web.browser'] |
| 5 | +# themeManifestItem = _.find program.manifest, (item) -> return item.url is '/theme.css' |
| 6 | +# themeManifestItem.where = 'client' |
| 7 | +# themeManifestItem.type = 'css' |
| 8 | + |
| 9 | +ClientVersions = undefined |
| 10 | +_defineMutationMethods = Meteor.Collection.prototype._defineMutationMethods |
| 11 | +Meteor.Collection.prototype._defineMutationMethods = -> |
| 12 | + if this._name is 'meteor_autoupdate_clientVersions' |
| 13 | + ClientVersions = this |
| 14 | + |
| 15 | + _defineMutationMethods.call this |
2 | 16 |
|
3 | 17 | RocketChat.theme = new class
|
4 | 18 | variables: {}
|
@@ -55,7 +69,74 @@ RocketChat.theme = new class
|
55 | 69 |
|
56 | 70 | RocketChat.settings.updateById 'css', data.css
|
57 | 71 |
|
58 |
| - RocketChat.Notifications.notifyAll 'theme-updated' |
| 72 | + WebAppInternals.staticFiles['/__cordova/theme.css'] = WebAppInternals.staticFiles['/theme.css'] = |
| 73 | + cacheable: true |
| 74 | + sourceMapUrl: undefined |
| 75 | + type: 'css' |
| 76 | + content: data.css |
| 77 | + |
| 78 | + hash = crypto.createHash('sha1').update(data.css).digest('hex') |
| 79 | + |
| 80 | + program = WebApp.clientPrograms['web.cordova'] |
| 81 | + themeManifestItem = _.find program.manifest, (item) -> return item.path is 'app/theme.css' |
| 82 | + themeManifestItem.type = 'css' |
| 83 | + themeManifestItem.where = 'client' |
| 84 | + themeManifestItem.url = "/theme.css?#{hash}" |
| 85 | + themeManifestItem.size = data.css.length |
| 86 | + themeManifestItem.hash = hash |
| 87 | + program.version = WebApp.calculateClientHashCordova() |
| 88 | + |
| 89 | + program = WebApp.clientPrograms['web.browser'] |
| 90 | + themeManifestItem = _.find program.manifest, (item) -> return item.path is 'app/theme.css' |
| 91 | + themeManifestItem.type = 'css' |
| 92 | + themeManifestItem.where = 'client' |
| 93 | + themeManifestItem.url = "/theme.css?#{hash}" |
| 94 | + themeManifestItem.size = data.css.length |
| 95 | + themeManifestItem.hash = hash |
| 96 | + program.version = WebApp.calculateClientHashRefreshable() |
| 97 | + |
| 98 | + Autoupdate.autoupdateVersion = __meteor_runtime_config__.autoupdateVersion = process.env.AUTOUPDATE_VERSION or WebApp.calculateClientHashNonRefreshable() |
| 99 | + Autoupdate.autoupdateVersionRefreshable = __meteor_runtime_config__.autoupdateVersionRefreshable = process.env.AUTOUPDATE_VERSION or WebApp.calculateClientHashRefreshable() |
| 100 | + Autoupdate.autoupdateVersionCordova = __meteor_runtime_config__.autoupdateVersionCordova = process.env.AUTOUPDATE_VERSION or WebApp.calculateClientHashCordova() |
| 101 | + |
| 102 | + # reloadClientPrograms = WebAppInternals.reloadClientPrograms |
| 103 | + # WebAppInternals.reloadClientPrograms = -> |
| 104 | + |
| 105 | + WebAppInternals.generateBoilerplate() |
| 106 | + # process.emit('message', {refresh: 'client'}) |
| 107 | + |
| 108 | + if not ClientVersions.findOne("version")? |
| 109 | + ClientVersions.insert |
| 110 | + _id: "version" |
| 111 | + version: Autoupdate.autoupdateVersion |
| 112 | + else |
| 113 | + ClientVersions.update "version", |
| 114 | + $set: |
| 115 | + version: Autoupdate.autoupdateVersion |
| 116 | + |
| 117 | + if not ClientVersions.findOne("version-cordova")? |
| 118 | + ClientVersions.insert |
| 119 | + _id: "version-cordova" |
| 120 | + version: Autoupdate.autoupdateVersionCordova |
| 121 | + refreshable: false |
| 122 | + else |
| 123 | + ClientVersions.update "version-cordova", |
| 124 | + $set: |
| 125 | + version: Autoupdate.autoupdateVersionCordova |
| 126 | + |
| 127 | + WebApp.onListening -> |
| 128 | + if not ClientVersions.findOne("version-refreshable")? |
| 129 | + ClientVersions.insert |
| 130 | + _id: "version-refreshable" |
| 131 | + version: Autoupdate.autoupdateVersionRefreshable |
| 132 | + assets: WebAppInternals.refreshableAssets |
| 133 | + else |
| 134 | + ClientVersions.update "version-refreshable", |
| 135 | + $set: |
| 136 | + version: Autoupdate.autoupdateVersionRefreshable |
| 137 | + assets: WebAppInternals.refreshableAssets |
| 138 | + |
| 139 | + # RocketChat.Notifications.notifyAll 'theme-updated' |
59 | 140 |
|
60 | 141 | addVariable: (type, name, value, isPublic=true) ->
|
61 | 142 | @variables[name] =
|
@@ -91,13 +172,13 @@ RocketChat.theme = new class
|
91 | 172 | return RocketChat.settings.get 'css'
|
92 | 173 |
|
93 | 174 |
|
94 |
| -WebApp.connectHandlers.use '/theme.css', (req, res, next) -> |
95 |
| - css = RocketChat.theme.getCss() |
| 175 | +# WebApp.rawConnectHandlers.use '/theme.css', (req, res, next) -> |
| 176 | +# css = RocketChat.theme.getCss() |
96 | 177 |
|
97 |
| - res.setHeader 'content-type', 'text/css; charset=UTF-8' |
98 |
| - res.setHeader 'Content-Disposition', 'inline' |
99 |
| - res.setHeader 'Cache-Control', 'no-cache' |
100 |
| - res.setHeader 'Pragma', 'no-cache' |
101 |
| - res.setHeader 'Expires', '0' |
| 178 | +# res.setHeader 'content-type', 'text/css; charset=UTF-8' |
| 179 | +# res.setHeader 'Content-Disposition', 'inline' |
| 180 | +# res.setHeader 'Cache-Control', 'no-cache' |
| 181 | +# res.setHeader 'Pragma', 'no-cache' |
| 182 | +# res.setHeader 'Expires', '0' |
102 | 183 |
|
103 |
| - res.end css |
| 184 | +# res.end css |
0 commit comments