zazu.savanna.get('/config', function (config) { // config MUST be an array with exactly one instance config = config.pop(); if (!config) { return zazu.processControl.error(new Error('Savanna has to contain a config!')); } debug('loaded config: ' + JSON.stringify(config)); var tempDir = path.join(zazu.tempDir, 'dashboard'); var variablesFile = path.join(zazu.baseDir, 'config', 'variables.less'); timon.less([path.join(zazu.baseDir, 'client', 'dashboard.less'), variablesFile], 'dashboard.css', tempDir, { modifyVars: { "zazu-grid-columns": config.gridColumns, "zazu-grid-rows": config.gridRows, "zazu-tiles-gap": config.tilesGap, "zazu-max-number-of-panels": config.maxViews } }).then(function () { debug('Generated dashboard.css'); }, function (err) { zazu.processControl.error('Error generating dashboard.less: ' + err); }); timon.browserify(path.join(zazu.baseDir, 'client', 'dashboard.js'), 'dashboard.js', tempDir).then(function () { debug('Generated dashboard.js'); }, function (err) { zazu.processControl.error('Error generating dashboard.js: ' + err); }); // copy assets var assets = zazu.baseDir + '/client/assets/'; if (fs.existsSync(assets)) { var target = path.join(tempDir, 'assets'); shelljs.mkdir('-p', target); shelljs.cp('-R', assets, target); debug('Copy assets dashboard'); } });
zazu.on(zazu.events.app.loaded, function (appClass, appName, appDir) { appName = zazu.camelToDash(appName); var variablesFile = path.join(zazu.baseDir, 'config', 'variables.less'), file = appDir + '/client/app.less'; // generate css if (fs.existsSync(file)) { timon.less([file, variablesFile], 'app.css', zazu.tempDir + '/' + appName, { modifyVars: { appName: appName } }).then(function () { debug('Generated app ' + appName + '.css'); }, function (err) { zazu.processControl.error(err); }); } //generate js file = appDir + '/client/app.js'; if (fs.existsSync(file)) { timon.browserify(file, 'app.js', zazu.tempDir + '/' + appName).then(function () { debug('Generated app ' + appName + '.js'); }, function (err) { zazu.processControl.error(err); }); } // copy assets file = appDir + '/client/assets/'; if (fs.existsSync(file)) { var target = path.join(zazu.tempDir, appName, 'assets'); shelljs.mkdir('-p', path.join(zazu.tempDir, appName, 'assets')); shelljs.cp('-R', file, target); debug('Copy assets ' + appName); } });