Skip to content

Commit 3ed3d59

Browse files
committed
Merge pull request RocketChat#1122 from RocketChat/hotfix/theme
Improve theme
2 parents 4500932 + 47cba8b commit 3ed3d59

File tree

5 files changed

+91
-26
lines changed

5 files changed

+91
-26
lines changed

client/views/main.html

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
<link rel="apple-touch-icon" sizes="144x144" href="/images/logo/apple-touch-icon-144x144.png?v=3">
3535
<link rel="apple-touch-icon" sizes="152x152" href="/images/logo/apple-touch-icon-152x152.png?v=3">
3636
<link rel="apple-touch-icon" sizes="180x180" href="/images/logo/apple-touch-icon-180x180.png?v=3">
37-
<link rel="stylesheet" type="text/css" href="/theme.css" id="theme">
3837
</head>
3938

4039
<body>

packages/rocketchat-theme/client/client.coffee

-15
This file was deleted.

packages/rocketchat-theme/package.js

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Package.onUse(function(api) {
1717
api.addFiles('server/server.coffee', 'server');
1818
api.addFiles('server/variables.coffee', 'server');
1919

20-
api.addFiles('client/client.coffee', 'client');
2120
api.addFiles('client/minicolors/jquery.minicolors.css', 'client');
2221
api.addFiles('client/minicolors/jquery.minicolors.js', 'client');
2322

packages/rocketchat-theme/server/server.coffee

+90-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
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
216

317
RocketChat.theme = new class
418
variables: {}
@@ -55,7 +69,74 @@ RocketChat.theme = new class
5569

5670
RocketChat.settings.updateById 'css', data.css
5771

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'
59140

60141
addVariable: (type, name, value, isPublic=true) ->
61142
@variables[name] =
@@ -91,13 +172,13 @@ RocketChat.theme = new class
91172
return RocketChat.settings.get 'css'
92173

93174

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()
96177

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'
102183

103-
res.end css
184+
# res.end css

public/theme.css

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*OOOPS*/

0 commit comments

Comments
 (0)