Permalink
Browse files

get back joe's docs changes:

  git checkout 980590f -- ./docs/
  • Loading branch information...
1 parent 5083de9 commit c5dacc0c8ed3bea7c4886f4802016dd8c9c2ac1e @isao isao committed Nov 13, 2012
Showing with 4,261 additions and 2,288 deletions.
  1. +1 −5 docs/dev_guide/api_overview/index.rst
  2. +11 −11 docs/dev_guide/api_overview/mojito_action_context.rst
  3. +65 −14 docs/dev_guide/api_overview/mojito_addons.rst
  4. +42 −25 docs/dev_guide/code_exs/adding_assets.rst
  5. +18 −9 docs/dev_guide/code_exs/app_config.rst
  6. +56 −31 docs/dev_guide/code_exs/binding_events.rst
  7. +69 −53 docs/dev_guide/code_exs/calling_yql.rst
  8. +2 −2 docs/dev_guide/code_exs/config.rst
  9. +31 −17 docs/dev_guide/code_exs/cookies.rst
  10. +49 −37 docs/dev_guide/code_exs/dynamic_assets.rst
  11. +42 −29 docs/dev_guide/code_exs/framed_assets.rst
  12. +41 −31 docs/dev_guide/code_exs/generating_urls.rst
  13. +47 −26 docs/dev_guide/code_exs/global_assets.rst
  14. +38 −25 docs/dev_guide/code_exs/htmlframe_view.rst
  15. +61 −42 docs/dev_guide/code_exs/i18n_apps.rst
  16. +7 −42 docs/dev_guide/code_exs/index.rst
  17. +101 −81 docs/dev_guide/code_exs/intermojit_communication.rst
  18. +37 −26 docs/dev_guide/code_exs/multiple_mojits.rst
  19. +2 −2 docs/dev_guide/code_exs/other.rst
  20. +41 −0 docs/dev_guide/code_exs/overview.rst
  21. +56 −40 docs/dev_guide/code_exs/query_params.rst
  22. +64 −55 docs/dev_guide/code_exs/route_config.rst
  23. +31 −18 docs/dev_guide/code_exs/scroll_views.rst
  24. +42 −26 docs/dev_guide/code_exs/simple_logging.rst
  25. +28 −18 docs/dev_guide/code_exs/simple_view_template.rst
  26. +63 −47 docs/dev_guide/code_exs/view_engines.rst
  27. +54 −29 docs/dev_guide/code_exs/views_multiple_devices.rst
  28. +54 −31 docs/dev_guide/code_exs/yui_modules.rst
  29. +220 −0 docs/dev_guide/conf.py
  30. +2 −1 docs/dev_guide/faq/index.rst
  31. +2 −6 docs/dev_guide/getting_started/index.rst
  32. +94 −57 docs/dev_guide/getting_started/mojito_getting_started_tutorial.rst
  33. +65 −0 docs/dev_guide/getting_started/quickstart.rst
  34. +75 −0 docs/dev_guide/index.rst
  35. +3 −5 docs/dev_guide/intro/index.rst
  36. +68 −32 docs/dev_guide/intro/mojito_apps.rst
  37. +56 −33 docs/dev_guide/intro/mojito_binders.rst
  38. +119 −7 docs/dev_guide/intro/mojito_configuring.rst
  39. +8 −7 docs/dev_guide/intro/mojito_mojits.rst
  40. +223 −156 docs/dev_guide/intro/mojito_mvc.rst
  41. +79 −40 docs/dev_guide/intro/mojito_overview.rst
  42. +50 −25 docs/dev_guide/intro/mojito_quicktour.rst
  43. +32 −13 docs/dev_guide/intro/mojito_static_resources.rst
  44. +22 −16 docs/dev_guide/quickstart/index.rst
  45. +75 −48 docs/dev_guide/reference/glossary.rst
  46. +121 −103 docs/dev_guide/reference/mojito_cmdline.rst
  47. +77 −40 docs/dev_guide/reference/mojito_troubleshooting.rst
  48. +19 −14 docs/dev_guide/resources/index.rst
  49. +4 −5 docs/dev_guide/topics/index.rst
  50. +101 −48 docs/dev_guide/topics/mojito_assets.rst
  51. +62 −33 docs/dev_guide/topics/mojito_composite_mojits.rst
  52. +133 −67 docs/dev_guide/topics/mojito_data.rst
  53. +269 −156 docs/dev_guide/topics/mojito_extensions.rst
  54. +116 −81 docs/dev_guide/topics/mojito_framework_mojits.rst
  55. +259 −0 docs/dev_guide/topics/mojito_hosting_container_reqs.rst
  56. +85 −53 docs/dev_guide/topics/mojito_logging.rst
  57. +54 −41 docs/dev_guide/topics/mojito_npm.rst
  58. +140 −122 docs/dev_guide/topics/mojito_resource_store.rst
  59. +159 −99 docs/dev_guide/topics/mojito_run_dyn_defined_mojits.rst
  60. +156 −107 docs/dev_guide/topics/mojito_testing.rst
  61. +160 −101 docs/dev_guide/topics/mojito_using_contexts.rst
