Skip to content

Commit

Permalink
Changed config so that IntlHTMLFrameMojit uses 'children' instead of …
Browse files Browse the repository at this point in the history
…a 'child' object.
  • Loading branch information
Joe Catera committed Jan 30, 2013
1 parent e66f13d commit 4da8f7d
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 35 deletions.
24 changes: 9 additions & 15 deletions frame_app/application.json
Expand Up @@ -6,21 +6,15 @@
"ms": {
"type": "IntlHTMLFrameMojit",
"config": {
"title": "Title of HTML page",
"child" : {
"type" : "FrameMojit",
"config": {
"children": {
"header": {
"type": "HeaderMojit"
},
"body": {
"type": "BodyMojit"
},
"footer": {
"type": "FooterMojit"
}
}
"children": {
"header": {
"type": "HeaderMojit"
},
"body": {
"type": "BodyMojit"
},
"footer": {
"type": "FooterMojit"
}
}
}
Expand Down
36 changes: 36 additions & 0 deletions frame_app/backup_application.json
@@ -0,0 +1,36 @@
[
{
"settings": [ "master" ],
"appPort": "8666",
"specs": {
"ms": {
"type": "IntlHTMLFrameMojit",
"config": {
"title": "Title of HTML page",
"child" : {
"type" : "FrameMojit",
"config": {
"children": {
"header": {
"type": "HeaderMojit"
},
"body": {
"type": "BodyMojit"
},
"footer": {
"type": "FooterMojit"
}
}
}
}
}
}
}
},
{
"settings": [ "environment:development" ],
"staticHandling": {
"forceUpdate": true
}
}
]
116 changes: 116 additions & 0 deletions frame_app/mojits/IntlHTMLFrameMojit/backup_controller
@@ -0,0 +1,116 @@
/*
* Copyright (c) 2011-2013, Yahoo! Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/


/*jslint anon:true, sloppy:true, nomen:true*/
/*global YUI*/


YUI.add('IntlHTMLFrameMojit', function (Y, NAME) {

'use strict';

Y.namespace('mojito.controllers')[NAME] = {

index: function (ac) {
this.__call(ac);
},

__call: function (ac) {

Y.log('executing IntlHTMLFrameMojit child', 'mojito', 'qeperf');

this._renderChild(ac, function (data, meta) {

// meta.assets from child should be piped into
// the frame's assets before doing anything else.
ac.assets.addAssets(meta.assets);

// SHAKER RUNTIME!
// NOTE: We move the deployment of the client to within Shaker addon...
ac.shaker.run(meta);

Y.log('IntlHTMLFrameMojit done()', 'mojito', 'qeperf');

// 1. mixing bottom and top fragments from assets into
// the template data, along with title and mojito version.
// 2. mixing meta with child metas, along with some extra
// headers.
ac.done(
Y.merge(data, ac.assets.renderLocations(), {
"name": "IntlHtmlFrameMojit",
"greeting": ac.intl.lang("GREETING"),
"says": ac.intl.lang("SAYS"),
"preposition": ac.intl.lang("PREPOSITION"),
"today": ac.intl.formatDate(new Date()),
"enableDynamicTitle": ac.config.get('enableDynamicTitle'),
"mojito_version": Y.mojito.version

}),
Y.merge(meta, {

http: {
headers: {
'content-type': 'text/html; charset="utf-8"'
}
},

view: {
name: 'index'
}

})
);

});

},

/**
* Renders a child mojit based on a config called "child" and
* the "assets" collection specified in the specs.
* @method _renderChild
* @protected
* @param {Object} ac Action Context Object.
* @param {Function} callback The callback.
*/
_renderChild: function (ac, callback) {
// Grab the "child" from the config an add it as the
// only item in the "children" map.
// var child = ac.config.get('child'),
var children = ac.config.get('children'),
cfg;

// Map the action to the child if the action
// is not specified as part of the child config.
child.action = child.action || ac.action;
Y.log(children);
// Create a config object for the composite addon
/*
cfg = {
children: {
child: child
},
assets: ac.config.get('assets')
};
*/

cfg = { children, assets: ac.config.get('assets')};
// Now execute the child as a composite
ac.composite.execute(cfg, callback);
}

};

}, '0.1.0', {requires: [
'mojito',
'mojito-assets-addon',
'mojito-deploy-addon',
'mojito-config-addon',
'mojito-composite-addon',
'mojito-shaker-addon',
'mojito-intl-addon'
]});
18 changes: 4 additions & 14 deletions frame_app/mojits/IntlHTMLFrameMojit/controller.server.js
Expand Up @@ -80,21 +80,11 @@ YUI.add('IntlHTMLFrameMojit', function (Y, NAME) {
_renderChild: function (ac, callback) {
// Grab the "child" from the config an add it as the
// only item in the "children" map.
var child = ac.config.get('child'),
// var child = ac.config.get('child'),
var children = ac.config.get('children'),
cfg;

// Map the action to the child if the action
// is not specified as part of the child config.
child.action = child.action || ac.action;

// Create a config object for the composite addon
cfg = {
children: {
child: child
},
assets: ac.config.get('assets')
};


cfg = { children: children, assets: ac.config.get('assets')};
// Now execute the child as a composite
ac.composite.execute(cfg, callback);
}
Expand Down
26 changes: 26 additions & 0 deletions frame_app/mojits/IntlHTMLFrameMojit/views/backup_template
@@ -0,0 +1,26 @@
<html>
<head>
<script type="text/javascript">var MOJITO_INIT=new Date().getTime();</script>
{{#meta}}
<meta name="{{name}}" content="{{content}}">
{{/meta}}
{{^meta}}
<meta name="creator" content="Yahoo! Mojito {{mojito_version}}">
{{/meta}}

<title>{{title}}</title>

{{{top}}}

</head>
<body>
<div id="intl_frame" class="header" style="border: dashed black 1px; margin: 10px 10px 10px 10px;">
<h3>{{{name}}} {{{says}} {{{greeting}}} {{{preposition}}} {{{today}}}</h3>

{{{child}}}

{{{bottom}}}
</div>

</body>
</html>
19 changes: 14 additions & 5 deletions frame_app/mojits/IntlHTMLFrameMojit/views/index.hb.html
@@ -1,3 +1,5 @@


<html>
<head>
<script type="text/javascript">var MOJITO_INIT=new Date().getTime();</script>
Expand All @@ -16,11 +18,18 @@
<body>
<div id="intl_frame" class="header" style="border: dashed black 1px; margin: 10px 10px 10px 10px;">
<h3>{{{name}}} {{{says}} {{{greeting}}} {{{preposition}}} {{{today}}}</h3>

{{{child}}}

{{{bottom}}}
<div id="{{mojit_view_id}}" class="mojit" style="border: dashed black 1px;">
<h1>{{title}}</h1>
<div class="header" style="border: dashed black 1px; margin: 10px 10px 10px 10px;">
{{{header}}}
</div>
<div class="body" style="border: dashed black 1px; margin: 10px 10px 10px 10px;">
{{{body}}}
</div>
<div class="footer" style="border: dashed black 1px; margin: 10px 10px 10px 10px;">
{{{footer}}}
</div>
</div>
</div>

</body>
</html>
3 changes: 2 additions & 1 deletion frame_app/package.json
Expand Up @@ -13,7 +13,8 @@
}
],
"dependencies": {
"mojito": "0.5.x"
"mojito": "0.5.x",
"shaker": "3.0.x"
},
"engines": {
"node": ">0.6"
Expand Down

0 comments on commit 4da8f7d

Please sign in to comment.