Skip to content

Commit

Permalink
getting pr4 merged for partials
Browse files Browse the repository at this point in the history
  • Loading branch information
caridy committed Nov 15, 2012
2 parents 6b2a5c4 + 0f5d67a commit 459bd50
Show file tree
Hide file tree
Showing 232 changed files with 28,474 additions and 5,066 deletions.
1 change: 1 addition & 0 deletions .npmignore
Expand Up @@ -5,6 +5,7 @@
*.bak
*~
/tests
!/tests/harness/lib/yuitest/java/build
arrowreport
artifacts
examples
Expand Down
6 changes: 1 addition & 5 deletions docs/dev_guide/api_overview/index.rst
Expand Up @@ -13,17 +13,13 @@ The API contains the following five modules:
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.
``Action Context`` object 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.
- **MojitServer** - is the module that provides access to the Mojito server.


Table of Contents
#################

.. toctree::
:maxdepth: 2

Expand Down
23 changes: 10 additions & 13 deletions docs/dev_guide/api_overview/mojito_action_context.rst
@@ -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
89 changes: 72 additions & 17 deletions docs/dev_guide/api_overview/mojito_addons.rst
@@ -1,15 +1,14 @@
=====================
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, 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
======

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 +18,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 +96,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
10 changes: 6 additions & 4 deletions docs/dev_guide/api_overview/mojito_client_obj.rst
@@ -1,5 +1,3 @@


=============
Client Object
=============
Expand All @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions docs/dev_guide/api_overview/mojito_rest_lib.rst
@@ -1,5 +1,3 @@


============
REST Library
============
Expand All @@ -8,11 +6,13 @@ 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
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,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.
Expand All @@ -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 = {
Expand Down

0 comments on commit 459bd50

Please sign in to comment.