Permalink
Browse files

Merge branch 'docs_remove_init_controllers' into HEAD

Conflicts:
	docs/dev_guide/api_overview/mojito_addons.rst
	docs/dev_guide/code_exs/adding_assets.rst
	docs/dev_guide/code_exs/binding_events.rst
	docs/dev_guide/code_exs/route_config.rst
	docs/dev_guide/getting_started/index.rst
	docs/dev_guide/getting_started/mojito_getting_started_tutorial.rst
	docs/dev_guide/intro/mojito_configuring.rst
	docs/dev_guide/intro/mojito_mvc.rst
	docs/dev_guide/topics/index.rst
	docs/dev_guide/topics/mojito_assets.rst
	docs/dev_guide/topics/mojito_composite_mojits.rst
	docs/dev_guide/topics/mojito_data.rst
	docs/dev_guide/topics/mojito_extensions.rst
	docs/dev_guide/topics/mojito_framework_mojits.rst
	docs/dev_guide/topics/mojito_logging.rst
	docs/dev_guide/topics/mojito_resource_store.rst
	docs/dev_guide/topics/mojito_run_dyn_defined_mojits.rst
  • Loading branch information...
2 parents 97f5a62 + 3447b5a commit df58c4fe12b9a2afc191845064de6a2c6369869a Joe Catera committed Nov 13, 2012
Showing with 998 additions and 1,085 deletions.
  1. +0 −3 docs/dev_guide/api_overview/mojito_action_context.rst
  2. +13 −7 docs/dev_guide/api_overview/mojito_addons.rst
  3. +6 −4 docs/dev_guide/api_overview/mojito_client_obj.rst
  4. +7 −7 docs/dev_guide/api_overview/mojito_rest_lib.rst
  5. +6 −8 docs/dev_guide/code_exs/adding_assets.rst
  6. +67 −66 docs/dev_guide/code_exs/binding_events.rst
  7. +2 −6 docs/dev_guide/code_exs/calling_yql.rst
  8. +1 −6 docs/dev_guide/code_exs/cookies.rst
  9. +2 −6 docs/dev_guide/code_exs/dynamic_assets.rst
  10. +2 −1 docs/dev_guide/code_exs/events.rst
  11. +1 −3 docs/dev_guide/code_exs/framed_assets.rst
  12. +2 −6 docs/dev_guide/code_exs/generating_urls.rst
  13. +0 −3 docs/dev_guide/code_exs/htmlframe_view.rst
  14. +2 −6 docs/dev_guide/code_exs/i18n_apps.rst
  15. +2 −1 docs/dev_guide/code_exs/inter-mojit.rst
  16. +64 −72 docs/dev_guide/code_exs/intermojit_communication.rst
  17. +5 −15 docs/dev_guide/code_exs/multiple_mojits.rst
  18. +8 −6 docs/dev_guide/code_exs/overview.rst
  19. +32 −30 docs/dev_guide/code_exs/query_params.rst
  20. +42 −30 docs/dev_guide/code_exs/route_config.rst
  21. +22 −24 docs/dev_guide/code_exs/scroll_views.rst
  22. +29 −25 docs/dev_guide/code_exs/simple_logging.rst
  23. +34 −34 docs/dev_guide/code_exs/simple_view_template.rst
  24. +75 −67 docs/dev_guide/code_exs/view_engines.rst
  25. +2 −2 docs/dev_guide/code_exs/views.rst
  26. +57 −50 docs/dev_guide/code_exs/views_multiple_devices.rst
  27. +31 −30 docs/dev_guide/code_exs/yui_modules.rst
  28. +1 −0 docs/dev_guide/getting_started/index.rst
  29. +20 −30 docs/dev_guide/getting_started/mojito_getting_started_tutorial.rst
  30. +0 −1 docs/dev_guide/intro/index.rst
  31. +41 −17 docs/dev_guide/intro/mojito_configuring.rst
  32. +7 −140 docs/dev_guide/intro/mojito_mvc.rst
  33. +0 −2 docs/dev_guide/reference/mojito_troubleshooting.rst
  34. +0 −1 docs/dev_guide/topics/index.rst
  35. +1 −9 docs/dev_guide/topics/mojito_assets.rst
  36. +10 −13 docs/dev_guide/topics/mojito_composite_mojits.rst
  37. +59 −44 docs/dev_guide/topics/mojito_data.rst
  38. +3 −21 docs/dev_guide/topics/mojito_extensions.rst
  39. +8 −1 docs/dev_guide/topics/mojito_framework_mojits.rst
  40. +52 −47 docs/dev_guide/topics/mojito_npm.rst
  41. +196 −174 docs/dev_guide/topics/mojito_resource_store.rst
  42. +86 −64 docs/dev_guide/topics/mojito_run_dyn_defined_mojits.rst
  43. +0 −3 docs/dev_guide/topics/mojito_testing.rst
