Skip to content

Instantly share code, notes, and snippets.

@redonkulus
Created October 19, 2012 20:32
Show Gist options
  • Save redonkulus/3920557 to your computer and use it in GitHub Desktop.
Save redonkulus/3920557 to your computer and use it in GitHub Desktop.
Routes.json
[{
"settings": [ "master" ],
"single": {
"verbs" : [ "get" ],
"path" : "/",
"call" : "single.index"
},
"composite": {
"verbs" : [ "get" ],
"path" : "/multiple",
"call" : "multiple.index"
}
}]
App.json
[
{
"settings": [ "master" ],
"log": {
"client": {
"level": "none",
"yui": false
},
"server": {
"level": "error",
"yui": false
}
},
"specs": {
"single": {
"type": "HTMLFrameMojit",
"config": {
"deploy": true,
"title": "Test Mojito App",
"child": {
"type": "page",
"config": {
"children": {
"weather" : {
"type": "weather",
"action": "index"
},
"stream" : {
"type": "stream",
"action": "index"
}
}
}
},
"assets": {
"top": {
"css": [
"/static/mojito/assets/main.css"
]
}
}
}
},
"multiple": {
"type": "HTMLFrameMojit",
"config": {
"title": "Composite Mojits - Test Mojito Perf",
"child": {
"type": "page"
},
"assets": {
"top": {
"css": [
"/static/mojito/assets/main.css"
]
}
}
}
}
}
}
]
Page controller:
YUI.add('page', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
index: function(ac) {
var x,
count = ac.params.getFromUrl('count') || 1,
children = ac.config.get('children'),
cfg = {
"children" : {}
};
// if children passed in, then use that
if (children !== undefined) {
cfg.children = children;
// otherwise generate children dynamically
} else {
for (x=1; x <= count; x++) {
cfg.children['mojit' + x] = { "type" : "weather" };
}
}
ac.composite.execute(cfg, function executeChildren(data, meta) {
ac.done(Y.Object.values(data).join(''), meta);
});
}
};
}, '0.0.1', {requires: [
'mojito',
'mojito-composite-addon',
'mojito-config-addon',
'mojito-params-addon',
]});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment