Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Updated documentation for examples, removed one example, its document…
Browse files Browse the repository at this point in the history
…ation and test, updated binding example to not use the Url addon.
  • Loading branch information
Joe Catera committed Mar 14, 2014
1 parent d9ad545 commit 6adc40e
Show file tree
Hide file tree
Showing 45 changed files with 266 additions and 1,239 deletions.
5 changes: 2 additions & 3 deletions docs/dev_guide/code_exs/adding_assets.rst
Expand Up @@ -37,8 +37,7 @@ The global assets are located in the ``{app_dir}/assets`` directory as shown her
|-- index.js
|-- mojits/
|-- package.json
|-- routes.json
|-- server.js
|-- routes.json (deprecated)

In the ``simple`` mojit below, you see the local ``assets`` directory for CSS files only
available to the ``simple`` mojit:
Expand Down Expand Up @@ -156,7 +155,7 @@ To create and run ``simple_assets``:
}
]
#. Update your ``app.js`` with the following to use Mojito's middleware, configure routing and port, and
#. Update your ``app.js`` with the following to use Mojito's middleware, configure routing and the port, and
have your application listen for requests:

.. code-block:: javascript
Expand Down
15 changes: 0 additions & 15 deletions docs/dev_guide/code_exs/app_config.rst
Expand Up @@ -86,21 +86,6 @@ To set up and run ``simple_config``:
}
]
#. To configure routing, replace the code in ``routes.json`` with the following:

.. code-block:: javascript
[
{
"settings": [ "master" ],
"simple": {
"verbs": ["get"],
"path": "/",
"call": "simple.index"
}
}
]
#. Update your ``app.js`` with the following to use Mojito's middleware, configure routing and the port, and
have your application listen for requests:

Expand Down
71 changes: 7 additions & 64 deletions docs/dev_guide/code_exs/binding_events.rst
Expand Up @@ -454,47 +454,12 @@ The root path is configured in ``app.js`` with the following:
libmojito.extend(app);
app.use(libmojito.middleware());
// To use the routing configured in `routes.json`, which
// is deprecated.
// The controller uses the Url addon, which requires the
// `routes.json` file.
app.mojito.attachRoutes();
app.get('/status', function (req, res) {
res.send('200 OK');
});
app.get('/', libmojito.dispatch('frame.index'));
You may have noticed though that the ``app.js`` attaches the routing
from ``routes.json``, which has been deprecated. This is because
another routing page relies on the ``Url`` addon that requires the
use of ``routes.json``.
Thus, the ``routes.json`` file below configures the route path for HTTP GET
calls made on the path ``/?page=:page``. The ``page`` parameter is used for paging
and is assigned the parameterized variable ``:page``,
which is assigned a value by the controller that we're
going to look shortly.
.. code-block:: javascript
[
{
"settings": ["master"],
"root": {
"verbs": ["get"],
"path": "/",
"call": "frame.index"
},
"perpage": {
"verbs": ["get"],
"path": "/?page=:page",
"call": "frame.index"
}
}
]
The controller for ``Pager`` performs several functions:
- uses the ``Params`` addon to get the ``page`` parameter from the query string
Expand Down Expand Up @@ -571,19 +536,19 @@ you need to require the model in the ``requires`` array of the controller.
}, '0.0.1', {requires: [
'mojito',
'mojito-models-addon',
'mojito-url-addon',
'mojito-params-addon',
'pager-model',
'dump'
]});
The URLs for the **prev** and **next** links are created by passing the mojit instance,
the method, and the query string parameters to the ``make`` method from the ``Url`` addon.
the method, and the query string parameters.

The code snippet below creates the query string parameters with the
`YUI QueryString module <http://yuilibrary.com/yui/docs/api/modules/querystring.html>`_.
If the query string created by ``Y.QueryString.stringify`` is "page=2" ,
``actionContext.url.make`` would return the URL ``{domain_name}:8666/?page=2``.
the ``createLink`` method would return the URL ``{domain_name}:8666/?page=2``.

.. code-block:: javascript
Expand All @@ -593,7 +558,7 @@ If the query string created by ``Y.QueryString.stringify`` is "page=2" ,
for (var k in params) {
mergedParams[k] = params[k];
}
return actionContext.url.make('frame', 'index', Y.QueryString.stringify(mergedParams));
return "/?" + Y.QueryString.stringify(mergedParams));
}
...
Expand Down Expand Up @@ -661,7 +626,6 @@ create URLs for the **next** and **prev** links.
}, '0.0.1', {requires: [
'mojito',
'mojito-models-addon',
'mojito-url-addon',
'mojito-params-addon',
'pager-model',
'dump'
Expand Down Expand Up @@ -703,27 +667,6 @@ To set up and run ``binding_events``:
}
]
#. To configure routing to call the ``index`` action from the instance of the
``HTMLFrameMojit``, replace the code in ``routes.json`` with the following:
.. code-block:: javascript
[
{
"settings": ["master"],
"root": {
"verbs": ["get"],
"path": "/",
"call": "frame.index"
},
"perpage": {
"verbs": ["get"],
"path": "/?page=:page",
"call": "frame.index"
}
}
]
#. Confirm that your ``app.js`` has the following content:

.. code-block:: javascript
Expand All @@ -740,17 +683,18 @@ To set up and run ``binding_events``:
libmojito.extend(app);
app.use(libmojito.middleware());
app.mojito.attachRoutes();
app.get('/status', function (req, res) {
res.send('200 OK');
});
app.get('/', libmojito.dispatch('frame.index'));
app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
});
module.exports = app;
#. Also, confirm that your ``package.json`` has the correct dependencies as show below. If not,
update ``package.json``.

Expand Down Expand Up @@ -822,12 +766,11 @@ To set up and run ``binding_events``:
for (var k in params) {
mergedParams[k] = params[k];
}
return actionContext.url.make('frame', 'index', Y.QueryString.stringify(mergedParams));
return "/?" + Y.QueryString.stringify(mergedParams);
}
}, '0.0.1', {requires: [
'mojito',
'mojito-models-addon',
'mojito-url-addon',
'mojito-params-addon',
'pager-model',
'dump'
Expand Down
56 changes: 23 additions & 33 deletions docs/dev_guide/code_exs/calling_yql.rst
Expand Up @@ -258,48 +258,38 @@ 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:

.. code-block:: javascript
[
{
"settings": [ "master" ],
"_index": {
"verbs": ["get"],
"path": "/",
"call": "frame.index"
}
}
]
#. Update your ``app.js`` with the following:
#. Update your ``app.js`` with the following to use Mojito's middleware, configure routing and the port, and
have your application listen for requests:

.. code-block:: javascript
'use strict';
var debug = require('debug')('app'),
express = require('express'),
libmojito = require('mojito'),
customContextualizerMiddleware = require('./middleware/mojito-contextualizer.js'),
app;
app = express();
app.set('port', process.env.PORT || 8666);
libmojito.extend(app);
app.use(customContextualizerMiddleware());
app.use(libmojito.middleware());
app.get('/status', function (req, res) {
res.send('200 OK');
});
app.get('/', libmojito.dispatch('frame.index'));
app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
});
module.exports = 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 () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
});
module.exports = app;
#. Confirm that your ``package.json`` has the correct dependencies as show below. If not,
update ``package.json``.

Expand Down
1 change: 0 additions & 1 deletion docs/dev_guide/code_exs/config.rst
Expand Up @@ -11,7 +11,6 @@ instances, routing paths, logging levels, and more.

app_config
route_config
generating_urls
simple_logging
using_configs

56 changes: 20 additions & 36 deletions docs/dev_guide/code_exs/cookies.rst
Expand Up @@ -124,27 +124,8 @@ To set up and run ``using_cookies``:
}
]
#. To configure routing, replace the code in ``routes.json`` with the following:

.. code-block:: javascript
[
{
"settings": ["master"],
"root": {
"verbs": ["get"],
"path": "/",
"call": "frame.index"
},
"example1": {
"verbs": ["get"],
"path": "/example1",
"call": "frame.example1"
}
}
]
#. Update your ``app.js`` with the following:
#. Update your ``app.js`` with the following to use Mojito's middleware, configure routing and the port, and
have your application listen for requests:

.. code-block:: javascript
Expand All @@ -155,22 +136,25 @@ To set up and run ``using_cookies``:
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 = express();
app.set('port', process.env.PORT || 8666);
libmojito.extend(app);
app.use(libmojito.middleware());
app.get('/status', function (req, res) {
res.send('200 OK');
});
app.get('/', libmojito.dispatch('frame.index'));
app.get('/example1', libmojito.dispatch('frame.example1'));
app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
});
module.exports = app;
app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
});
module.exports = app;
#. Confirm that your ``package.json`` has the correct dependencies as show below. If not,
update ``package.json``.

Expand Down
20 changes: 3 additions & 17 deletions docs/dev_guide/code_exs/dynamic_assets.rst
Expand Up @@ -216,22 +216,8 @@ To create and run ``device_assets``:
}
]
#. To configure routing, replace the code in ``routes.json`` with the following:

.. code-block:: javascript
[
{
"settings": [ "master" ],
"_framed_view": {
"verbs": ["get"],
"path": "/",
"call": "frame.index"
}
}
]
. Update your ``app.js`` with the following:
#. Update your ``app.js`` with the following to use Mojito's middleware, configure routing and the port, and
have your application listen for requests:

.. code-block:: javascript
Expand All @@ -247,11 +233,11 @@ To create and run ``device_assets``:
libmojito.extend(app);
app.use(libmojito.middleware());
app.mojito.attachRoutes();
app.get('/status', function (req, res) {
res.send('200 OK');
});
app.get('/', libmojito.dispatch('frame.index'));
app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
Expand Down

0 comments on commit 6adc40e

Please sign in to comment.