@@ -29,9 +29,6 @@ One of the most common methods used from an instance of the ``ActionContext`` cl
* @constructor
*/
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
/**
* Method corresponding to the 'index' action.
*
@@ -2,13 +2,15 @@
Action Context Addons
=====================
+<<<<<<< HEAD
The Action Context uses a mechanism called addons to provide functionality that lives both
on the server and client. Each addon provides additional functions through a namespacing
object, which is appended to the ``ActionContext`` object that is available in every
controller function. See the `ActionContext Class <../../api/classes/ActionContext.html>`_
for the addon classes.
The Action Context addons allow you to do the following:
+=======
- access assets, such as CSS and JavaScript files
- get configuration information
@@ -18,10 +20,11 @@ The Action Context addons allow you to do the following:
- get and set HTTP headers
- create URLs
-.. _addons-syntax:
+
+.. _mojito_addons-syntax:
Syntax
-######
+======
Using the ``ActionContext`` object ``ac``, you would call a ``{method}`` from an
``{addon}`` with the following syntax:
@@ -33,10 +36,11 @@ with the ``url`` method as seen here:
``ac.params.url()``
+
.. _addons-requiring:
Requiring Addons
-################
+================
Prior to version 0.5.0, Mojito attached addons to the ``ActionContext`` object for
every HTTP request and mojit instance. As a result, you were able to use
@@ -79,10 +83,11 @@ The list below shows what strings are used to require addons.
and Assets.
-.. _addons-exs:
+
+.. _mojito_addons-exs:
Addon Examples
-##############
+==============
The following code examples use the addons in parentheses:
@@ -93,10 +98,11 @@ The following code examples use the addons in parentheses:
- `Internationalizing Your Application <../code_exs/i18n_apps.html>`_ (``Intl``)
- `Using Multiple Mojits <../code_exs/multiple_mojits.html>`_ (``Composite``)
-.. _addons-creating:
+
+.. _mojito_addons-create:
Creating Addons
-###############
+===============
Because customized addons are not part of the standard API, but an extension of the API, the
instructions for creating addons can be found in
@@ -1,5 +1,3 @@
-
-
=============
Client Object
=============
@@ -9,17 +7,21 @@ created. The ``client`` object can be used to pause and resume mojits running wi
See `Class Y.mojito.Client <../../api/classes/Y.mojito.Client.html>`_ in the
`Mojito API Reference <../../api/>`_ for more details.
+.. _mojito_client_obj-pause:
+
Pausing Mojits
-##############
+==============
From the ``client`` object, you call the ``pause`` method as seen below to prevent any code from
executing outside of the individual binders (within the Mojito framework) and to call ``onPause()``
on all binders.
``Y.mojito.client.pause()``
+.. _mojito_client_obj-resume:
+
Resuming Mojits
-###############
+===============
From the ``client`` object, you call the ``resume`` method as seen below to immediately execute all
cached operations and notify all of the binders through the ``onResume`` function.
@@ -1,5 +1,3 @@
-
-
============
REST Library
============
@@ -8,8 +6,10 @@ Mojito has a library to make it easier to make a REST calls to Web services from
implementation details, see `Class Y.mojito.lib.REST <../../api/classes/Y.mojito.lib.REST.html>`_
in the Mojito API documentation.
+.. _mojito_rest_lib-incl:
+
Including Library
-#################
+=================
To use the REST library, include the string 'mojito-rest-lib' in the ``requires`` array, which
instructs YUI to load the library. Once the library is loaded, you can use
@@ -25,8 +25,11 @@ instructs YUI to load the library. Once the library is loaded, you can use
// Ask YUI to load the library w/ 'mojito-rest-lib'.
}, '0.0.1', {requires: ['mojito', 'mojito-rest-lib']});
+
+.. _mojito_rest_lib-ex:
+
Example
-#######
+=======
In the model for the ``recipeSearch`` mojit below, the REST library is used to make a GET call to
the Recipe Puppy API.
@@ -35,9 +38,6 @@ the Recipe Puppy API.
YUI.add('ProductSearchModel', function(Y, NAME) {
Y.namespace('mojito.models')[NAME] = {
- init: function(config) {
- this.config = config;
- },
recipeSearch: function(count, cb) {
var url = 'http://www.recipepuppy.com/api/';
var params = {
@@ -199,14 +199,12 @@ To create and run ``simple_assets``:
* @constructor
*/
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
- /**
- * Method corresponding to the 'index' action.
- * @param ac {Object} The action context that
- * provides access to the Mojito API.
- */
+
+ /**
+ * Method corresponding to the 'index' action.
+ * @param ac {Object} The action context that
+ * provides access to the Mojito API.
+ */
index: function(ac) {
var data = {
title: "Simple Assets",
@@ -11,9 +11,11 @@ Binding Events
Summary
=======
-This example shows how to bind events to a mojit, configure code to run on the client, and
-make AJAX calls to the YQL Web service. The application listens for events and then makes
-AJAX calls to YQL to get Flickr photo information.
+
+This example shows how to bind events to a mojit, configure code to run
+on the client, and make AJAX calls to the YQL Web service. The application
+listens for events and then makes AJAX calls to YQL to get Flickr photo
+information.
The following topics will be covered:
@@ -40,12 +42,13 @@ Implementation Notes
Configuring the Application to Run on the Client
------------------------------------------------
-Mojito lets you configure applications to run on either the server or client side. This
-example uses binders that are deployed to the client, so we need to configure Mojito to
-deploy the application to the client, where it will be executed by the browser.
+Mojito lets you configure applications to run on either the server or client
+side. This example uses binders that are deployed to the client, so we need
+to configure Mojito to deploy the application to the client, where it will
+be executed by the browser.
-To configure Mojito to run on the client, you simply set the ``"deploy"`` property to
-``true`` in ``application.json`` as seen below.
+To configure Mojito to run on the client, you simply set the ``"deploy"``
+property to ``true`` in ``application.json`` as seen below.
.. code-block:: javascript
@@ -72,8 +75,8 @@ Getting Data with YQL in the Model
----------------------------------
In the mojit model, the `YUI YQL Query Utility <http://developer.yahoo.com/yui/3/yql/>`_
-is used to get Flickr photo information. To access the utility in your model, specify
-``'yql'`` in the ``requires`` array as seen in the code snippet below:
+is used to get Flickr photo information. To access the utility in your model,
+specify ``'yql'`` in the ``requires`` array as seen in the code snippet below:
.. code-block:: javascript
@@ -83,10 +86,10 @@ is used to get Flickr photo information. To access the utility in your model, sp
...
}, '0.0.1', {requires: ['yql']});
-This code example uses the ``flickr.photos.search`` table to get information for photos
-that have a title, description, or tags containing a string. For example, the YQL
-statement below returns Flickr photo information for those photos that have a title,
-description, or tags containing the string "Manhattan".
+This code example uses the ``flickr.photos.search`` table to get information
+for photos that have a title, description, or tags containing a string. For
+example, the YQL statement below returns Flickr photo information for those
+photos that have a title, description, or tags containing the string "Manhattan".
Copy the query below into the `YQL Console <http://developer.yahoo.com/yql/console/>`_,
replace ``{your_flickr_api_key}`` with your own Flickr API key, and then click **TEST**
@@ -100,11 +103,13 @@ the photo URI as seen here:
``http://farm + {farm} + static.flickr.com/ + {server} + / + {id} + _ + {secret} + .jpg``
+
In the ``model.server.js`` of ``PagerMojit`` shown below, the ``YQL`` function uses the YQL
statement above to get photo data, then parses the returned response to create the photo
URIs. The model then wraps the photo information in an object and stores those objects in
the ``images`` array that is sent to the controller through the ``callback`` function.
+
.. code-block:: javascript
YUI.add('PagerMojitModel', function(Y, NAME) {
@@ -428,6 +433,7 @@ the ``requires`` array.
};
}, '0.0.1', {requires: ['yql', 'io', 'dump']});
+
.. _events_notes-paging:
Using Paging
@@ -565,9 +571,7 @@ create URLs for the **next** and **prev** links.
* @constructor
*/
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(actionContext) {
var page = actionContext.params.getFromMerged('page');
var start;
@@ -684,56 +688,55 @@ To set up and run ``binding_events``:
* @class Controller
* @constructor
*/
- Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
- index: function(actionContext) {
- var page = actionContext.params.getFromMerged('page');
- var start;
- page = parseInt(page) || 1;
- if ((!page) || (page<1)) {
- page = 1;
- }
- // Page param is 1 based, but the model is 0 based
- start = (page - 1) * PAGE_SIZE;
- var model = actionContext.models.PagerMojit;
- // Data is an array of images
- model.getData('mojito', start, PAGE_SIZE, function(data) {
- Y.log('DATA: ' + Y.dump(data));
- var theData = {
- data: data, // images
- hasLink: false,
- prev: {
- title: "prev" // opportunity to localize
- },
- next: {
- link: createLink(actionContext, {page: page+1}),
- title: "next"
- },
- query: 'mojito'
- };
- if (page > 1) {
- theData.prev.link = createLink(actionContext, {page: page-1});
- theData.hasLink = true;
+ Y.namespace('mojito.controllers')[NAME] = {
+
+ index: function(actionContext) {
+ var page = actionContext.params.getFromMerged('page');
+ var start;
+ page = parseInt(page) || 1;
+ if ((!page) || (page<1)) {
+ page = 1;
}
- actionContext.done(theData);
- });
- }
- };
- // Generate the link to the next page based on:
- // - mojit id
- // - action
- // - params
- function createLink(actionContext, params) {
- var mergedParams = Y.mojito.util.copy(actionContext.params.getFromMerged());
- for (var k in params) {
- mergedParams[k] = params[k];
+ // Page param is 1 based, but the model is 0 based
+ start = (page - 1) * PAGE_SIZE;
+ var model = actionContext.models.PagerMojit;
+ // Data is an array of images
+ model.getData('mojito', start, PAGE_SIZE, function(data) {
+ Y.log('DATA: ' + Y.dump(data));
+ var theData = {
+ data: data, // images
+ hasLink: false,
+ prev: {
+ title: "prev" // opportunity to localize
+ },
+ next: {
+ link: createLink(actionContext, {page: page+1}),
+ title: "next"
+ },
+ query: 'mojito'
+ };
+ if (page > 1) {
+ theData.prev.link = createLink(actionContext, {page: page-1});
+ theData.hasLink = true;
+ }
+ actionContext.done(theData);
+ });
+ }
+ };
+ // Generate the link to the next page based on:
+ // - mojit id
+ // - action
+ // - params
+ function createLink(actionContext, params) {
+ var mergedParams = Y.mojito.util.copy(actionContext.params.getFromMerged());
+ for (var k in params) {
+ mergedParams[k] = params[k];
+ }
+ return actionContext.url.make('frame', 'index', Y.QueryString.stringify(mergedParams));
}
- return actionContext.url.make('frame', 'index', Y.QueryString.stringify(mergedParams));
- }
}, '0.0.1', {requires: ['dump', 'mojito-url-addon', 'mojito-params-addon']});
+
#. To get Flickr photo information using YQL, create the file ``models/model.server.js`` with
the code below. Be sure to replace the ``'{your_flickr_api_key}'`` with your own
Flickr API key.
@@ -752,9 +755,7 @@ To set up and run ``binding_events``:
* @constructor
*/
Y.namespace('mojito.models')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
getData: function(query, start, count, callback) {
var q = null;
// Get Flickr API key: http://www.flickr.com/services/api/keys/apply/
Oops, something went wrong.

0 comments on commit df58c4f

Please sign in to comment.