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 #799 from drewfish/merge-perf
Browse files Browse the repository at this point in the history
merge develop-perf into develop
  • Loading branch information
drewfish committed Nov 28, 2012
2 parents 7484c79 + 1dfef32 commit 1f2654d
Show file tree
Hide file tree
Showing 553 changed files with 13,753 additions and 14,950 deletions.
15 changes: 8 additions & 7 deletions docs/dev_guide/api_overview/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ This section introduces some of the main features of the Mojito API. Please see

The API contains the following five modules:

- **ActionContext** - is a key module of the Mojito framework, giving you access to the frameworks
features from within a controller function.
- **Addons** - extensions that provide functionality that lives both on the server and/or client.
Each addon provides additional functions through a namespace that is attached directly to the
``Action Context`` object available in every controller function.
- **ActionContext** - is a key module of the Mojito framework, giving you access to the
frameworks features from within a controller function.
- **Addons** - extensions that provide functionality that lives both on the server
and/or client. Each addon provides additional functions through a namespace that is
attached directly to the ``Action Context`` object and is available when required in a
controller.
- **CommonLibs** - is a utility library containing methods to handle cookies, access input
parameters, and make REST calls.
- **MojitoClient** - is the client-side Mojito runtime module containing methods that allow
inter-mojit communication through the ``mojitProxy`` object.
- **MojitoClient** - is the client-side Mojito runtime module containing methods that
allow inter-mojit communication through the ``mojitProxy`` object.
- **MojitServer** - is the module that provides access to the Mojito server.

.. toctree::
Expand Down
23 changes: 10 additions & 13 deletions docs/dev_guide/api_overview/mojito_action_context.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@


==============
Action Context
==============

The Action Context is an essential element of the Mojito framework that gives you access to the
frameworks features from within a controller function. To use the Action Context, you create an
instance of the ``ActionContext`` class, which we will call ``ac`` for short. From ``ac``, you can
call methods to execute mojit actions within either a server or client context. See the
`ActionContext Class <../../api/classes/ActionContext.html>`_ for the methods available from ``ac``.
The Action Context is an essential element of the Mojito framework that gives you access
to the frameworks features from within a controller function. To use the Action Context,
you create an instance of the ``ActionContext`` class, which we will call ``ac`` for
short. From ``ac``, you can call methods to execute mojit actions within either a server
or client context. See the `ActionContext Class <../../api/classes/ActionContext.html>`_
for the methods available from ``ac``.

One of the most common methods used from an instance of the ``ActionContext`` class is ``done``,
which lets you pass data from the controller to a view. In the example ``controller.server.js`` below,
the ``done`` method sends the ``data`` object to the ``index`` template.
One of the most common methods used from an instance of the ``ActionContext`` class is
``done``, which lets you pass data from the controller to a view. In the example
``controller.server.js`` below, the ``done`` method sends the ``data`` object to the
``index`` template.

.. code-block:: javascript
Expand All @@ -29,9 +29,6 @@ the ``done`` method sends the ``data`` object to the ``index`` template.
* @constructor
*/
Y.namespace('mojito.controllers')[NAME] = {
init: function(config) {
this.config = config;
},
/**
* Method corresponding to the 'index' action.
*
Expand Down
91 changes: 74 additions & 17 deletions docs/dev_guide/api_overview/mojito_addons.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
=====================
Action Context Addons
=====================

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 that is appended to the ``ActionContext`` object. The ``ActionContext`` object
is available in each controller function, but controllers need to
:ref:`require addons <addons-requiring>` before accessing addon methods.
See the `ActionContext Class <../../api/classes/ActionContext.html>`_
for the addon classes.

======
Addons
======

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.

Addons allow you to do the following:
The Action Context addons allow you to do the following:

- access assets, such as CSS and JavaScript files
- get configuration information
Expand All @@ -19,21 +20,74 @@ Addons allow you to do the following:
- get and set HTTP headers
- create URLs


.. _mojito_addons-syntax:

Syntax
######
======

Using the ActionContext object ``ac``, you would call a ``{method}`` from an ``{addon}`` with the
following syntax:
Using the ``ActionContext`` object ``ac``, you would call a ``{method}`` from an
``{addon}`` with the following syntax:

``ac.{addon}.{method}``

For example, to get all of the query string parameters, you would use the ``Params`` addon with the
``url`` method as seen here:
For example, to get all of the query string parameters, you would use the ``Params`` addon
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
any of the Action Context addons by default.

In Mojito versions 0.5.0 and later, you need to explicitly require an addon before you
can use it. You require an addon by including an associated string in the
``requires`` array of your controller. For example, in the controller below,
the ``Params`` addon is required by adding the string ``'mojito-params-addon'`` to the
``requires`` array.


.. code-block:: javascript
YUI.add('Foo', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
index: function(ac) {
var all_params = ac.params.all();
}
};
// Require the addon by adding the param name to the requires array
}, '0.0.1', {requires: ['mojito', 'mojito-params-addon']});
The list below shows what strings are used to require addons.

- ``Assets`` addon - ``requires ['mojito-assets-addon']``
- ``Composite`` addon - ``requires ['mojito-composite-addon']``
- ``Config`` addon - ``requires ['mojito-config-addon']``
- ``Cookies`` addon - ``requires ['mojito-cookie-addon']``
- ``Http`` addon - ``requires ['mojito-http-addon']``
- ``Intl`` addon - ``requires ['mojito-intl-addon']``
- ``Params`` addon - ``requires ['mojito-params-addon']``
- ``Url`` addon - ``requires ['mojito-url-addon']``


.. note::
To run older applications with Mojito v0.5.0 and later, you will need to
modify your controllers so that the ActionContext addons that are being
used are required. The most common addons are ``Config``, ``Params``, ``Url``,
and ``Assets``.



.. _mojito_addons-exs:

Addon Examples
##############
==============

The following code examples use the addons in parentheses:

Expand All @@ -44,8 +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``)


.. _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
Expand Down
29 changes: 16 additions & 13 deletions docs/dev_guide/api_overview/mojito_client_obj.rst
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@


=============
Client Object
=============

When Mojito starts up, the global object ``Y.mojito.client`` that represents the client runtime is
created. The ``client`` object can be used to pause and resume mojits running within the page.
See `Class Y.mojito.Client <../../api/classes/Y.mojito.Client.html>`_ in the
`Mojito API Reference <../../api/>`_ for more details.
When Mojito starts up, the global object ``Y.mojito.client`` that represents the client
runtime is created. The ``client`` object can be used to pause and resume mojits running
within the page. 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.
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.
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.

``Y.mojito.client.resume()``

Expand Down
29 changes: 15 additions & 14 deletions docs/dev_guide/api_overview/mojito_rest_lib.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@


============
REST Library
============

Mojito has a library to make it easier to make a REST calls to Web services from your model. For
implementation details, see `Class Y.mojito.lib.REST <../../api/classes/Y.mojito.lib.REST.html>`_
in the Mojito API documentation.
Mojito has a library to make it easier to make a REST calls to Web services from your
model. For 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
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
`Y.mojito.lib.REST <../../api/classes/Y.mojito.lib.REST.html>`_ to make REST calls..

.. code-block:: javascript
Expand All @@ -25,19 +26,19 @@ 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.
In the model for the ``recipeSearch`` mojit below, the REST library is used to make a
GET call to the Recipe Puppy API.

.. code-block:: javascript
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 = {
Expand Down
Loading

0 comments on commit 1f2654d

Please sign in to comment.