serve theme.css through WebApp.rawConnectHandlers

pull/4981/head
David Renshaw 9 years ago
parent e677af8ae4
commit f6d4e4fbed
  1. 18
      packages/rocketchat-theme/server/server.coffee

@ -8,17 +8,23 @@ logger = new Logger 'rocketchat:theme',
type: 'info'
WebApp.rawConnectHandlers.use (req, res, next) ->
path = req.url.split("?")[0];
if (path == '/__cordova/theme.css' || path == '/theme.css')
css = RocketChat.theme.getCss()
hash = crypto.createHash('sha1').update(css).digest('hex')
res.setHeader('Content-Type', 'text/css; charset=UTF-8')
res.setHeader('ETag', '"' + hash + '"')
res.write(css)
res.end();
else
next()
calculateClientHash = WebAppHashing.calculateClientHash
WebAppHashing.calculateClientHash = (manifest, includeFilter, runtimeConfigOverride) ->
css = RocketChat.theme.getCss()
if css.trim() isnt ''
WebAppInternals.staticFiles['/__cordova/theme.css'] = WebAppInternals.staticFiles['/theme.css'] =
cacheable: true
sourceMapUrl: undefined
type: 'css'
content: css
hash = crypto.createHash('sha1').update(css).digest('hex')
themeManifestItem = _.find manifest, (item) -> return item.path is 'app/theme.css'

Loading…
Cancel
Save