Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[doc] Fixed doc issues/discrepancies created by merge of develop-perf into dev... #814

Merged
merged 1 commit into from

1 participant

@zhouyaoji
Owner

...elop.

@zhouyaoji zhouyaoji merged commit 026f6a8 into yahoo:develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 240 additions and 139 deletions.
  1. +6 −5 docs/dev_guide/api_overview/mojito_addons.rst
  2. +1 −1  docs/dev_guide/api_overview/mojito_rest_lib.rst
  3. +1 −11 docs/dev_guide/code_exs/adding_assets.rst
  4. +1 −1  docs/dev_guide/code_exs/app_config.rst
  5. +25 −4 docs/dev_guide/code_exs/binding_events.rst
  6. +4 −3 docs/dev_guide/code_exs/calling_yql.rst
  7. +19 −0 docs/dev_guide/code_exs/query_params.rst
  8. +0 −1  docs/dev_guide/code_exs/views_multiple_devices.rst
  9. +19 −15 docs/dev_guide/faq/index.rst
  10. +1 −1  docs/dev_guide/getting_started/mojito_getting_started_tutorial.rst
  11. +4 −3 docs/dev_guide/getting_started/quickstart.rst
  12. +4 −4 docs/dev_guide/index.rst
  13. +3 −3 docs/dev_guide/intro/mojito_apps.rst
  14. +10 −12 docs/dev_guide/intro/mojito_configuring.rst
  15. +1 −1  docs/dev_guide/intro/mojito_mojits.rst
  16. +17 −15 docs/dev_guide/intro/mojito_mvc.rst
  17. +3 −23 docs/dev_guide/reference/mojito_cmdline.rst
  18. +2 −2 docs/dev_guide/topics/mojito_assets.rst
  19. +5 −5 docs/dev_guide/topics/mojito_composite_mojits.rst
  20. +26 −0 docs/dev_guide/topics/mojito_data.rst
  21. +5 −5 docs/dev_guide/topics/mojito_extensions.rst
  22. +3 −3 docs/dev_guide/topics/mojito_frame_mojits.rst
  23. +2 −5 docs/dev_guide/topics/mojito_npm.rst
  24. +4 −6 docs/dev_guide/topics/mojito_resource_store.rst
  25. +72 −6 docs/dev_guide/topics/mojito_testing.rst
  26. +2 −4 docs/dev_guide/topics/mojito_using_contexts.rst
