Permalink
Browse files

Merge pull request #821 from zhouyaoji/docs_autoload_to_yui_modules

[docs] Changed the autoload directory to yui modules directory, but left notes that both can be used.
  • Loading branch information...
Joe Catera
Joe Catera committed Dec 4, 2012
2 parents d28e292 + e87716d commit 80002a53d203756e889d29157638c1edb8a83725
@@ -19,7 +19,7 @@ page views and browser sessions.
The following topics will be covered:
-- adding YUI modules to the ``autoload`` directory
+- adding YUI modules to the ``yui_modules`` directory
- accessing YUI modules from a mojit
.. _code_exs-incl_yui_mods-notes:
@@ -38,9 +38,9 @@ Location
########
To add YUI modules that all your mojits can access, place the modules in the
-``autoload`` directory under the application directory. For example, YUI
+``yui_modules`` directory under the application directory. For example, YUI
modules in the ``hello_world`` application would be placed in
-``hello_world/autoload``.
+``hello_world/yui_modules``.
.. _yui_mod_impl_add-naming:
@@ -70,15 +70,15 @@ the module identified by the string ``'gallery-storage-lite'``.
YUI.add('gallery-storage-lite', function (Y) {
...
- }, '1.0.0', { requires: ['event-base', 'event-custom', 'event-custom-complex', 'json']});
+ }, '1.0.0', { requires: [ 'event-base', 'event-custom', 'event-custom-complex', 'json']});
.. _yui_mod_impl-using:
Using a YUI Module from Mojits
------------------------------
-After registered YUI modules have been added to the ``autoload`` directory, you
+After registered YUI modules have been added to the ``yui_modules`` directory, you
can load them into your mojit code by listing them as dependencies in the
``requires`` array. In the binder ``index.js`` below, you can see that the
Storage Lite module that we created and registered in :ref:`registering_module`
@@ -95,7 +95,7 @@ is listed as a dependency in the ``requires`` array.
...
}
};
- // See autoload/storage-lite.client.js
+ // See yui_modules/storage-lite.client.js
}, '0.0.1', {requires: [ 'gallery-storage-lite' ]});
In the ``bind`` method, ``Y.StorageLite.getItem`` and ``Y.StorageLite.setItem``
@@ -177,12 +177,12 @@ To set up and run ``yui_module``:
}
]
-#. Create the autoload directory for storing the Storage Lite module.
+#. Create the ``yui_modules`` directory for storing the Storage Lite module.
- ``$ mkdir autoload``
-#. Get the Storage Lite module and place it in the ``autoload`` directory.
+ ``$ mkdir yui_modules``
+#. Get the Storage Lite module and place it in the ``yui_modules`` directory.
- ``$ wget -O autoload/storage-lite.client.js https://raw.github.com/rgrove/storage-lite/master/src/storage-lite.js --no-check-certificate``
+ ``$ wget -O yui_modules/storage-lite.client.js https://raw.github.com/rgrove/storage-lite/master/src/storage-lite.js --no-check-certificate``
#. Change to ``mojits/Notepad``.
#. Replace the code in ``controller.server.js`` with the following:
@@ -227,7 +227,7 @@ To set up and run ``yui_module``:
};
}, '0.0.1', {
requires: [
- 'gallery-storage-lite' //see autoload/storage-lite.client.js
+ 'gallery-storage-lite' //see yui_modules/storage-lite.client.js
]
});
@@ -56,9 +56,9 @@ globally available to all mojits. Those marked with an asterisk are not created
- ``assets`` - general directory containing CSS files for all mojits.
- ``application.json`` - application configuration file that lets you specify
the port and the mojits used by the application.
-- ``autoload`` - directory of JavaScript files that contain YUI modules added
- with ``YUI.add``. These files aren't actually *auto-loaded*, but are merely
- automatically included if required by a YUI module.
+- ``yui_modules`` - directory of JavaScript files that contain YUI modules added
+ with ``YUI.add``. These files are automatically included if required by a
+ YUI module.
- ``default.json`` - file that sets default values for all specifications.
- ``mojits`` - directory storing the mojits. See `Mojit Files and Directories`_
for a description of the directory contents.
@@ -94,10 +94,10 @@ is available.
- ``actions`` - directory of JavaScript files containing methods to add to the
controller. Actions are useful for maintaining large controllers.
- ``assets`` - directory for storing CSS or JavaScript files.
-- ``autoload`` - directory containing JavaScript files that contain YUI
- modules added with ``YUI.add``. These files aren't actually *autoloaded*,
- but are merely automatically included if required by a YUI module. Both
- the application directory and mojit directory can have ``autoload`` directories.
+- ``yui_modules`` - directory containing JavaScript files that contain YUI
+ modules added with ``YUI.add``. These files are automatically included if required by a
+ YUI module. Both the application directory and mojit directory can have ``yui_modules``
+ directories.
- ``binders`` - directory containing event binding files for the mojit.
- ``controller.server.js`` - the mojit controller that runs on the server. You
can also create the file ``controller.client.js`` to have a mojit controller
@@ -117,11 +117,11 @@ is available.
- ``{model_name}.{affinity}-tests.js`` - the unit tests for the mojit
models.
- ``{module_name}.{affinity}-tests.js`` - the unit tests for YUI modules,
- which are located in ``mojits/{mojit_name}/autoload`` directory.
+ which are located in ``mojits/{mojit_name}/yui_modules`` directory.
- Example of module and corresponding test:
- - ``{app_name}/mojits/{mojit_name}/autoload/{module_name}.{affinity}.js``
+ - ``{app_name}/mojits/{mojit_name}/yui_modules/{module_name}.{affinity}.js``
-- ``{app_name}/mojits/{mojit_name}/tests/autoload/{module_name}.{affinity}-tests.js``
+- ``{app_name}/mojits/{mojit_name}/tests/yui_modules/{module_name}.{affinity}-tests.js``
- ``views`` - directory containing the templates.
@@ -147,13 +147,13 @@ rendering engine.
|-- application.json
|-- assets/
| `-- favicon.icon
- |-- autoload/
+ |-- yui_modules/
| `-- *.{affinity}.js
|-- index.js
|-- mojits/
| `-- [mojit_name]
| |-- assets/
- | |-- autoload/
+ | |-- yui_modules/
| | `-- *.{affinity}.js
| |-- binders/
| | `-- {view_name}.js
@@ -165,7 +165,7 @@ rendering engine.
| |-- models/
| | `-- {model_name}.{affinity}.js
| |-- tests/
- | | |-- autoload/
+ | | |-- yui_modules/
| | | `-- {module_name}.{affinity}-tests.js
| | |-- controller.{affinity}-tests.js
| | `-- models/
@@ -105,11 +105,11 @@ configuration Object
| | | | to cache the view. Note that not all view engines |
| | | | support caching. |
+--------------------------------------------------------+----------------------+-------------------+--------------------------------------------------------+
-| ``deferAllOptionalAutoloads`` | boolean | false | Specifies whether optional YUI modules found in |
-| | | | the ``/autoload/`` directories are not shipped to |
-| | | | the client. This is an optimization setting and |
-| | | | should generally only be set if you are building |
-| | | | an offline application. |
+| ``deferAllOptionalAutoloads`` | boolean | false | Specifies whether optional YUI modules found in the |
+| | | | ``/autoload/`` and ``/yui_modules/`` directories are |
+| | | | not shipped to the client. This is an optimization |
+| | | | setting and should generally only be set if you are |
+| | | | building an offline application. |
+--------------------------------------------------------+----------------------+-------------------+--------------------------------------------------------+
| ``middleware`` | array of strings | [] | A list of paths to the Node.js module that exports |
| | | | a Connect middleware function. |
@@ -51,13 +51,6 @@ assets
application. See `Mojito Developer Topics: Assets <../topics/mojito_assets.html>`_ to
learn how to use assets in Mojito applications.
-autoload
---------
-
- A directory of a Mojito application containing JavaScript files that use YUI modules
- added with ``YUI.add``. These files aren't actually *auto-loaded*, but are merely
- automatically included if required by a YUI module.
-
binder
------
@@ -18,8 +18,8 @@ Issues
called? <moj_binder_init>`
* :ref:`I am getting Handlebars rendering errors. Is this a client-side or server-side
issue with Handlebars and can it be fixed? <handlebars_rendering_error>`
-* :ref:`Why can't my controller access the YUI modules in the "autoload" directory?
- <controller_access_autoload>`
+* :ref:`Why can't my controller access the YUI modules in the "yui_modules" directory?
+ <controller_access_yui_modules>`
* :ref:`Why am I getting the error message "EADDRINUSE, Address already in use" when I try
to start Mojito? <eaddriuse_err>`
* :ref:`When I execute child mojits with "composite.execute", the views are being rendered,
@@ -148,9 +148,9 @@ prototype so that your templates can be rendered. Try doing the following:
------------
-.. _controller_access_autoload:
+.. _controller_access_yui_modules:
-**Q:** *Why can't my controller access the YUI modules in the "autoload" directory?*
+**Q:** *Why can't my controller access the YUI modules in the "yui_modules" directory?*
**A:**
A common problem is that the YUI module is missing the
@@ -248,14 +248,14 @@ the ``<meta>`` tag and the ``addCss`` method adds the device-specific CSS.
YUI Assets
==========
-YUI modules should be placed in the ``autoload`` directory and **not**
+YUI modules should be placed in the ``yui_modules`` directory and **not**
the ``assets`` directory. When your mojit code wants to use one of the YUI
-modules in the ``autoload`` directory, you add the module name in the
+modules in the ``yui_modules`` directory, you add the module name in the
``requires`` array, and Mojito will automatically load the module.
For example, to use a YUI module called ``substitute`` in your mojit
controller, you would place the ``substitute.js`` file in the
-``autoload`` directory and then add the module name in the ``requires``
+``yui_modules`` directory and then add the module name in the ``requires``
array as seen in the example mojit controller below.
.. code-block:: javascript
@@ -296,7 +296,7 @@ be a child of the `HTMLFrameMojit <../topics/mojito_frame_mojits.html#htmlframem
When you run ``mojito compile inlinecss``, the CSS files in
``/mojits/{mojit_name}/assets/`` are compiled into the YUI module
-``/mojits/{mojit_name}/autoload/compiled/inlinecss.common.js``.
+``/mojits/{mojit_name}/yui_modules/compiled/inlinecss.common.js``.
Mojito will use the compiled CSS and insert inline CSS into the ``<head>``
element of the rendered view. See also
`Compiling Inline CSS <../reference/mojito_cmdline.html#compiling-inline-css>`_.
@@ -318,11 +318,11 @@ Location of YUI Modules
Application-level YUI modules should be placed in the following directory:
-``{app_dir}/autoload/``
+``{app_dir}/yui_modules/``
Mojit-level YUI modules should be placed in the following directory:
-``{mojit_dir}/autoload/``
+``{mojit_dir}/yui_modules/``
.. _libraries_yui-using:
@@ -343,7 +343,7 @@ for the ``UID`` namespace. This will let you create an instance, and the
``prototype`` object then allows you to access the method ``log`` from that
instance.
-``{mojit_dir}/autoload/hello-uid.server.js``
+``{mojit_dir}/yui_modules/hello-uid.server.js``
.. code-block:: javascript
@@ -1048,7 +1048,7 @@ The |RS| comes with the following four built-in addons:
- calculates the asset URL base for each mojit
- ``yui``
- registers new resource type ``yui-module`` found in the directories
- ``autoload`` or ``yui_modules``
+ ``yui_modules`` or ``autoload``
- registers new resource type ``yui-lang`` found in the ``lang`` directory
- calculates the ``yui`` metadata for resource versions that are YUI modules
- pre-calculates corresponding YUI module dependencies when resources are
@@ -18,9 +18,9 @@ Conventions
- ``{app_name}/tests`` - application tests
- ``{app_name}/mojits/{mojit_name}/tests`` - mojit tests
- - ``{app_name}/autoload/{yui_module}/tests`` - tests for
+ - ``{app_name}/yui_modules/{yui_module}/tests`` - tests for
application-level YUI modules
- - ``{app_name}/mojits/{mojit_name}/autoload/{yui_module}/tests`` - tests for
+ - ``{app_name}/mojits/{mojit_name}/yui_modules/{yui_module}/tests`` - tests for
mojit-level YUI modules
- Syntax for the name of the test file: ``{yui_module}.{affinity}-tests.js``
@@ -6,10 +6,10 @@ Create project and mojit
mojito create app simple yui_module
mojito create mojit simple Notepad
-Put a YUI Gallery Module in ./yui_module/autoload AND rename it to include an affinity:
+Put a YUI Gallery Module in ./yui_modules/ AND rename it to include an affinity:
- mkdir ./yui_module/autoload
- wget -O ./yui_module/autoload/storage-lite.client.js \
+ mkdir ./yui_modules/
+ wget -O ./yui_modules/storage-lite.client.js \
https://raw.github.com/rgrove/storage-lite/master/src/storage-lite.js
Edit application.json "specs":
@@ -38,5 +38,5 @@ YUI.add('NotepadBinderIndex', function (Y, NAME) {
};
}, '0.0.1', {requires: [
- 'gallery-storage-lite' //see autoload/storage-lite.client.js
+ 'gallery-storage-lite' //see yui_modules/storage-lite.client.js
]});
@@ -1,6 +1,6 @@
{
"name": "yui_module",
- "description": "example mojit showing how to load YUI modules that are in the autoload directory.",
+ "description": "example mojit showing how to load YUI modules that are in the yui_modules directory.",
"version": "0.0.1",
"author": {
"name": "Isao Yagi",

0 comments on commit 80002a5

Please sign in to comment.