Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1361 from zhouyaoji/docs_cli

[docs] Removed references to 'mojito start', corrected sections on setting the base context, updated the command-line section.
  • Loading branch information...
commit 07ec1ef2471787ffeec006c9b5293ab89e51e6fb 2 parents 8fbdc5c + 52340a2
@zhouyaoji zhouyaoji authored
View
32 docs/dev_guide/faq/index.rst
@@ -21,7 +21,6 @@ General
* :ref:`Does Mojito have API methods for handling caching? If not, what's the best way for Mojito
applications to handle caching? <moj_caching>`
* :ref:`Can Mojito make runtime decisions to run client-side or server-side code? <moj_run_client_server>`
-* :ref:`Can Mojito be started with Node.js instead of using "mojito start"? <moj_node_start>`
* :ref:`How can I improve the performance of my Mojito application? <moj_optimize_performance>`
* :ref:`Can I start an application so that it listens to requests made to a specific IP address or hostname? <moj_ip_address>`
@@ -189,9 +188,16 @@ General
.. note:: Your application has to deploy code to the client, so
``deploy`` must be set to ``true``.
- #. Start your application with the context ``environment:development``:
+ #. Modify your ``app.js`` to start with the context ``environment:development``:
- ``$ mojito start --context environment:development``
+ .. code-block:: javascript
+
+ libmojito.extend(app, {
+ context: {
+ runtime: 'server',
+ environment: 'development'
+ }
+ });
#. Open your application in a browser.
#. Modify code in your binders or templates.
#. Refresh your browser to see the updates in your application.
@@ -236,14 +242,14 @@ General
``$ sudo npm install supervisor -g``
#. From a Mojito application directory, start Mojito with ``supervisor``:
- ``$ supervisor -x path/to/mojito/bin/mojito start``
+ ``$ supervisor -x node app.js``
#. View your application in a browser.
#. In a separate terminal window, make changes to the source code of the application.
#. Refresh the page to view the modified application.
.. note:: ``supervisor`` will only update files with extensions ``node`` or ``js`` by
default. To have ``supervisor`` watch files with other extensions, use the
- option ``-e`` or ``--extensions``: ``$ supervisor -e js,json,html -x path/to/mojito start``
+ option ``-e`` or ``--extensions``: ``$ supervisor -e js,json,html -x node app.js``
------------
@@ -321,22 +327,6 @@ General
------------
-.. _moj_node_start:
-.. topic:: **Can Mojito be started with Node.js instead of using "mojito start"?**
-
- Yes. Although there is not a standard way for starting Mojito with Node.js, you could
- run the following from your application directory::
-
- $ node --debug server.js
-
-
- This will allow you to debug your server-side code with a tool such as
- `node-inspector <https://github.com/node-inspector/node-inspector>`_.
-
-------------
-
-
-
.. _moj_optimize_performance:
.. topic:: **How can I improve the performance of my Mojito application?**
View
110 docs/dev_guide/reference/mojito_cmdline.rst
@@ -168,15 +168,12 @@ Starting the Server
Use the following to start the server and run the application.
-``$ mojito start [<port>] [--context "key1:value1,key2:value2,key3:value3"]``
+``$ node app.js``
-The port number specified in the command above overrides the port number in
-the application configuration file, ``application.json``. The default port
-number is 8666. See :ref:`Specifying Context <mj_cmdline-context>` to learn
-how to use the ``--context`` option.
-
-.. note:: You can also start your application with Node.js by running the following command
- from the application directory: ``$ node --debug server.js``
+.. note:: Mojito v0.8 and earlier used the Mojito CLI utility to start
+ applications (``mojito start``). If you have an older application
+ you need to create an ``app.js`` first and then use ``node app.js``
+ to start the application.
.. _mj_cmdlne-js_lint:
@@ -267,47 +264,6 @@ Version Information
.. note:: Showing the version of the application and mojit requires that they have a
``package.json`` file.
-.. _mj_cmdlne-build_sys:
-
-Build System
-============
-
-Mojito comes with a build command for generating an HTML5 offline Mojito
-application that runs in different environments. The command must be run inside
-of the application you want built.
-
-``$ mojito build <type> [<output-path>] [--context "key1:value1,key2:value2,key3:value3"]``
-
-Output is written to ``{app-dir}/artifacts/builds/{type}`` by default. See
-:ref:`Specifying Context <mj_cmdline-context>` to learn about the ``--context``
-option.
-
-.. _build_sys-types:
-
-Build Types
------------
-
-The following sections describe the available build type.
-
-.. _build_types-html5app:
-
-html5app
-########
-
-To build an HTML 5 application, use the the following:
-
-``$ mojito build html5app``
-
-This generates a HTML5 Offline Application with a ``cache.manifest`` listing
-all the files that will be available offline. An ``index.hb.html`` page is
-generated from the result of calling the Web root ``/`` of the Mojito
-application that this command was run within. You can build other pages by
-specifying the pages in the ``"builds": "html5app"`` object in
-``application.json``. The `html5 <../intro/mojito_configuring.html#html5app-object>`_
-object lets you add the ``manifest`` attribute to the ``html`` element,
-configure relative paths, and specify a list of URLs to pages to generate.
-
-
.. _mj_cmdline-dependency:
Dependency Graphs (Deprecated)
@@ -330,21 +286,53 @@ The ``mojito gv`` command has the following options:
.. note:: To render the Graphviz files into GIF images, you need the `Graphviz - Graph
Visualization Software <http://www.graphviz.org/Download..php>`_.
+
+No Longer Supported
+===================
+
+As of Mojito v0.9, several command-line features are no longer supported.
+The following sections discuss what's not supported and offer possible solutions.
+
+.. _mj_cmdline-mojito_start:
+
+mojito start
+------------
+
+Applications are no longer started with ``mojito start``. You start applications
+with ``node`` and the boot file ``app.js``:
+
+``$ node app.js``
+
+.. _mj_cmdlne-build_sys:
+
+mojito build
+------------
+
+As of Mojito v0.9, the ``build`` command for creating HTML5 applications
+from Mojito applications is no longer available.
+
.. _mj_cmdline-context:
-Specifying Context
-==================
+Specifying Context: --context
+-----------------------------
+
+You can no longer specify the base context with the ``--context`` option.
+To specify a base context in Mojito v0.9 and later, you pass a ``context`` object
+to the ``extend`` method in the file ``app.js``. In the example snippet from
+``app.js`` below, the application when started will use the base context ``environment:staging``:
+
+.. code-block:: javascript
-When configuration files are read, a context is applied to determine which
-values will be used for a given key. The applied context is a combination of
-the dynamic context determined for each HTTP request and a static context
-specified when the server is started. See
-`Using Context Configurations <../topics/mojito_using_contexts.html>`_ for
-more information.
+ var express = require('express'),
+ libmojito = require('mojito'),
+ app = express();
-The static context can be specified by a command-line option whose value
-is a comma-separated list of key-value pairs. Each key-value pair is separated
-by a colon. Try to avoid using whitespace, commas, and colons in the keys and values.
+ libmojito.extend(app, {
+ context: {
+ runtime: 'server',
+ environment: 'staging'
+ }
+ });
-``$ mojito start --context "key1:value1,key2:value2,key3:value3"``
+Learn more about contexts in `Using Context Configurations <../topics/mojito_using_contexts.html>`_.
View
3  docs/dev_guide/reference/mojito_troubleshooting.rst
@@ -173,7 +173,8 @@ to start Mojito?*
**A:**
You probably have an instance of mojito already started/running (check the output from
``ps aux | grep mojito``). Either stop the instance that is running or start a new
-instance on another port such as in ``mojito start 8667``.
+instance on another port such as in ``$ export PORT=8667; node app.js``. Your
+``app.js`` has to have a line of code to set the port or use the environment variable ``PORT``.
------------
View
59 docs/dev_guide/topics/mojito_hosting_container_reqs.rst
@@ -9,6 +9,63 @@ your applications, so that they may be launched in hosting environments. We
will look at what startup files are required for each version and provide
code examples.
+.. _startup_reqs-v0.9:
+
+Mojito v0.9 and Later
+=======================
+
+Version 0.9 removes the ``server.js`` and requires the addition of ``app.js`` to
+boot applications. The ``app.js`` is structured much like the ``app.js`` of Express
+applications with Mojito included to dispatch mojits, attach routing and application configurations,
+and providing middleware.
+
+Although your ``app.js`` can have many forms, from using Express-like syntax for defining
+routing paths, adding middleware, etc., to using Mojito to do those same things, the
+example ``app.js`` below can be the starting point or template for your applications.
+
+.. _startup_reqs-v0.9-appjs:
+
+app.js
+------
+
+.. code-block:: javascript
+
+ /*jslint node:true*/
+
+ 'use strict';
+
+ var express = require('express'),
+ libmojito = require('mojito'),
+ app;
+
+ app = express();
+ app.set('port', process.env.PORT || 8666);
+ libmojito.extend(app);
+
+ app.use(libmojito.middleware());
+ app.mojito.attachRoutes();
+
+ app.get('/status', function (req, res) {
+ res.send('200 OK');
+ });
+
+ app.listen(app.get('port'), function () {
+ console.log('Server listening on port ' + app.get('port') + ' ' +
+ 'in ' + app.get('env') + ' mode');
+ });
+ module.exports = app;
+
+
+.. _startup_reqs-v0.9-appjs:
+
+server.js
+---------
+
+**OBSOLETE**
+
+The ``server.js`` file is not created by version 0.9. Remove from any
+applications that are using versions 0.9 or greater.
+
.. _startup_reqs-v0.4.8:
Mojito v0.4.8 and Later
@@ -29,7 +86,7 @@ index.js
**OBSOLETE**
The ``index.js`` file is not created by version 0.4.7. Remove from any
-applicationsthat are using versions 0.4.7 or greater.
+applications that are using versions 0.4.7 or greater.
.. _startup_reqs_v0.4.8-server:
View
22 docs/dev_guide/topics/mojito_npm.rst
@@ -99,19 +99,23 @@ run ``npm install`` from the Mojito application directory.
"email": "nobody@yahoo-inc.com"
}
],
- "dependencies": {
- "mojito": ">= 0.3.0",
- "async": "~0.1",
- "form_mojit" : "1.x"
+ "scripts": {
+ "start": "node app.js"
},
"engines": {
- "node": ">=0.4.5"
+ "node": "> 0.8",
+ "npm": "> 1.0"
},
- "scripts": {
- "start": "mojito start"
+ "dependencies": {
+ "debug": "*",
+ "node-markdown": "*",
+ "mojito": "~0.9.0"
+ },
+ "devDependencies": {
+ "mojito-cli": ">= 0.2.0"
}
- }
-
+ }
+
.. _author_npm_mod_shared_mojito_resource:
View
38 docs/dev_guide/topics/mojito_using_contexts.rst
@@ -44,27 +44,35 @@ for request contexts override those of the base context.
Base Context
------------
-The base context is statically set with the ``--context`` option when you
-start an application.
+The base context is statically set in ``app.js`` by passing a ``context`` object
+to the ``extend`` method that is called from an instance of Mojito. You pass the
+instance of an Express application and the ``context`` object to ``extend`` to
+set the base context.
-.. _context_base-syntax:
+In the example ``app.js`` below, ``libmojito`` is an instance of Mojito, and ``app``
+is an instance of Express. You pass ``app`` to ``libmojito.extend`` as well as
+the ``context`` object that specifies the ``development`` environment.
-Syntax
-######
-
-The base context has the following syntax:
-
-``"key1:value1[,key2:value2]"``
+.. code-block:: javascript
-.. _context_base-ex:
+ var express = require('express'),
+ libmojito = require('mojito'),
+ app = express();
-Example
-#######
+ libmojito.extend(app, {
+ context: {
+ runtime: 'server',
+ environment: 'development'
+ }
+ });
-The following starts the application with the base context
-``environment:production``:
+.. note:: Mojito v0.8.x and Earlier
-``$ mojito start --context "environment:production"``
+ In versions of Mojito before v0.9, you used the Mojito CLI utility to specify
+ the context with the ``--context`` option on the command line. We recommend
+ adapt your applications to Mojito v0.9, which in general only involves creating
+ the file ``app.js``, removing the ``server.js`` file, and using ``node app.js`` to
+ start applications.
.. _context_configs_what-request:
View
2  docs/dev_guide/topics/mojito_yui_config.rst
@@ -144,7 +144,7 @@ Synthetic Modules in Mojito
What Are Synthetic Modules?
###########################
-When you run ``mojito start`` or use an alternative way to boot your application,
+When you run ``node app.js`` or use an alternative way to boot your application,
the Mojito store analyzes the directory structure and dependencies to try to understand the
structure and then make assumptions. From this analysis, the synthetic modules
create application metadata that can be used by YUI Loader to load the application and
Please sign in to comment.
Something went wrong with that request. Please try again.