Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Init app

  • Loading branch information...
commit 658a27966ab42273e805681725910d337f693c73 0 parents
g authored
25 application.json
@@ -0,0 +1,25 @@
+[
+ {
+ "settings": ["master"],
+ "yui": {
+ "config": {
+ "combo": true
+ }
+ },
+ "specs": {
+ "weather": {
+ "type": "HTMLFrameMojit",
+ "config": {
+ "title": "Weather",
+ "deploy": true,
+ "child": {
+ "type": "Weather",
+ "config": {
+ "foo": null
+ }
+ }
+ }
+ }
+ }
+ }
+]
23 index.js
@@ -0,0 +1,23 @@
+/*
+ * 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, nomen:true, node:true*/
+
+
+process.chdir(__dirname);
+
+
+/**
+ * @param {object} config The configuration object containing processing params.
+ * @param {object} token Token used to identify the application.
+ */
+module.exports = function(config, token) {
+ var app = require('./server.js');
+
+ // Signal the application is ready, providing the token and app references.
+ process.emit('application-ready', token, app);
+};
2  mojits/Weather/assets/index.css
@@ -0,0 +1,2 @@
+dt { font-weight: bold; }
+.sel { background-color: #FF4; }
4 mojits/Weather/autoload/lib.common.js
@@ -0,0 +1,4 @@
+YUI.add('LibCommon', function(Y, NAME)
+{
+ Y.log('Common lib loaded.', 'warn');
+}, '0.0.1', {requires: []});
60 mojits/Weather/binders/index.js
@@ -0,0 +1,60 @@
+YUI.add('WeatherBinder', function(Y, NAME)
+{
+ Y.namespace('mojito.binders')[NAME] =
+ {
+ init: function(proxy)
+ {
+ var self = this,
+ form = Y.Node.create('<form><label for=zip>zip</label><input type=text name=zip></form>');
+
+ Y.one('body').append(form);
+ form.on('submit', self.handleForm, self);
+
+ console.log(proxy._mojito, 'warn')
+
+ self.proxy = proxy;
+ },
+
+ handleForm: function(e)
+ {
+ e.halt();
+
+ var self = this,
+ form = e.target,
+ zip = form.get('zip').get('value');
+
+ if(zip)
+ {
+ self.proxy.refreshView({params:{url:{zip: zip}}});
+ }
+ },
+
+ bind: function(node)
+ {
+ this.updateTitle();
+ },
+
+ onRefreshView: function(node, domNode)
+ {
+ var self = this,
+ proxy = self.proxy,
+ context = proxy.context;
+
+ self.updateTitle();
+ /*
+ proxy.render('fragment', {
+ type: proxy.type,
+ config: Y.JSON.stringify(proxy.config),
+ lang: context.lang,
+ device: context.device
+ }, function(err){Y.log(arguments, 'warn')});
+ */
+ //console.log('refreshed', arguments);
+ },
+
+ updateTitle: function()
+ {
+ Y.one('title').setContent(Y.one('h1').getContent());
+ }
+ };
+}, '0.0.1', {requires: ['mojito-client']});
27 mojits/Weather/controller.common.js
@@ -0,0 +1,27 @@
+YUI.add('mojit', function(Y, NAME)
+{
+ Y.mojito.controllers[NAME] =
+ {
+ init: function(config)
+ {
+ this.config = config;
+ },
+
+ index: function(ac)
+ {
+ var self = this;
+
+ ac.models.ModelWeather.getData({zip: ac.params.url('zip') || '90025'}, function(err, res)
+ {
+ var channel = res.query.results.channel;
+ ac.done(Y.merge(ac.context, {
+ title: channel.description,
+ content: channel.item.description,
+ config: Y.JSON.stringify(self.config)
+ }));
+ });
+
+ ac.assets.addCss('./index.css');
+ }
+ };
+}, '0.0.1', {requires: ['json', 'mojito', 'ModelWeather']});
15 mojits/Weather/defaults.json
@@ -0,0 +1,15 @@
+[
+ {
+ "settings": ["master"],
+ "config": {
+ "bar": "bar"
+ }
+ },
+ {
+ "settings": ["device:iphone"],
+ "config": {
+ "foo": "shinyfoo",
+ "bar": "shinybar"
+ }
+ }
+]
5 mojits/Weather/definition.json
@@ -0,0 +1,5 @@
+[
+ {
+ "settings": [ "master" ]
+ }
+]
18 mojits/Weather/models/yql.common.js
@@ -0,0 +1,18 @@
+YUI.add('ModelWeather', function(Y, NAME)
+{
+ Y.mojito.models[NAME] =
+ {
+ init: function(config)
+ {
+ this.config = config;
+ },
+
+ getData: function(args, cb)
+ {
+ Y.YQL('select * from weather.forecast where location=' + args.zip, function(res)
+ {
+ cb(null, res);
+ });
+ }
+ };
+}, '0.0.1', {requires: ['yql']});
12 mojits/Weather/views/fragment.mu.html
@@ -0,0 +1,12 @@
+<div>
+ <dl>
+ <dt>mojit</dt>
+ <dd>{{type}}</dd>
+ <dt>config</dt>
+ <dd>{{config}}</dd>
+ <dt>lang</dt>
+ <dd>{{lang}}</dd>
+ <dt>device</dt>
+ <dd>{{device}}</dd>
+ </dl>
+</div>
12 mojits/Weather/views/index.mu.html
@@ -0,0 +1,12 @@
+<div id="{{mojit_view_id}}">
+ <h1>{{title}}</h1>
+ {{{content}}}
+ <dl>
+ <dt>config</dt>
+ <dd>{{config}}</dd>
+ <dt>lang</dt>
+ <dd>{{lang}}</dd>
+ <dt>device</dt>
+ <dd>{{device}}</dd>
+ </dl>
+</div>
24 package.json
@@ -0,0 +1,24 @@
+{
+ "name": "mojito",
+ "description": "My Mojito application",
+ "version": "0.0.1",
+ "author": {
+ "name": "Your Name",
+ "email": "nobody@yahoo-inc.com"
+ },
+ "contributors": [
+ {
+ "name": "Your Name",
+ "email": "nobody@yahoo-inc.com"
+ }
+ ],
+ "dependencies": {
+ "mojito": ">= 0.1.0"
+ },
+ "engines": {
+ "node": ">= 0.4.2 < 0.5.0"
+ },
+ "scripts": {
+ "start": "mojito start"
+ }
+}
8 routes.json
@@ -0,0 +1,8 @@
+[{
+ "settings": [ "master" ],
+ "home": {
+ "verbs": ["get"],
+ "path": "/",
+ "call": "weather.index"
+ }
+}]
1  server.js
@@ -0,0 +1 @@
+module.exports = require('/usr/local/lib/node_modules/mojito').createServer();
3  start.js
@@ -0,0 +1,3 @@
+require('./server.js').listen(8777, null, function() {
+
+});

0 comments on commit 658a279

Please sign in to comment.
Something went wrong with that request. Please try again.