View
11 docs/dev_guide/api_overview/mojito_addons.rst
@@ -49,8 +49,8 @@ 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.
+the ``Params`` addon is required by adding the string ``'mojito-params-addon'``
+to the ``requires`` array.
.. code-block:: javascript
@@ -91,7 +91,8 @@ Addon Examples
The following code examples use the addons in parentheses:
-- `Dynamically Adding CSS to Different Devices <../code_exs/dynamic_assets.html>`_ (``Assets``)
+- `Dynamically Adding CSS to Different Devices <../code_exs/dynamic_assets.html>`_
+ (``Assets``)
- `Using Cookies <../code_exs/cookies.html>`_ (``Cookie``)
- `Using Query Parameters <../code_exs/query_params.html>`_ (``Params``)
- `Generating URLs <../code_exs/generating_urls.html>`_ (``Url``)
@@ -104,8 +105,8 @@ The following code examples use the addons in parentheses:
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
+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
`Creating New Addons <../topics/mojito_extensions.html#creating-new-addons>`_.
View
2  docs/dev_guide/api_overview/mojito_rest_lib.rst
@@ -12,7 +12,7 @@ documentation.
Including Library
=================
-To use the REST library, include the string 'mojito-rest-lib' in the ``requires`` array,
+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..
View
12 docs/dev_guide/code_exs/adding_assets.rst
@@ -183,17 +183,7 @@ To create and run ``simple_assets``:
.. code-block:: javascript
YUI.add('simple', function(Y, NAME) {
- /**
- * The simple module.
- *
- * @module simple
- */
- /**
- * Constructor for the Controller class.
- *
- * @class Controller
- * @constructor
- */
+
Y.namespace('mojito.controllers')[NAME] = {
/**
View
2  docs/dev_guide/code_exs/app_config.rst
@@ -37,7 +37,7 @@ The example ``application.json`` below specifies that the application use the mo
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.
+method in the controller when HTTP GET called on the root path.
.. code-block:: javascript
View
29 docs/dev_guide/code_exs/binding_events.rst
@@ -499,7 +499,7 @@ calculate the index of the first photo to display:
To get the photo data, the controller depends on the model to call YQL to query the
Flickr API. Using ``actionContext.get({model_name})`` lets you get a reference to the
model. The example controller below calls the ``getData`` from the model
-``PagerMojitModel`` with ``actionContext.models.get('PagerMojitModel').getData`, which
+``PagerMojitModel`` with ``actionContext.models.get('PagerMojitModel').getData``, which
will get the returned data from YQL in the callback function. To use methods from models,
you need to require the model in the ``requires`` array of the controller.
@@ -532,7 +532,14 @@ you need to require the model in the ``requires`` array of the controller.
}
...
};
- }, '0.0.1', {requires: ['dump', 'mojito-url-addon', 'mojito-params-addon', 'PagerMojitModel']});
+ }, '0.0.1', {requires: [
+ 'mojito',
+ 'mojito-models-addon',
+ 'mojito-url-addon',
+ 'mojito-params-addon',
+ 'PagerMojitModel',
+ 'dump'
+ ]});
The URLs for the **prev** and **next** links are created by passing the mojit instance,
@@ -615,7 +622,14 @@ create URLs for the **next** and **prev** links.
}
return actionContext.url.make('frame', 'index', Y.QueryString.stringify(mergedParams));
}
- }, '0.0.1', {requires: ['dump', 'mojito-url-addon', 'mojito-params-addon', 'PagerMojitModel']});
+ }, '0.0.1', {requires: [
+ 'mojito',
+ 'mojito-models-addon',
+ 'mojito-url-addon',
+ 'mojito-params-addon',
+ 'PagerMojitModel',
+ 'dump'
+ ]});
.. _code_exs_events-setup:
@@ -732,7 +746,14 @@ To set up and run ``binding_events``:
}
return actionContext.url.make('frame', 'index', Y.QueryString.stringify(mergedParams));
}
- }, '0.0.1', {requires: ['dump', 'mojito-url-addon', 'mojito-params-addon', 'mojito-models-addon', 'PagerMojitModel']});
+ }, '0.0.1', {requires: [
+ 'mojito',
+ 'mojito-models-addon',
+ 'mojito-url-addon',
+ 'mojito-params-addon',
+ 'PagerMojitModel',
+ 'dump'
+ ]});
#. To get Flickr photo information using YQL, create the file ``models/model.server.js``
View
7 docs/dev_guide/code_exs/calling_yql.rst
@@ -171,7 +171,8 @@ Calling the Model from the Controller
The controller in this code example performs the following functions:
-- gets the query string parameters using the `Params addon <../../api/classes/Params.common.html>`_
+- gets the query string parameters using the
+ `Params addon <../../api/classes/Params.common.html>`_
- passes the query string parameters to the ``search`` function of the model
- receives the ``photos`` array from the ``search`` function and sends an object to the
template
@@ -257,8 +258,8 @@ To set up and run ``model_yql``:
}
]
-#. To configure the routing to call the ``index`` method an instance of ``HTMLFrameMojit``,
- replace the code in ``routes.json`` with the following:
+#. To configure the routing to call the ``index`` method an instance of
+ ``HTMLFrameMojit``, replace the code in ``routes.json`` with the following:
.. code-block:: javascript
View
19 docs/dev_guide/code_exs/query_params.rst
@@ -194,6 +194,25 @@ a key to ``params.getFromMerged(key)``. For example,
...
}, '0.0.1', {requires: ['dump', 'mojito-params-addon']});
+The methods of the ``Params`` addon have the following aliases for simplification:
+
++---------------------+--------------+
+| Method | Alias |
++=====================+==============+
+| ``getAll()`` | ``all()`` |
++---------------------+--------------+
+| ``getFromBody()`` | ``body()`` |
++---------------------+--------------+
+| ``getFromFiles()`` | ``files()`` |
++---------------------+--------------+
+| ``getFromMerged()`` | ``merged()`` |
++---------------------+--------------+
+| ``getfromRoute()`` | ``route()`` |
++---------------------+--------------+
+| ``getFromUrl()`` | ``url()`` |
++---------------------+--------------+
+
+
For more information, see the `Params addon <../../api/classes/Params.common.html>`_ in
the Mojito API documentation.
View
1  docs/dev_guide/code_exs/views_multiple_devices.rst
@@ -198,7 +198,6 @@ To set up and run ``device_views``:
#. Create your mojit.
``$ mojito create mojit device``
-
#. To configure you application, replace the code in ``application.json``
with the following:
View
34 docs/dev_guide/faq/index.rst
@@ -449,9 +449,10 @@ Mojits
.. .. _moj_reuse:
.. .. topic:: **Can I share or re-use mojits?**
-.. Although not available yet, Y Cocktails mojit gallery/repository will let developers
-.. share, discover, and select mojits to re-use in building their experiences. A
-.. common packaging format for mojits is used, based on the CommonJS specification.
+.. Although not available yet, the Cocktails mojit gallery/repository will let
+.. developers share, discover, and select mojits to re-use in building their
+.. experiences. A common packaging format for mojits is used, based on the CommonJS
+.. specification.
Configuration
-------------
@@ -470,10 +471,10 @@ Configuration
.. _moj_client:
.. topic:: **How do you configure mojits to run on the client?**
- Run Mojito at build time to generate the html page using ``mojito build html5app``.
+ Run Mojito at build time to generate the HTML page using ``mojito build html5app``.
This runs the Mojito infrastructure as if it were a running server instance and prints
- out the resulting HTML+JSON required to bootstrap a client-side mojit. This is what
- Livestand does. Among other things, it leads down a path where it's very hard to do
+ out the resulting HTML+JSON required to bootstrap a client-side mojit.
+ Among other things, it leads down a path where it's very hard to do
incremental builds because the Web server abstraction makes it hard to do the timestamp
resolution that incremental builds require. A better approach would be to allow people
to hard-code the top-level mojit bootstrap code by publishing mojit creation APIs that
@@ -657,12 +658,12 @@ Views
.. _moj_devices:
.. topic:: **Do I have to create separate mojits for different devices?**
- The platformâ™s capabilities allow mojits to be executed (and their results displayed)
+ The platform's capabilities allow mojits to be executed (and their results displayed)
on every device in either set. For a module developer, the benefit is obvious: a single
- codebase that can address a wide range of devices. Mojits may still need to be customized
- for a specific device (or device class), however, to take advantage of device-specific
- capabilities. The platform does not perform an automated translation/degradation of
- HTML5 views to simpler layouts, for example.
+ codebase that can address a wide range of devices. Mojits may still need to be
+ customized for a specific device (or device class), however, to take advantage of
+ device-specific capabilities. The platform does not perform an automated
+ translation/degradation of HTML5 views to simpler layouts, for example.
------------
@@ -743,10 +744,13 @@ Logging/Testing
.. _moj_client_server_logging:
.. topic:: **Can logging be configured to be different for the client and server?**
- Yes, the ``application.json`` configuration file can contain a ``yui.config`` object
- that contain the properties ``logExclude`` and ``logInclude`` to log certain components
- of your application. You can also use context configurations to have different
- configurations depending on the runtime environment.
+ Yes, the ``application.json`` configuration file uses the ``yui.config`` object
+ for configuring logging. You can use contexts to customize logging for
+ different runtime environments. For instance, you could use the ``"runtime:client"``
+ context to configure client-side logging and the ``"master"`` context to configure
+ server-side logging. You can also use the properties ``logExclude`` and ``logInclude``
+ of the ``yui.config`` object to log or not log certain components
+ of your application.
See `config Object <../intro/mojito_configuring.html#yui_config>`_
and the `Log Configuration <../topics/mojito_logging.html#log-configuration>`_ for
View
2  docs/dev_guide/getting_started/mojito_getting_started_tutorial.rst
@@ -27,7 +27,7 @@ You will learn how to do the following:
Make the Application
====================
-#. Create the Mojito application ``minty_app``.
+#. Create the Mojito application ``minty_app``.
``$ mojito create app minty_app``
View
7 docs/dev_guide/getting_started/quickstart.rst
@@ -16,8 +16,8 @@ Prerequisites
Installation Steps
==================
-#. Get Mojito from the npm registry and globally install Mojito so that it can be run from the
- command line. You may need to use ``sudo`` if you run into permission errors.
+#. Get Mojito from the npm registry and globally install Mojito so that it can be run from
+ the command line. You may need to use ``sudo`` if you run into permission errors.
``$ npm install mojito -g``
@@ -39,7 +39,8 @@ Create a Mojito Application
Modify Your Application
=======================
-To make the application return a string we want, replace the code in ``mojits/myMojit/controller.server.js`` with the following:
+To make the application return a string we want, replace the code in
+``mojits/myMojit/controller.server.js`` with the following:
.. code-block:: javascript
View
8 docs/dev_guide/index.rst
@@ -31,9 +31,9 @@ Developer Topics
================
This chapter is intended for developers who have gotten their feet wet and
-intend to get in deeper with Mojito. We'll start the discussion with assets, cookies,
-logging, testing and then move onto more advanced topics such as
-composite/framework mojits, extending Mojito, and context configuration.
+intend to get in deeper with Mojito. We'll start the discussion with assets, cookies,
+logging, testing, and then move onto more advanced topics such as
+composite/framework mojits, extending Mojito, and context configurations.
.. _mojito_doc_directory-code_exs:
@@ -63,7 +63,7 @@ Besides reading documentation and working through code examples, there
are many other ways to learn about Mojito, so we've compiled a page where
you can find presentations, videos, screencasts, articles, and blogs.
You can also find Twitter handles to follow for the latest news and
-the YDN forum for Mojito.
+the YDN forum for Mojito, where you can post questions.
.. toctree::
:maxdepth: 4
View
6 docs/dev_guide/intro/mojito_apps.rst
@@ -20,9 +20,9 @@ Overview
Mojito applications contains JSON configuration files and directories for
storing JavaScript, HTML, and CSS. The configuration files can be used to
define relationships between code components, assets, routing paths, defaults
-and are available at the application and mojit-level. The directory structure
+and are available at the application and mojit level. The directory structure
of a Mojito application reflects the MVC architecture and separates resources,
-such assets, libraries, middleware, etc.
+such as assets, libraries, middleware, etc.
To create a Mojito application, you use the command-line tool ``mojito``. When
the command below is run, Mojito creates a directory structure with files for
@@ -37,7 +37,7 @@ that create the rectangular areas of a page.
To create a mojit, you run the command below from the application directory,
which creates another directory structure and files that include the mojit
-controller, model, binders, and views.
+controller, model, binder, and view.
``$ mojito create mojit <mojito_app>``
View
22 docs/dev_guide/intro/mojito_configuring.rst
@@ -51,10 +51,11 @@ and `Mojit Configuration`_ for details about specific configuration files.
YAML
####
-Mojito also supports configuration files in YAML format. The YAML file extension could
-be ``.yaml`` or ``.yml``. Mojito allows comments in the YAML files. When both JSON file
-and YAML files are present, the YAML file is used and a warning is issued. For the data
-types of the YAML elements, please see the JSON configuration tables in
+Mojito also supports configuration files in YAML format (JSON is a subset of YAML).
+The YAML file extension could be ``.yaml`` or ``.yml``. Mojito allows comments in the
+YAML files. When both the JSON file (e.g., ``application.json``) and the YAML file
+(e.g., ``application.yaml``) are present, the YAML file is used and a warning is issued.
+For the data types of the YAML elements, please see the JSON configuration tables in
:ref:`Application Configuration <configure_mj-app>`,
:ref:`Routing <configure_mj-routing>`, and :ref:`Mojit Configuration <configure_mj-mojit>`.
@@ -614,7 +615,7 @@ The following is deployed to the client:
When a binder invokes its controller, if the controller has the ``client`` or ``common``
affinity, then the controller and its dependencies are deployed to the client as well. If
the affinity of the controller is ``server``, the invocation occurs on the server. In
-either case, the binder is able to seamlessly invoke the controller.
+either case, the binder can invoke the controller.
.. _deploy_app-ex:
@@ -784,7 +785,7 @@ put in the ``config`` object.
Mojit Instances
---------------
-A mojit instance is made entirely of configuration. This configuration specifies
+A mojit instance is defined with configuration. This configuration specifies
which mojit type to use and configures an instance of that type. The mojit
instances are defined in the ``specs`` object of the ``application.json`` file.
@@ -1145,9 +1146,6 @@ would call the ``index`` action:
- ``http://localhost:8666/1_mojito``
- ``http://localhost:8666/99_Mojitos``
-.. _generate_urls:
-
-.. _generate_urls:
.. _generate_urls:
@@ -1189,11 +1187,11 @@ The ``index`` function above returns the following URL: ``http://localhost:8666/
Accessing Configurations from Mojits
====================================
-The model, and binder can access mojit configurations from the ``init``
+The model and binder can access mojit configurations from the ``init``
function. The controller and model are passed ``configuration`` objects. The controller
can access configuration the ``actionContext`` object and the ``Config`` addon.
-The ``init`` function in the binder instead of a configuration object is passed the
-``mojitProxy`` object, which enables you to get the configurations.
+The ``init`` function in the binder, instead of a configuration object, is passed the
+``mojitProxy`` object, which enables you to access configurations.
.. _configuring_access-applevel:
View
2  docs/dev_guide/intro/mojito_mojits.rst
@@ -114,7 +114,7 @@ See `Addons <../api_overview/mojito_addons.html>`_ in the
View Files
##########
-View files are called templates in Mojito. View templates can contain both HTML
+View files are called templates in Mojito. Templates can contain both HTML
and templating tags/expressions, such as Mustache or Handlebars, and are rendered into
markup that is outputted to the client.
View
32 docs/dev_guide/intro/mojito_mvc.rst
@@ -3,21 +3,18 @@ MVC in Mojito
=============
The MVC architecture in Mojito incorporates a clear separation of the
-controller, model, and view. The controller retrieves data from the model
+controller, model, and view. The controller is pivotal in the sense that it controls
+all interactions in the MVC of Mojito.The controller retrieves data from the model
and passes it to the view. Client requests for data are sent to the controller,
which in turn fetches data from the model and passes the data to the client.
-The controller is pivotal in the sense that it controls all interactions in
-the MVC of Mojito.
The controller, model, and view are found in the mojit of Mojito. The mojit
is a single unit of execution of a Mojito application. An application may
-have one or more mojits, which are physically represented by directory
-structure. The mojit has one controller, any number or no models, and one
+have one or more mojits, which are physically represented by a directory
+structure. Each mojit has one controller, any number or no models, and one
or more views. When Mojito receives an HTTP request, an application invokes
a mojit controller that can then execute, pass data to the view, or get data
-from the model. Now that we have described the general characteristics and
-implementation of the MVC in Mojito, let's look at each of the components in
-more detail.
+from the model. Let's look now at each of the MVC components in more detail.
.. _mojito_mvc-models:
@@ -72,7 +69,7 @@ A model should have the basic structure shown below.
.. code-block:: javascript
YUI.add('{mojit_name}Model{Model_name}', function(Y, NAME) {
- // Models must register themselves in the
+ // Models must register themselves with YUI.add
// Namespace for models
Y.namespace('mojito.models')[NAME] = {
// Optional init() method is given the
@@ -291,6 +288,11 @@ Several objects and methods form the backbone of the controller.
- ``requires`` - (optional) an array that lists any addons that are needed
by the controller.
+.. _mvc_controller-ex:
+
+Example
+-------
+
The example controller below shows you how the components are used. The
``status`` mojit is registered with ``YUI.add`` and the ``init`` function
stores the date so it can be used by other functions, and the ``this``
@@ -397,7 +399,8 @@ syntax convention. The ``ActionContext`` object allows controller functions
to access framework features such as API methods and addons that extend
functionality. To access the model from the ActionContext object ``ac``,
you use the following syntax: ``ac.models.get('{model_name}').{model_function}``
-
+You also need to require the ``Models`` addon by adding the string
+``"mojito-models-addon"`` to the ``requires`` array.
The ``{model_name}`` is the YUI module name that is passed to ``YUI.add`` of the
model file, not the model file name. The example controller below shows the
@@ -546,7 +549,7 @@ Reporting Errors
The ``ActionContext`` object has an ``error`` method for reporting errors.
Like the ``done`` method, ``error`` should only be called once. Also, you
cannot call both ``done`` and ``error``. The error requires an ``Error``
-object as a parameter. The ``Error`` object is just the standard JavasScript
+object as a parameter. The ``Error`` object is just the standard JavaScript
``Error`` object that can have a ``code`` property specifying the HTTP response
code that will be used if the error bubbles to the top of the
page (i.e., not caught by a parent mojit).
@@ -562,7 +565,7 @@ to get a blog post. The ``try-catch`` clause will catch any errors made calling
try {
var post = ac.models.get('BlogModel').getPost();
ac.done({ "post": post });
- }catch(e) {
+ } catch(e) {
console.log(e);
ac.error(e);
}
@@ -587,7 +590,7 @@ have substituted values for the template tags.
Naming Convention
-----------------
-The naming convention of the templates is based on the controller function
+The naming convention of the templates is based on the controller function (action)
that supplies data, the engine that renders the templates, and the device
requesting the page. If the calling device is determined not to be a portable
device such as a cell phone, the ``{device}`` element of the syntax below
@@ -607,8 +610,7 @@ Here are some other example template names with descriptions:
function of the controller and the calling device is determined to
be a Web browser.
- ``get_photos.iphone.hb.html`` - This template gets data from the
- ``get_photos`` function
- of the controller and the calling device is an iPhone.
+ ``get_photos`` function of the controller and the calling device is an iPhone.
- ``find_friend.android.hb.html`` - This template gets data from the
``find_friend`` function of the controller and the calling device is Android
based.
View
26 docs/dev_guide/reference/mojito_cmdline.rst
@@ -62,7 +62,7 @@ Mojito Archetypes
Mojito offers the following three archetypes for applications and mojits.
- ``simple`` - The minimal configuration and code needed to run an application.
-- ``default`` - This archetype is run if no command line archetype option is
+- ``default`` - This archetype is run if no command-line archetype option is
specified. It is a happy medium between ``simple`` and ``full``.
- ``full`` - Provides the most comprehensive configuration and code for
applications.
@@ -277,30 +277,10 @@ applications that can access native features of mobile devices.
The generated application contains Mojito, frame mojits, the default mojit
``top_frame``, your created mojits, and application configuration. The command
-will also create a ``snapshot.json`` file that can be used tracking and updating applications.
+will also create a ``snapshot.json`` file that can be used tracking and updating
+applications.
-.. _build_types-hybridapp:
-
-hybridapp
-#########
-
-
-To build a hybrid application, use either of the following.
-
-``$ mojito build hybridapp [--context <context>] --snapshotName <snapshot_name> --snapshotTag <snapshot_tag> [<path/to/app/>]``
-
-``$ mojito build hybridapp [-c <context>] -n <snapshot_name> -t <snapshot_tag> [<path/to/app/>]``
-
-
-This generates a HTML5 application that is customized to work with a future component
-of the Cocktails suite that will allow you to write HTML5/JavaScript applications
-that can access native features of mobile devices.
-
-The generated application contains Mojito, frame mojits, the default mojit ``top_frame``,
-your created mojits, and application configuration. The command will also create
-a ``snapshot.json`` file that can be used tracking and updating applications.
-
.. _mj_cmdlne-compile_sys:
View
4 docs/dev_guide/topics/mojito_assets.rst
@@ -180,8 +180,8 @@ the ``<link>`` tag refers to the static URL to the asset ``index.css``.
</ul>
</div>
-From the static URL, you cannot tell the asset is mojit or application level,
-but you do know that either the application or the mojit is ``simple``.
+From the static URL, you cannot tell whether the asset is at the mojit or application
+level, but you do know that either the application or the mojit is ``simple``.
.. _mojito_assets-using:
View
10 docs/dev_guide/topics/mojito_composite_mojits.rst
@@ -90,11 +90,11 @@ as Handlebars expressions in the ``index`` template of the parent mojit.
For example, in the example controller of the parent mojit below, the ``index``
function calls ``ac.composite.done``, which executes ``ac.done`` in the
-``index`` functions of the child mojits. The rendered ``index`` views for
-each of the child mojits is then available to as a Handlebars expression, such
-as ``{{{child_mojit}}}``. Notice that the ``template`` object allows the parent
-mojit to send data to the template, so that ``{{title}}`` can be used in the
-template.
+``index`` functions of the child mojits. The rendered ``index`` templates for
+each of the child mojits is then available as a Handlebars expression, such
+as ``{{{child_mojit}}}`` in the parent template. Notice that the ``template`` object
+allows the parent mojit to send data to the template, so that ``{{title}}`` can be
+used in the template.
.. code-block:: javascript
View
26 docs/dev_guide/topics/mojito_data.rst
@@ -370,6 +370,32 @@ To get all of the GET, POST, and routing parameters, call ``getFromMerged`` or
}
}, '0.0.1', {requires: ['mojito-params-addon']});
+.. _mojito_params_addon-aliases:
+
+Params Addon Method Aliases
+===========================
+
+We have looked at the methods of the ``Params`` addon for getting query string
+parameter, query string parameters, and HTTP body data. For simplicity,
+the ``Params`` addon also provides the aliases below
+for the methods that we have covered thus far.
+
++---------------------+--------------+
+| Method | Alias |
++=====================+==============+
+| ``getAll()`` | ``all()`` |
++---------------------+--------------+
+| ``getFromBody()`` | ``body()`` |
++---------------------+--------------+
+| ``getFromFiles()`` | ``files()`` |
++---------------------+--------------+
+| ``getFromMerged()`` | ``merged()`` |
++---------------------+--------------+
+| ``getfromRoute()`` | ``route()`` |
++---------------------+--------------+
+| ``getFromUrl()`` | ``url()`` |
++---------------------+--------------+
+
.. _mojito_data-cookie:
View
10 docs/dev_guide/topics/mojito_extensions.rst
@@ -131,7 +131,7 @@ plugin name (``'addon-ac-cheese'``) and the constructor (``CheeseAcAddon``) with
.. _extending_addons-writing_ex:
Example Addon
-*************
+#############
In the example addon ``cheese.common.js`` below, the ``YUI.add`` method
registers the ``addon-ac-cheese`` plugin. The addon namespace
@@ -477,7 +477,7 @@ section.
- **view engine addon** - The Mojito addon that compiles and renders templates.
The addon typically relies on a rendering engine to compile and render templates,
but may include code to do the compilation and rendering.
-- **rendering engine** - The rendering engine is typically an off-the-shelf
+- **rendering engine** - The rendering engine is typically off-the-shelf
technology, such as `Dust <http://akdubya.github.com/dustjs>`_,
`Jade <http://jade-lang.com/>`_, or `EJS <http://embeddedjs.com/>`_, that
renders the template into markup for an HTML page.
@@ -521,7 +521,7 @@ The name of the template should have the following syntax where
``{view_engine_name}`` should be the same as the ``{view_engine_name}`` in
the file name of the view engine addon.
-``{view}.{view_engine_name}.html``
+``{action}.[{device}].{view_engine_name}.html``
.. _extending_ve-loc:
@@ -574,9 +574,9 @@ The view engine addon must have the following:
.. code-block:: javascript
- YUI.add('addons-viewengine-hb', function(Y, NAME) {
+ YUI.add('addons-viewengine-ejs', function(Y, NAME) {
- // The addon name 'addons-viewengine-hb' is registered by YUI.add
+ // The addon name 'addons-viewengine-ejs' is registered by YUI.add
}, '0.1.0', {requires: []});
View
6 docs/dev_guide/topics/mojito_frame_mojits.rst
@@ -28,8 +28,8 @@ Because it builds the Web page from the framework to the content and styling, th
``HTMLFrameMojit`` must be the top-level mojit in a Mojito application. As the top-level
or parent mojit, the ``HTMLFrameMojit`` may have one or more child mojits.
-To create a Mojito application that uses the ``HTMLFrameMojit``, see the code examples
-`Using the HTML Frame Mojit <../code_exs/htmlframe_view.html>`_
+To see examples of applications using ``HTMLFrameMojit``, see the
+code examples `Using the HTML Frame Mojit <../code_exs/htmlframe_view.html>`_
and `Attaching Assets with HTMLFrameMojit <../code_exs/framed_assets.html>`_.
.. _fw_mojits_htmlframe-config:
@@ -302,7 +302,7 @@ Example
This example shows you application configuration as well as the code for the
parent mojit and the child mojit that is lazy loaded. If you were to run
this lazy load example, you would see the content of the parent mojit first
-and then see the child mojit's output loaded in the page.
+and then see the rendered view of the child mojit loaded onto the page.
.. _lazyload_ex-app_config:
View
7 docs/dev_guide/topics/mojito_npm.rst
@@ -123,8 +123,6 @@ others can package the Mojito resources in an npm module. The npm module is
simply a container for the Mojito resource(s). The npm module must specify that
it contains a Mojito resource in its ``package.json``.
-
-
.. _res_def_metadata:
General Process of Authoring an npm Module Containing Shared Mojito Resources
@@ -158,7 +156,6 @@ for details about the properties of the ``mojito`` object.
}
-
.. _moj_object:
mojito object
@@ -208,8 +205,8 @@ mojit
The ``mojit`` type specifies that the npm module contains a mojit. The
resources in the mojit (controller, models, views, etc.) will be looked for at
the location specified by the ``"location"`` field of the ``mojito`` object.
-For example, the controller will be looked for in the following location,
-where ``{name}`` is the name of the npm package:
+For example, the controller will be looked for in the following location:
+
``{location}/controller.{affinity}.{selector}.js``
.. _bundle_type:
View
10 docs/dev_guide/topics/mojito_resource_store.rst
@@ -21,7 +21,7 @@ Intended Audience
Only advanced Mojito application developers needing finer grain control over
the management of resources or to extend the functionality of the resource
-store should read this documentation.
+store need to read this documentation.
.. _intro-prereqs:
@@ -189,7 +189,7 @@ Resource Metadata
Intro
-----
-The RS uses metadata to track information about each resource. This metadata
+The |RS| uses metadata to track information about each resource. This metadata
is used by the rest of Mojito to find, load, and parse the resources. The
metadata is generated by the |RS| or by |RS| addons |---| it has no
representation on the filesystem.
@@ -434,7 +434,6 @@ Only one selector can be used in each configuration object identified by the
must match the selector found in the resource file names. So, for example,
the template ``views/index.iphone.hb.html`` has the selector ``iphone``.
-.. _sel_prop-ex:
.. _sel_prop-ex:
@@ -521,7 +520,7 @@ Example
"selector": "iphone",
"view": {
"outputFormat": "html",
- "engine": "mu"
+ "engine": "hb"
},
"url": "/static/PagedFlickr/views/index.hb.html"
}
@@ -571,7 +570,7 @@ packages have precedence over *deeper* ones. (Not all the packages are used: onl
those that have declared themselves as extensions to Mojito.) Finally, if Mojito
wasn't found in ``node_modules``, the globally-installed version of Mojito is walked.
-After all that, the |RS| knows about all the resource versions. Then it resolves
+After all that, the |RS| knows about all the resource versions. Then it resolves
those versions into the resources as described in
:ref:`Resolution and Priorities <how-resolution>`.
@@ -650,7 +649,6 @@ and ``controller.common.iphone.js``, for the server and context
``{device:iphone}``, the second version will be used because its selector
is a higher priority match than its affinity.
-
All this is pre-calculated for each resource and for each possible runtime
configuration (client or server, and every appropriate runtime context).
View
78 docs/dev_guide/topics/mojito_testing.rst
@@ -94,7 +94,7 @@ have the string ``-tests`` appended to the affinity. For example, the mojit
controller with the ``common`` affinity would be ``controller.common.js``,
so the name of the test file must be ``controller.common-tests.js``.
-The ``controller.common.js`` below requires the ``Foo`` module.
+The ``controller.common.js`` below registers the ``Foo`` module.
.. code-block:: javascript
@@ -103,7 +103,7 @@ The ``controller.common.js`` below requires the ``Foo`` module.
});
To test the ``Foo``, module, the the test file ``controller.common-tests.js`` would
-require the ``Foo-tests`` module as seen below.
+require the ``Foo`` and 'mojito-test' modules as seen below.
.. code-block:: javascript
@@ -143,7 +143,7 @@ The ``controller.server.js`` below requires the ``Foo`` module.
To test the controller of the ``Foo`` mojit, create a file in the tests
directory called ``controller.common-tests.js`` that includes the ``Foo-tests``
module as seen below. Note that the reference to the controller is gotten
-using ``Y.mojito.controller`` or ``Y.mojito.controllers[NAME]``.
+using ``Y.mojito.controllers[NAME]``.
.. code-block:: javascript
@@ -154,7 +154,7 @@ using ``Y.mojito.controller`` or ``Y.mojito.controllers[NAME]``.
suite.add(new YUITest.TestCase({
name: 'Foo tests',
setUp: function() {
- controller = Y.mojito.controller;
+ controller = Y.mojito.controllers[NAME];
},
tearDown: function() {
controller = null;
@@ -363,6 +363,9 @@ the namespaces of the addons within the ``MockActionContext`` constructor:
returns: 'updating, yo'
});
+
+
+
.. _mock_custom_addons:
Mocking Custom Addons
@@ -417,6 +420,69 @@ array with the model YUI modules as is done with addons:
}
);
+.. _mock_addons-ex:
+
+Example MockAction Test
+-----------------------
+
+.. _mock_addons_ex-controller:
+
+controller.server.js
+####################
+
+
+.. code-block:: javascript
+
+ YUI.add('myMojit', function(Y, NAME) {
+ Y.namespace('mojito.controllers')[NAME] = {
+ index: function(ac) {
+ ac.done({
+ status: 'Mojito is working.',
+ });
+ }
+ };
+ }, '0.0.1', {requires: ['mojito', 'myMojitModelFoo']});
+
+.. _mock_addons_ex-controller_test:
+
+controller.server-tests.js
+##########################
+
+.. code-block:: javascript
+
+ YUI.add('tester-tests', function(Y) {
+ var suite = new YUITest.TestSuite('tester-tests'),
+ controller = null,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+ name: 'tester user tests',
+ setUp: function() {
+ controller = Y.mojito.controllers.tester;
+ },
+ tearDown: function() {
+ controller = null;
+ },
+ 'test mojit': function() {
+ var ac = new Y.mojito.MockActionContext({});
+ A.isNotNull(controller);
+ A.isFunction(controller.index);
+ ac.expect({
+ method: 'done',
+ args: [YUITest.Mock.Value.Object],
+ callCount: 1,
+ run: function(data){
+ YUITest.ObjectAssert.areEqual({ status: 'Mojito is working.' },data);
+ }
+ });
+ controller.index(ac);
+ ac.verify();
+ }
+ }));
+ YUITest.TestRunner.add(suite);
+ }, '0.0.1', {requires: ['mojito-test', 'myMojit']});
+
+
.. _mojito_testing-models:
Model Tests
@@ -612,8 +678,8 @@ or unit tests with one command.
Using Arrow to Run Tests
************************
-You can also separately run unit and functional tests directly
-with the ``arrow`` command. You pass Arrow a test descriptor, which
+You can also run individual unit and functional tests
+with the ``arrow`` command. You just pass Arrow a test descriptor, which
is a JSON configuration file that describes and organizes your tests.
For an overview of Arrow and the command-line options, see
the `Arrow README <https://github.com/yahoo/arrow/blob/master/README.md>`_.
View
6 docs/dev_guide/topics/mojito_using_contexts.rst
@@ -96,7 +96,7 @@ with the HTTP header ``"User-Agent: Mozilla/5.0 (Linux; U; Android 2.3; en-us)"`
Query String Parameters
#######################
-The key and value pairs in the context are dynamically set by the query string.
+The query string can also dynamically set the context.
.. _request_query_str-syntax:
@@ -255,9 +255,7 @@ then mapped to configurations.
Default Configurations
**********************
-Default configurations are used when no context is given. These configurations
-are found in the object where the settings array has the string ``"master"`` as
-seen below.
+The configurations for the ``"master"`` context are used when no context is given.
.. code-block:: javascript
Something went wrong with that request. Please try again.