Skip to content
Snippets Groups Projects
Commit 47cba8b0 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Improve theme

parent d0f48c4e
No related branches found
No related tags found
No related merge requests found
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
<link rel="apple-touch-icon" sizes="144x144" href="/images/logo/apple-touch-icon-144x144.png?v=3"> <link rel="apple-touch-icon" sizes="144x144" href="/images/logo/apple-touch-icon-144x144.png?v=3">
<link rel="apple-touch-icon" sizes="152x152" href="/images/logo/apple-touch-icon-152x152.png?v=3"> <link rel="apple-touch-icon" sizes="152x152" href="/images/logo/apple-touch-icon-152x152.png?v=3">
<link rel="apple-touch-icon" sizes="180x180" href="/images/logo/apple-touch-icon-180x180.png?v=3"> <link rel="apple-touch-icon" sizes="180x180" href="/images/logo/apple-touch-icon-180x180.png?v=3">
<link rel="stylesheet" type="text/css" href="/theme.css" id="theme">
</head> </head>
<body> <body>
......
updateTheme = ->
el = $('#theme')[0]
if el
el.href = el.href.replace(/\?.*$/, '') + '?_dc=' + Random.id()
Meteor.startup ->
connected = Meteor.status().connected
Tracker.autorun ->
if connected is false and Meteor.status().connected is true
updateTheme()
connected = Meteor.status().connected
RocketChat.Notifications.onAll 'theme-updated', ->
updateTheme()
...@@ -17,7 +17,6 @@ Package.onUse(function(api) { ...@@ -17,7 +17,6 @@ Package.onUse(function(api) {
api.addFiles('server/server.coffee', 'server'); api.addFiles('server/server.coffee', 'server');
api.addFiles('server/variables.coffee', 'server'); api.addFiles('server/variables.coffee', 'server');
api.addFiles('client/client.coffee', 'client');
api.addFiles('client/minicolors/jquery.minicolors.css', 'client'); api.addFiles('client/minicolors/jquery.minicolors.css', 'client');
api.addFiles('client/minicolors/jquery.minicolors.js', 'client'); api.addFiles('client/minicolors/jquery.minicolors.js', 'client');
......
less = Npm.require('less') less = Npm.require('less')
crypto = Npm.require('crypto')
# program = WebApp.clientPrograms['web.browser']
# themeManifestItem = _.find program.manifest, (item) -> return item.url is '/theme.css'
# themeManifestItem.where = 'client'
# themeManifestItem.type = 'css'
ClientVersions = undefined
_defineMutationMethods = Meteor.Collection.prototype._defineMutationMethods
Meteor.Collection.prototype._defineMutationMethods = ->
if this._name is 'meteor_autoupdate_clientVersions'
ClientVersions = this
_defineMutationMethods.call this
RocketChat.theme = new class RocketChat.theme = new class
variables: {} variables: {}
...@@ -55,7 +69,74 @@ RocketChat.theme = new class ...@@ -55,7 +69,74 @@ RocketChat.theme = new class
RocketChat.settings.updateById 'css', data.css RocketChat.settings.updateById 'css', data.css
RocketChat.Notifications.notifyAll 'theme-updated' WebAppInternals.staticFiles['/__cordova/theme.css'] = WebAppInternals.staticFiles['/theme.css'] =
cacheable: true
sourceMapUrl: undefined
type: 'css'
content: data.css
hash = crypto.createHash('sha1').update(data.css).digest('hex')
program = WebApp.clientPrograms['web.cordova']
themeManifestItem = _.find program.manifest, (item) -> return item.path is 'app/theme.css'
themeManifestItem.type = 'css'
themeManifestItem.where = 'client'
themeManifestItem.url = "/theme.css?#{hash}"
themeManifestItem.size = data.css.length
themeManifestItem.hash = hash
program.version = WebApp.calculateClientHashCordova()
program = WebApp.clientPrograms['web.browser']
themeManifestItem = _.find program.manifest, (item) -> return item.path is 'app/theme.css'
themeManifestItem.type = 'css'
themeManifestItem.where = 'client'
themeManifestItem.url = "/theme.css?#{hash}"
themeManifestItem.size = data.css.length
themeManifestItem.hash = hash
program.version = WebApp.calculateClientHashRefreshable()
Autoupdate.autoupdateVersion = __meteor_runtime_config__.autoupdateVersion = process.env.AUTOUPDATE_VERSION or WebApp.calculateClientHashNonRefreshable()
Autoupdate.autoupdateVersionRefreshable = __meteor_runtime_config__.autoupdateVersionRefreshable = process.env.AUTOUPDATE_VERSION or WebApp.calculateClientHashRefreshable()
Autoupdate.autoupdateVersionCordova = __meteor_runtime_config__.autoupdateVersionCordova = process.env.AUTOUPDATE_VERSION or WebApp.calculateClientHashCordova()
# reloadClientPrograms = WebAppInternals.reloadClientPrograms
# WebAppInternals.reloadClientPrograms = ->
WebAppInternals.generateBoilerplate()
# process.emit('message', {refresh: 'client'})
if not ClientVersions.findOne("version")?
ClientVersions.insert
_id: "version"
version: Autoupdate.autoupdateVersion
else
ClientVersions.update "version",
$set:
version: Autoupdate.autoupdateVersion
if not ClientVersions.findOne("version-cordova")?
ClientVersions.insert
_id: "version-cordova"
version: Autoupdate.autoupdateVersionCordova
refreshable: false
else
ClientVersions.update "version-cordova",
$set:
version: Autoupdate.autoupdateVersionCordova
WebApp.onListening ->
if not ClientVersions.findOne("version-refreshable")?
ClientVersions.insert
_id: "version-refreshable"
version: Autoupdate.autoupdateVersionRefreshable
assets: WebAppInternals.refreshableAssets
else
ClientVersions.update "version-refreshable",
$set:
version: Autoupdate.autoupdateVersionRefreshable
assets: WebAppInternals.refreshableAssets
# RocketChat.Notifications.notifyAll 'theme-updated'
addVariable: (type, name, value, isPublic=true) -> addVariable: (type, name, value, isPublic=true) ->
@variables[name] = @variables[name] =
...@@ -91,13 +172,13 @@ RocketChat.theme = new class ...@@ -91,13 +172,13 @@ RocketChat.theme = new class
return RocketChat.settings.get 'css' return RocketChat.settings.get 'css'
WebApp.connectHandlers.use '/theme.css', (req, res, next) -> # WebApp.rawConnectHandlers.use '/theme.css', (req, res, next) ->
css = RocketChat.theme.getCss() # css = RocketChat.theme.getCss()
res.setHeader 'content-type', 'text/css; charset=UTF-8' # res.setHeader 'content-type', 'text/css; charset=UTF-8'
res.setHeader 'Content-Disposition', 'inline' # res.setHeader 'Content-Disposition', 'inline'
res.setHeader 'Cache-Control', 'no-cache' # res.setHeader 'Cache-Control', 'no-cache'
res.setHeader 'Pragma', 'no-cache' # res.setHeader 'Pragma', 'no-cache'
res.setHeader 'Expires', '0' # res.setHeader 'Expires', '0'
res.end css # res.end css
/*OOOPS*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment