Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Init app

  • Loading branch information...
commit 658a27966ab42273e805681725910d337f693c73 0 parents
g authored
25 application.json
... ... @@ -0,0 +1,25 @@
  1 +[
  2 + {
  3 + "settings": ["master"],
  4 + "yui": {
  5 + "config": {
  6 + "combo": true
  7 + }
  8 + },
  9 + "specs": {
  10 + "weather": {
  11 + "type": "HTMLFrameMojit",
  12 + "config": {
  13 + "title": "Weather",
  14 + "deploy": true,
  15 + "child": {
  16 + "type": "Weather",
  17 + "config": {
  18 + "foo": null
  19 + }
  20 + }
  21 + }
  22 + }
  23 + }
  24 + }
  25 +]
23 index.js
... ... @@ -0,0 +1,23 @@
  1 +/*
  2 + * Copyright (c) 2011-2012, Yahoo! Inc. All rights reserved.
  3 + * Copyrights licensed under the New BSD License.
  4 + * See the accompanying LICENSE file for terms.
  5 + */
  6 +
  7 +
  8 +/*jslint anon:true, sloppy:true, nomen:true, node:true*/
  9 +
  10 +
  11 +process.chdir(__dirname);
  12 +
  13 +
  14 +/**
  15 + * @param {object} config The configuration object containing processing params.
  16 + * @param {object} token Token used to identify the application.
  17 + */
  18 +module.exports = function(config, token) {
  19 + var app = require('./server.js');
  20 +
  21 + // Signal the application is ready, providing the token and app references.
  22 + process.emit('application-ready', token, app);
  23 +};
