Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #643 from isao/createbuild
Browse files Browse the repository at this point in the history
new archetype: mojito create app hybrid myapp
new build type: mojito build hybrid path/to/packages/dir
new custom archetypes: mojito create custom path/to/your/archetype mything
  • Loading branch information
Isao Yagi committed Oct 22, 2012
2 parents 936326d + 08d9a71 commit a87ac15
Show file tree
Hide file tree
Showing 24 changed files with 1,014 additions and 669 deletions.
31 changes: 31 additions & 0 deletions lib/app/archetypes/app/hybrid/application.json.hb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[
{
"settings": [ "master" ],

"appPort": {{port}},

"specs": {
"frame": {
"base": "top_frame"
}
},

"staticHandling": {
"appName": "yahoo.application.{{name}}",
"prefix": "yahoo.application.{{name}}"
},

"builds": {
"hybridapp": {
"urls": ["/yahoo.application.{{name}}/index.html"]
}
},

"yui": {
"dependencyCalculations": "precomputed+ondemand",
"base": "/yahoo.libs.yui/",
"url": "$$yui.base$$yui/yui-min.js",
"loader": "loader/loader-min.js"
}
}
]
Binary file added lib/app/archetypes/app/hybrid/assets/favicon.ico
Binary file not shown.
57 changes: 57 additions & 0 deletions lib/app/archetypes/app/hybrid/mojits/top_frame/binders/index.js.hb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2012 Yahoo! Inc. All rights reserved.
*/
/*jslint anon:true, sloppy:true, nomen:true*/
YUI.add('top_frameBinderIndex', function(Y, NAME) {

/**
* The top_frameBinderIndex module.
*
* @module top_frameBinderIndex
*/

/**
* Constructor for the top_frameBinderIndex class.
*
* @class top_frameBinderIndex
* @constructor
*/
Y.namespace('mojito.binders')[NAME] = {

/**
* Binder initialization method, invoked after all binders on the page
* have been constructed.
*/
init: function(mojitProxy) {
this.mojitProxy = mojitProxy;
},

/**
* The binder method, invoked to allow the mojit to attach DOM event
* handlers.
*
* @param node {Node} The DOM node to which this mojit is attached.
*/
bind: function(node) {
var me = this;
this.node = node;
/**
* Example code for the bind method:
*
* node.all('dt').on('mouseenter', function(evt) {
* var dd = '#dd_' + evt.target.get('text');
* me.node.one(dd).addClass('sel');
*
* });
* node.all('dt').on('mouseleave', function(evt) {
*
* var dd = '#dd_' + evt.target.get('text');
* me.node.one(dd).removeClass('sel');
*
* });
*/
}

};

}, '0.0.1', {requires: ['event-mouseenter', 'mojito-client']});
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2012 Yahoo! Inc. All rights reserved.
*/
/*jslint anon:true, sloppy:true, nomen:true*/
YUI.add('top_frame', function(Y, NAME) {

/**
* The top_frame module.
*
* @module top_frame
*/

/**
* Constructor for the Controller class.
*
* @class Controller
* @constructor
*/
Y.namespace('mojito.controllers')[NAME] = {

init: function(config) {
this.config = config;
},

/**
* Method corresponding to the 'index' action.
*
* @param ac {Object} The ActionContext that provides access
* to the Mojito API.
*/
index: function(ac) {
ac.models.top_frameModelFoo.getData(function(err, data) {
if (err) {
return ac.error(err);
}

ac.done({
status: 'Mojito is working.',
data: data
});
});
}

};

}, '0.0.1', {requires: ['mojito', 'top_frameModelFoo']});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{
"settings": [ "master" ]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2012 Yahoo! Inc. All rights reserved.
*/
/*jslint anon:true, sloppy:true, nomen:true*/
YUI.add('top_frameModelFoo', function(Y, NAME) {

/**
* The top_frameModelFoo module.
*
* @module top_frame
*/

/**
* Constructor for the top_frameModelFoo class.
*
* @class top_frameModelFoo
* @constructor
*/
Y.namespace('mojito.models')[NAME] = {

init: function(config) {
this.config = config;
},

/**
* Method that will be invoked by the mojit controller to obtain data.
*
* @param callback {function(err,data)} The callback function to call when the
* data has been retrieved.
*/
getData: function(callback) {
callback(null, { some: 'data' });
}

};

}, '0.0.1', {requires: []});
23 changes: 23 additions & 0 deletions lib/app/archetypes/app/hybrid/mojits/top_frame/package.json.hb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "top_frame",
"version": "0.0.1",
"pkg_type": "frame",
"description": "The {{name}} application's top frame (HTMLFrameMojit)",
"engines": {
"node": ">0.6",
"npm": ">1.0",
"mojito": ">0.4"
},
"maintainers": [
{
"email": "[email protected]",
"name": "Your Name"
}
],
"yahoo": {
"mojito": {
"package": "public",
"version": ">0.4"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"settings": [ "master" ],

"type": "HTMLFrameMojit",
"config": {
"deploy": true,
"title": "{{name}} App",
"child": {
"type": "top_frame"
},
"assets": {
"bottom": {
"js": ["/yahoo.crt.lib/yui-cfg.js"]
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2012 Yahoo! Inc. All rights reserved.
*/

YUI.add('top_frame-tests', function(Y) {

var suite = new YUITest.TestSuite('top_frame-tests'),
controller = null,
A = YUITest.Assert;

suite.add(new YUITest.TestCase({

name: 'top_frame user tests',

setUp: function() {
controller = Y.mojito.controllers.top_frame;
},
tearDown: function() {
controller = null;
},

'test mojit': function() {
var ac,
modelData,
assetsResults,
doneResults;
modelData = { x:'y' };
ac = {
assets: {
addCss: function(css) {
assetsResults = css;
}
},
models: {
top_frameModelFoo: {
getData: function(cb) {
cb(null, modelData);
}
}
},
done: function(data) {
doneResults = data;
}
};

A.isNotNull(controller);
A.isFunction(controller.index);
controller.index(ac);
A.areSame('./index.css', assetsResults);
A.isObject(doneResults);
A.areSame('Mojito is working.', doneResults.status);
A.isObject(doneResults.data);
A.isTrue(doneResults.data.hasOwnProperty('x'));
A.areEqual('y', doneResults.data['x']);

}

}));

YUITest.TestRunner.add(suite);

}, '0.0.1', {requires: ['mojito-test', 'top_frame']});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2012 Yahoo! Inc. All rights reserved.
*/

YUI.add('top_frameModelFoo-tests', function(Y, NAME) {

var suite = new YUITest.TestSuite(NAME),
model = null,
A = YUITest.Assert;

suite.add(new YUITest.TestCase({

name: 'top_frameModelFoo user tests',

setUp: function() {
model = Y.mojito.models.top_frameModelFoo;
},
tearDown: function() {
model = null;
},

'test mojit model': function() {
var called = false;
A.isNotNull(model);
A.isFunction(model.getData);
model.getData(function(err, data) {
called = true;
A.isTrue(!err);
A.isObject(data);
A.areSame('data', data.some);
});
A.isTrue(called);
}

}));

YUITest.TestRunner.add(suite);

}, '0.0.1', {requires: ['mojito-test', 'top_frameModelFoo']});
10 changes: 10 additions & 0 deletions lib/app/archetypes/app/hybrid/mojits/top_frame/views/index.hb.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div id="{{mojit_view_id}}">
<dl>
<dt>status</dt>
<dd id="dd_status">{{status}}</dd>
<dt>data</dt>
<dd id="dd_data">
<b>some:</b> {{#data}}{{some}}{{/data}}
</dd>
</dl>
</div>
17 changes: 17 additions & 0 deletions lib/app/archetypes/app/hybrid/package.json.hb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "yahoo.application.{{name}}",
"author": "Your Name <[email protected]>",
"description": "This application's main package: yahoo.application.{{name}}",
"version": "0.0.1",
"type": "application",
"pkg_type": "application",
"dependencies": {
"mojito": ">0.4",
"yahoo.libs.yui": "*"
},
"engines": {
"node": ">0.6",
"npm": ">1.0",
"mojito": ">0.4"
}
}
23 changes: 23 additions & 0 deletions lib/app/archetypes/app/hybrid/routes.json.hb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"settings": [ "master" ],

"root": {
"verbs": ["get"],
"path": "/",
"call": "frame.index"
},

"yahoo.application.{{name}}": {
"verbs": ["get"],
"path": "/yahoo.application.{{name}}/index.html",
"call": "frame.index"
},

"any mojit/action": {
"verbs": [ "GET" ],
"path": "/:module/:action",
"call": "{module}.{action}"
}
}
]
17 changes: 17 additions & 0 deletions lib/app/archetypes/app/hybrid/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2011-2012, Yahoo! Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/


/*jslint anon:true, sloppy:true*/


/**
* Create and start a new Mojito server/application.
*/
var Mojito = require('mojito');
var app = Mojito.createServer();

module.exports = app.start();
Loading

0 comments on commit a87ac15

Please sign in to comment.