@@ -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
@@ -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``.
-
-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.
+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.
.. code-block:: javascript
@@ -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
@@ -19,19 +18,69 @@ Addons allow you to do the following:
- get and set HTTP headers
- create URLs
+.. _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.
+
+
+.. _addons-exs:
+
Addon Examples
##############
@@ -44,6 +93,8 @@ 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:
+
Creating Addons
###############
@@ -2,10 +2,16 @@
Adding CSS
==========
+.. raw:: html
+
+ <span class="testimate">Time Estimate: 10 minutes</span>&nbsp;&nbsp;&nbsp;<span class="difficulty">Difficulty: Beginner</span>
+
**Time Estimate:** 10 minutes
**Difficulty:** Beginner
+.. _code_exs_css-summary:
+
Summary
=======
@@ -16,12 +22,14 @@ The following topics will be covered:
- configuring an application to have assets
- including assets in the template
+.. _code_exs_css-notes:
+
Implementation Notes
====================
-Each application has an ``assets`` directory for placing global CSS files that can be accessed by
-all of your mojits. Each mojit has its own ``assets`` directory for local CSS files that are only
-accessible by the mojit.
+Each application has an ``assets`` directory for placing global CSS files that can be
+accessed by all of your mojits. Each mojit has its own ``assets`` directory for local
+CSS files that are only accessible by the mojit.
The global assets are located in the ``{app_dir}/assets`` directory as shown here:
@@ -36,8 +44,8 @@ The global assets are located in the ``{app_dir}/assets`` directory as shown her
|-- routes.json
|-- server.js
-In the ``simple`` mojit below, you see the local ``assets`` directory for CSS files only available
-to the ``simple`` mojit:
+In the ``simple`` mojit below, you see the local ``assets`` directory for CSS files only
+available to the ``simple`` mojit:
::
@@ -52,8 +60,8 @@ to the ``simple`` mojit:
|-- tests/
`-- views/
-This code example only uses local CSS, so the ``simple.css`` file is placed in the ``assets``
-directory under the ``simple`` mojit.
+This code example only uses local CSS, so the ``simple.css`` file is placed in the
+``assets`` directory under the ``simple`` mojit.
.. code-block:: css
@@ -67,18 +75,18 @@ directory under the ``simple`` mojit.
}
.toolbar li { display:inline; }
-The CSS files in the mojit ``assets`` directory can be accessed in the template using the following
-path syntax:
+The CSS files in the mojit ``assets`` directory can be accessed in the template using the
+following path syntax:
``/static/{mojit}/assets/{css_file}.css``
-This code example uses the ``simple`` mojit and the ``simple.css`` asset. To access ``simple.css``,
-you would use the following path:
+This code example uses the ``simple`` mojit and the ``simple.css`` asset. To access
+``simple.css``, you would use the following path:
``/static/simple/assets/simple.css``
-The ``index.hb.html`` template below includes ``simple.css`` from the ``assets`` directory using the
-path above.
+The ``index.hb.html`` template below includes ``simple.css`` from the ``assets`` directory
+using the path above.
.. code-block:: html
@@ -107,15 +115,19 @@ path above.
</body>
</html>
-To access the global assets for the application, you use a similar syntax, replacing the mojit name
-with the application name. Thus, if the application name is ``simple_assets`` and ``simple.css``
-is in ``simple_assets/assets/``, you would access ``simple.css`` with the following path:
+To access the global assets for the application, you use a similar syntax, replacing the
+mojit name with the application name. Thus, if the application name is ``simple_assets``
+and ``simple.css`` is in ``simple_assets/assets/``, you would access ``simple.css`` with
+the following path:
``/static/simple_assets/assets/simple.css``
-.. note:: For the purpose of simplifying this code example, the ``setColor`` function was hardcoded
- into the template. In your Mojito applications, you should avoid mixing the business and
- presentation logic of your application by hardcoding JavaScript into your template.
+.. note:: For the purpose of simplifying this code example, the ``setColor`` function was
+ hardcoded into the template. In your Mojito applications, you should avoid
+ mixing the business and presentation logic of your application by hardcoding
+ JavaScript into your template.
+
+.. _code_exs_css-setup:
Setting Up this Example
=======================
@@ -132,7 +144,8 @@ To create and run ``simple_assets``:
``$ mojito create mojit simple``
-#. To configure your application to use the ``simple`` mojit, replace the code in ``application.json`` with the following:
+#. To configure your application to use the ``simple`` mojit, replace the code in
+ ``application.json`` with the following:
.. code-block:: javascript
@@ -147,7 +160,8 @@ To create and run ``simple_assets``:
}
]
-#. To configure routing, create the file ``routes.json`` with the following:
+#. To configure routing, replace the code of the file ``routes.json`` with the
+ following:
.. code-block:: javascript
@@ -167,7 +181,8 @@ To create and run ``simple_assets``:
``$ cd mojits/simple``
-#. Modify your controller to pass an array of objects to the template by replacing the code in ``controller.server.js`` with the following:
+#. Modify your controller to pass an array of objects to the template by replacing the
+ code in ``controller.server.js`` with the following:
.. code-block:: javascript
@@ -185,7 +200,7 @@ To create and run ``simple_assets``:
*/
Y.namespace('mojito.controllers')[NAME] = {
init: function(config) {
- this.config = config;
+ this.config = config;
},
/**
* Method corresponding to the 'index' action.
@@ -208,8 +223,8 @@ To create and run ``simple_assets``:
};
}, '0.0.1', {requires: []});
-#. Include the assets in your template by replacing the code in ``views/index.hb.html`` with the
- following:
+#. Include the assets in your template by replacing the code in ``views/index.hb.html``
+ with the following:
.. code-block:: html
@@ -259,6 +274,8 @@ To create and run ``simple_assets``:
http://localhost:8666
+.. _code_exs_css-src:
+
Source Code
===========
@@ -6,16 +6,21 @@ Basic Configuring of Applications
**Difficulty Level:** Beginning
+.. _code_exs_basic_config-summary:
+
Summary
=======
This example shows how to configure a mojit and the routing for your application.
+.. _code_exs_basic_config-notes:
+
Implementation Notes
====================
-The ``application.json`` file is used to specify the mojits that your application can use. The
-example ``application.json`` below specifies that the application use the mojit ``SimpleMojit``.
+The ``application.json`` file is used to specify the mojits that your application can use.
+The example ``application.json`` below specifies that the application use the mojit
+``SimpleMojit``.
.. code-block:: javascript
@@ -30,9 +35,9 @@ example ``application.json`` below specifies that the application use the mojit
}
]
-The routing configuration for Mojito applications is contained in ``routes.json``. In this example
-``routes.json``, the Mojito server is told to call the ``index`` method in the controller when an
-HTTP GET is called on the root path.
+The routing configuration for Mojito applications is contained in ``routes.json``. In this
+example ``routes.json``, the Mojito server is told to call the ``index`` method in the
+controller when an HTTP GET is called on the root path.
.. code-block:: javascript
@@ -47,10 +52,12 @@ HTTP GET is called on the root path.
}
]
-The ``index`` method is a canned method in the controller when you create a mojit. To learn how to
-create templates that get data from the controller,
+The ``index`` method is a canned method in the controller when you create a mojit. To
+learn how to create templates that get data from the controller,
see `Creating a Simple View with Handlebars <simple_view_template.html>`_.
+.. _code_exs_basic_config-setup:
+
Setting Up this Example
=======================
@@ -63,8 +70,8 @@ To set up and run ``simple_config``:
#. Create your mojit.
``$ mojito create mojit SimpleMojit``
-#. To specify that your application use ``SimpleMojit``, replace the code in ``application.json``
- with the following:
+#. To specify that your application use ``SimpleMojit``, replace the code in
+ ``application.json`` with the following:
.. code-block:: javascript
@@ -101,6 +108,8 @@ To set up and run ``simple_config``:
http://localhost:8666
+.. _code_exs_basic_config-src:
+
Source Code
===========
Oops, something went wrong.

0 comments on commit c5dacc0

Please sign in to comment.