2  mojits/Weather/assets/index.css
... ... @@ -0,0 +1,2 @@
  1 +dt { font-weight: bold; }
  2 +.sel { background-color: #FF4; }
4 mojits/Weather/autoload/lib.common.js
... ... @@ -0,0 +1,4 @@
  1 +YUI.add('LibCommon', function(Y, NAME)
  2 +{
  3 + Y.log('Common lib loaded.', 'warn');
  4 +}, '0.0.1', {requires: []});
60 mojits/Weather/binders/index.js
... ... @@ -0,0 +1,60 @@
  1 +YUI.add('WeatherBinder', function(Y, NAME)
  2 +{
  3 + Y.namespace('mojito.binders')[NAME] =
  4 + {
  5 + init: function(proxy)
  6 + {
  7 + var self = this,
  8 + form = Y.Node.create('<form><label for=zip>zip</label><input type=text name=zip></form>');
  9 +
  10 + Y.one('body').append(form);
  11 + form.on('submit', self.handleForm, self);
  12 +
  13 + console.log(proxy._mojito, 'warn')
  14 +
  15 + self.proxy = proxy;
  16 + },
  17 +
  18 + handleForm: function(e)
  19 + {
  20 + e.halt();
  21 +
  22 + var self = this,
  23 + form = e.target,
  24 + zip = form.get('zip').get('value');
  25 +
  26 + if(zip)
  27 + {
  28 + self.proxy.refreshView({params:{url:{zip: zip}}});
  29 + }
  30 + },
  31 +
  32 + bind: function(node)
  33 + {
  34 + this.updateTitle();
  35 + },
  36 +
  37 + onRefreshView: function(node, domNode)
  38 + {
  39 + var self = this,
  40 + proxy = self.proxy,
  41 + context = proxy.context;
  42 +
  43 + self.updateTitle();
  44 + /*
  45 + proxy.render('fragment', {
  46 + type: proxy.type,
  47 + config: Y.JSON.stringify(proxy.config),
  48 + lang: context.lang,
  49 + device: context.device
  50 + }, function(err){Y.log(arguments, 'warn')});
  51 + */
  52 + //console.log('refreshed', arguments);
  53 + },
  54 +
  55 + updateTitle: function()
  56 + {
  57 + Y.one('title').setContent(Y.one('h1').getContent());
  58 + }
  59 + };
  60 +}, '0.0.1', {requires: ['mojito-client']});
27 mojits/Weather/controller.common.js
... ... @@ -0,0 +1,27 @@
  1 +YUI.add('mojit', function(Y, NAME)
  2 +{
  3 + Y.mojito.controllers[NAME] =
  4 + {
  5 + init: function(config)
  6 + {
  7 + this.config = config;
  8 + },
  9 +
  10 + index: function(ac)
  11 + {
  12 + var self = this;
  13 +
  14 + ac.models.ModelWeather.getData({zip: ac.params.url('zip') || '90025'}, function(err, res)
  15 + {
  16 + var channel = res.query.results.channel;
  17 + ac.done(Y.merge(ac.context, {
  18 + title: channel.description,
  19 + content: channel.item.description,
  20 + config: Y.JSON.stringify(self.config)
  21 + }));
  22 + });
  23 +
  24 + ac.assets.addCss('./index.css');
  25 + }
  26 + };
  27 +}, '0.0.1', {requires: ['json', 'mojito', 'ModelWeather']});
15 mojits/Weather/defaults.json
... ... @@ -0,0 +1,15 @@
  1 +[
  2 + {
  3 + "settings": ["master"],
  4 + "config": {
  5 + "bar": "bar"
  6 + }
  7 + },
  8 + {
  9 + "settings": ["device:iphone"],
  10 + "config": {
  11 + "foo": "shinyfoo",
  12 + "bar": "shinybar"
  13 + }
  14 + }
  15 +]
5 mojits/Weather/definition.json
... ... @@ -0,0 +1,5 @@
  1 +[
  2 + {
  3 + "settings": [ "master" ]
  4 + }
  5 +]
18 mojits/Weather/models/yql.common.js
... ... @@ -0,0 +1,18 @@
  1 +YUI.add('ModelWeather', function(Y, NAME)
  2 +{
  3 + Y.mojito.models[NAME] =
  4 + {
  5 + init: function(config)
  6 + {
  7 + this.config = config;
  8 + },
  9 +
  10 + getData: function(args, cb)
  11 + {
  12 + Y.YQL('select * from weather.forecast where location=' + args.zip, function(res)
  13 + {
  14 + cb(null, res);
  15 + });
  16 + }
  17 + };
  18 +}, '0.0.1', {requires: ['yql']});
12 mojits/Weather/views/fragment.mu.html
... ... @@ -0,0 +1,12 @@
  1 +<div>
  2 + <dl>
  3 + <dt>mojit</dt>
  4 + <dd>{{type}}</dd>
  5 + <dt>config</dt>
  6 + <dd>{{config}}</dd>
  7 + <dt>lang</dt>
  8 + <dd>{{lang}}</dd>
  9 + <dt>device</dt>
  10 + <dd>{{device}}</dd>
  11 + </dl>
  12 +</div>
12 mojits/Weather/views/index.mu.html
... ... @@ -0,0 +1,12 @@
  1 +<div id="{{mojit_view_id}}">
  2 + <h1>{{title}}</h1>
  3 + {{{content}}}
  4 + <dl>
  5 + <dt>config</dt>
  6 + <dd>{{config}}</dd>
  7 + <dt>lang</dt>
  8 + <dd>{{lang}}</dd>
  9 + <dt>device</dt>
  10 + <dd>{{device}}</dd>
  11 + </dl>
  12 +</div>
24 package.json
... ... @@ -0,0 +1,24 @@
  1 +{
  2 + "name": "mojito",
  3 + "description": "My Mojito application",
  4 + "version": "0.0.1",
  5 + "author": {
  6 + "name": "Your Name",
  7 + "email": "nobody@yahoo-inc.com"
  8 + },
  9 + "contributors": [
  10 + {
  11 + "name": "Your Name",
  12 + "email": "nobody@yahoo-inc.com"
  13 + }
  14 + ],
  15 + "dependencies": {
  16 + "mojito": ">= 0.1.0"
  17 + },
  18 + "engines": {
  19 + "node": ">= 0.4.2 < 0.5.0"
  20 + },
  21 + "scripts": {
  22 + "start": "mojito start"
  23 + }
  24 +}
8 routes.json
... ... @@ -0,0 +1,8 @@
  1 +[{
  2 + "settings": [ "master" ],
  3 + "home": {
  4 + "verbs": ["get"],
  5 + "path": "/",
  6 + "call": "weather.index"
  7 + }
  8 +}]
1  server.js
... ... @@ -0,0 +1 @@
  1 +module.exports = require('/usr/local/lib/node_modules/mojito').createServer();
3  start.js
... ... @@ -0,0 +1,3 @@
  1 +require('./server.js').listen(8777, null, function() {
  2 +
  3 +});

0 comments on commit 658a279

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