Permalink
Browse files

adding demo for secure settings screencast

  • Loading branch information...
1 parent e086dae commit 71d0c3aaa0c76bb11751b123b73e3e26f27278ef @caridy committed Aug 3, 2012
@@ -0,0 +1,40 @@
+[
+ {
+ "settings": [ "master" ],
+ "specs": {
+ "foo": {
+ "type": "Foo",
+ "config": {
+ "public1": "public1value",
+ "global": "fooGlobalSetting"
+ }
+ },
+ "page": {
+ "type": "HTMLFrameMojit",
+ "config": {
+ "deploy": true,
+ "child": {
+ "base": "foo"
+ }
+ }
+ }
+ }
+ },
+ {
+ "settings": [ "environment:development" ],
+ "staticHandling": {
+ "forceUpdate": true
+ }
+ },
+ {
+ "settings": [ "runtime:server" ],
+ "business": {
+ "logic": {
+ "secret2": "secret2value"
+ }
+ },
+ "fooGlobalSetting": {
+ "secret1": "secret1value"
+ }
+ }
+]
Binary file not shown.
@@ -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);
+};
@@ -0,0 +1,2 @@
+dt { font-weight: bold; }
+.sel { background-color: #FF4; }
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('FooBinderIndex', function(Y, NAME) {
+
+/**
+ * The FooBinderIndex module.
+ *
+ * @module FooBinderIndex
+ */
+
+ /**
+ * Constructor for the FooBinderIndex class.
+ *
+ * @class FooBinderIndex
+ * @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;
+ 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']});
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('Foo', function(Y, NAME) {
+
+/**
+ * The Foo module.
+ *
+ * @module Foo
+ */
+
+ /**
+ * 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) {
+ var public1 = this.config.public1,
+ global = (this.config.global ? ac.app.config[this.config.global] : {}),
+ computed = Y.merge(this.config, global),
+ business = ac.app.config.business,
+ secret1 = computed.secret1,
+ secret3 = ac.config.getDefinition('secret3');
+
+ ac.models.FooModelFoo.getData(function(err, data) {
+ if (err) {
+ ac.error(err);
+ return;
+ }
+ ac.assets.addCss('./index.css');
+ ac.done({
+ status: 'Mojito is working.',
+ data: data,
+ business: JSON.stringify(business),
+ public1: public1,
+ secret1: secret1,
+ secret3: secret3
+ });
+ });
+ }
+
+ };
+
+}, '0.0.1', {requires: ['mojito', 'FooModelFoo']});
@@ -0,0 +1,8 @@
+[
+ {
+ "settings": [ "master" ],
+ "config": {
+ "public1": "default public1 value"
+ }
+ }
+]
@@ -0,0 +1,6 @@
+[
+ {
+ "settings": [ "master" ],
+ "secret3": "secret3value"
+ }
+]
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('FooModelFoo', function(Y, NAME) {
+
+/**
+ * The FooModelFoo module.
+ *
+ * @module Foo
+ */
+
+ /**
+ * Constructor for the FooModelFoo class.
+ *
+ * @class FooModelFoo
+ * @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: []});
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+YUI.add('FooBinderIndex-tests', function(Y, NAME) {
+
+ var suite = new YUITest.TestSuite(NAME),
+ binder,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'Foo index binder tests',
+
+ setUp: function() {
+ binder = Y.mojito.binders.FooBinderIndex;
+ },
+ tearDown: function() {
+ binder = null;
+ },
+
+ 'TODO: test update id': function() {
+ var node = Y.Node.create("<div id='guid123'></div>");
+ binder.init({
+ _guid: 'guid123'
+ });
+ binder.bind(node);
+
+ // there is nothing to test in the binder initially
+ A.skip();
+
+ }
+
+ }));
+
+ YUITest.TestRunner.add(suite);
+
+}, '0.0.1', {requires: ['mojito-test', 'node', 'FooBinderIndex']});
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+
+YUI.add('Foo-tests', function(Y) {
+
+ var suite = new YUITest.TestSuite('Foo-tests'),
+ controller = null,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'Foo user tests',
+
+ setUp: function() {
+ controller = Y.mojito.controllers.Foo;
+ },
+ tearDown: function() {
+ controller = null;
+ },
+
+ 'test mojit': function() {
+ var ac,
+ modelData,
+ assetsResults,
+ doneResults;
+ modelData = { x:'y' };
+ ac = {
+ assets: {
+ addCss: function(css) {
+ assetsResults = css;
+ }
+ },
+ models: {
+ FooModelFoo: {
+ 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', 'Foo']});
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+
+YUI.add('FooModelFoo-tests', function(Y, NAME) {
+
+ var suite = new YUITest.TestSuite(NAME),
+ model = null,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'FooModelFoo user tests',
+
+ setUp: function() {
+ model = Y.mojito.models.FooModelFoo;
+ },
+ 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', 'FooModelFoo']});
@@ -0,0 +1,18 @@
+<div id="{{mojit_view_id}}">
+ <dl>
+ <dt>status</dt>
+ <dd id="dd_status">{{status}}</dd>
+ <dt>public1</dt>
+ <dd>{{public1}}</dd>
+ <dt>secret1</dt>
+ <dd>{{secret1}}</dd>
+ <dt>secret3</dt>
+ <dd>{{secret3}}</dd>
+ <dt>business</dt>
+ <dd>{{{business}}}</dd>
+ <dt>data</dt>
+ <dd id="dd_data">
+ <b>some:</b> {{#data}}{{some}}{{/data}}
+ </dd>
+ </dl>
+</div>
Oops, something went wrong.

0 comments on commit 71d0c3a

Please sign in to comment.