Skip to content

anonymous /gist:5777728
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
/*jslint node:true, nomen:true */
var combo = require("combo-js-css"),
defaultConfig = {
baseComboPath:"/cb",
jsComboPath:"/js/",
cssComboPath:"/css/",
pathSets:[
{
"rootPath":"/mojits",
"cssRootPath":"/",
"jsRootPath":"/"
},
{
"rootPath":"/assets",
"cssRootPath":"/",
"jsRootPath":"/"
}
]
},
config;
function setupConfig(app){
var store = app.store,
appConfig = store.getStaticAppConfig(),
yuiDetails = store.yui.getYUIURLDetails(),
staticDetails = store.getAllURLDetails();
config = merge(
defaultConfig,
appConfig.comboJsCss,
{
staticDescriptor: merge(yuiDetails, staticDetails),
staticStore: store.yui.resContents
}
);
for( var n in store.yui.resContents){
console.log(n);
}
combo.config.updateConfigFromParams(config);
}
function merge(){
var finalObj = {};
for( var i = 0, ln = arguments.length; i < ln; i++){
if(arguments[i]){
copy(finalObj, arguments[i]);
}
}
return finalObj;
}
function copy(tar, src){
for( var n in src){
if(src.hasOwnProperty(n)){
tar[n] = src[n];
}
}
}
module.exports = function (req, res, next) {
if(!config){
setupConfig(req.app);
}
if(!req.url.indexOf(config.baseComboPath + config.jsComboPath)){
console.log("serving JS from combo service");
combo.combo.comboReq(req, res, combo.config.types.JS, combo.config);
return true;
}
if(!req.url.indexOf(config.baseComboPath + config.jsComboPath)){
combo.combo.comboReq(req, res, combo.config.types.CSS, combo.config);
return true;
}
next();
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.