Gitter migration: Setup redirects (rollout pt. 3)
[gitter.git] / server / handlers / renderers / sub-resources.js
blob16415277d1ef62f4e86747a4f5f72ca33d123bc3
1 'use strict';
3 var cdn = require('gitter-web-cdn');
5 function cdnSubResources(resources, jsRoot) {
6 var resourceList = [];
7 if (resources) {
8 resourceList = resourceList.concat(resources);
11 return resourceList
12 .map(function(f) {
13 return cdn(jsRoot + '/' + f + '.js');
15 .concat(cdn('fonts/sourcesans/SourceSansPro-Regular.otf.woff'));
18 var SUBRESOURCE_MAPPINGS = {};
20 var CACHED_SUBRESOURCES = Object.keys(SUBRESOURCE_MAPPINGS).reduce(function(memo, key) {
21 memo[key] = cdnSubResources(SUBRESOURCE_MAPPINGS[key], 'js');
22 return memo;
23 }, {});
25 function getSubResources(entryPoint, jsRoot) {
26 if (!jsRoot) {
27 return CACHED_SUBRESOURCES[entryPoint];
30 return cdnSubResources(SUBRESOURCE_MAPPINGS[entryPoint], jsRoot);
33 module.exports = getSubResources;