Skip to content

Commit

Permalink
Merge pull request YahooArchive#1363 from zhouyaoji/code_exs-routing_…
Browse files Browse the repository at this point in the history
…update

[code_exs] Updated the routing for the examples to use app.js, not routes.json.
  • Loading branch information
Joe Catera committed Mar 14, 2014
2 parents 037b096 + acf6433 commit f42c9d5
Show file tree
Hide file tree
Showing 45 changed files with 238 additions and 124 deletions.
10 changes: 5 additions & 5 deletions docs/dev_guide/code_exs/route_config.rst
Expand Up @@ -65,7 +65,7 @@ action is called from the ``custom-route`` instance.
// Defining route `/custom-route` and executing (dispatching)
// the action `index` of the mojit instance `mapped_mojit`.
app.get('/custom-route', libmojito.dispath('mapped_mojit.index'));
app.get('/custom-route', libmojito.dispatch('mapped_mojit.index'));
app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
Expand Down Expand Up @@ -104,7 +104,7 @@ for handling HTTP POST requests and calls the method ``post_params`` from the
// Defining the route `/*` and executing (dispatching)
// the action `post_params` of the mojit instance `post-route`.
app.post('/*', libmojito.dispath('post-route.post_params'));
app.post('/*', libmojito.dispatch('post-route.post_params'));
app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
Expand Down Expand Up @@ -169,15 +169,15 @@ To set up and run ``configure_routing``:
// Defining route `GET /` and executing (dispatching)
// the action `index` of the mojit instance `mapped_mojit`.
app.get('/', libmojito.dispath('mapped_mojit.index'));
app.get('/', libmojito.dispatch('mapped_mojit.index'));
// Defining route `GET /index` and executing (dispatching)
// the action `index` of the mojit instance `mapped_mojit`.
app.get('/index', libmojito.dispath('mapped_mojit.index'));
app.get('/index', libmojito.dispatch('mapped_mojit.index'));
// Defining the route `POST /*` and executing (dispatching)
// the action `post_params` of the mojit instance `post-route`.
app.post('/show', libmojito.dispath('mapped_mojit.show'));
app.post('/show', libmojito.dispatch('mapped_mojit.show'));
app.get('/status', function (req, res) {
res.send('200 OK');
Expand Down
7 changes: 6 additions & 1 deletion examples/developer-guide/adding_view_engines/app.js
Expand Up @@ -19,12 +19,17 @@ app.set('port', process.env.PORT || 8666);
libmojito.extend(app);

app.use(libmojito.middleware());
app.mojito.attachRoutes();
// To use the routing configured in `routes.json`, which
// is deprecated, you uncomment this line.
//app.mojito.attachRoutes();

app.get('/status', function (req, res) {
res.send('200 OK');
});

app.get('/', libmojito.dispatch('myMojit.default_ve'));
app.get('/ejs', libmojito.dispatch('myMojit.added_ve'));

app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
Expand Down
7 changes: 7 additions & 0 deletions examples/developer-guide/binding_events/app.js
Expand Up @@ -21,12 +21,19 @@ libmojito.extend(app);

app.use(customContextualizerMiddleware());
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'));

app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
Expand Down
17 changes: 16 additions & 1 deletion examples/developer-guide/configure_routing/app.js
Expand Up @@ -19,12 +19,27 @@ app.set('port', process.env.PORT || 8666);
libmojito.extend(app);

app.use(libmojito.middleware());
app.mojito.attachRoutes();

// To use the routing configured in `routes.json`, which
// is deprecated, you uncomment this line.
// app.mojito.attachRoutes();

app.get('/status', function (req, res) {
res.send('200 OK');
});

// Defining route `GET /` and executing (dispatching)
// the action `index` of the mojit instance `mapped_mojit`.
app.get('/', libmojito.dispatch('mapped_mojit.index'));

// Defining route `GET /index` and executing (dispatching)
// the action `index` of the mojit instance `mapped_mojit`.
app.get('/index', libmojito.dispatch('mapped_mojit.index'));

// Defining the route `POST /*` and executing (dispatching)
// the action `post_params` of the mojit instance `post-route`.
app.post('/show', libmojito.dispatch('mapped_mojit.show'));

app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
Expand Down
10 changes: 9 additions & 1 deletion examples/developer-guide/dashboard/02_mojits/app.js
Expand Up @@ -19,12 +19,20 @@ app.set('port', process.env.PORT || 8666);
libmojito.extend(app);

app.use(libmojito.middleware());
app.mojito.attachRoutes();

// To use the routing configured in `routes.json`, which
// is deprecated, you uncomment this line.
// app.mojito.attachRoutes();

app.get('/status', function (req, res) {
res.send('200 OK');
});

app.get('/', libmojito.dispatch('github.index'));
app.get('/header', libmojito.dispatch('header.index'));
app.get('/body', libmojito.dispatch('body.index'));
app.get('/footer', libmojito.dispatch('footer.index'));

app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
Expand Down
7 changes: 6 additions & 1 deletion examples/developer-guide/dashboard/03_frame_mojits/app.js
Expand Up @@ -19,12 +19,17 @@ app.set('port', process.env.PORT || 8666);
libmojito.extend(app);

app.use(libmojito.middleware());
app.mojito.attachRoutes();

// To use the routing configured in `routes.json`, which
// is deprecated, you uncomment this line.
// app.mojito.attachRoutes();

app.get('/status', function (req, res) {
res.send('200 OK');
});

app.get('/', libmojito.dispatch('tribframe.index'));

app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
Expand Down
Expand Up @@ -19,12 +19,17 @@ app.set('port', process.env.PORT || 8666);
libmojito.extend(app);

app.use(libmojito.middleware());
app.mojito.attachRoutes();
// To use the routing configured in `routes.json`, which
// is deprecated, you uncomment this line.
// app.mojito.attachRoutes();

app.get('/status', function (req, res) {
res.send('200 OK');
});

app.get('/', libmojito.dispatch('tribframe.index'));


app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
Expand Down
15 changes: 0 additions & 15 deletions examples/developer-guide/dashboard/04_composite_mojits/routes.json
Expand Up @@ -4,20 +4,5 @@
"verbs": ["get"],
"path": "/",
"call": "tribframe.index"
},
"header": {
"verbs":["get"],
"path": "/header",
"call": "header.index"
},
"body": {
"verbs": ["get"],
"path": "/body",
"call": "body.index"
},
"footer": {
"verbs": ["get"],
"path": "/footer",
"call": "footer.index"
}
}]
7 changes: 6 additions & 1 deletion examples/developer-guide/dashboard/05_getting_data/app.js
Expand Up @@ -19,12 +19,17 @@ app.set('port', process.env.PORT || 8666);
libmojito.extend(app);

app.use(libmojito.middleware());
app.mojito.attachRoutes();

// To use the routing configured in `routes.json`, which
// is deprecated, you uncomment this line.
// app.mojito.attachRoutes();

app.get('/status', function (req, res) {
res.send('200 OK');
});

app.get('/', libmojito.dispatch('tribframe.index'));

app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
Expand Down
17 changes: 0 additions & 17 deletions examples/developer-guide/dashboard/05_getting_data/routes.json
Expand Up @@ -4,22 +4,5 @@
"verbs": ["get"],
"path": "/",
"call": "tribframe.index"
},
"header": {
"verbs":["get"],
"path": "/header",
"call": "header.index"
},
"body": {
"verbs": ["get"],
"path": "/body",
"call": "body.index"
},
"footer": {
"verbs": ["get"],
"path": "/footer",
"call": "footer.index"
}


}]
7 changes: 6 additions & 1 deletion examples/developer-guide/dashboard/06_testing/app.js
Expand Up @@ -19,12 +19,17 @@ app.set('port', process.env.PORT || 8666);
libmojito.extend(app);

app.use(libmojito.middleware());
app.mojito.attachRoutes();

// To use the routing configured in `routes.json`, which
// is deprecated, you uncomment this line.
// app.mojito.attachRoutes();

app.get('/status', function (req, res) {
res.send('200 OK');
});

app.get('/', libmojito.dispatch('tribframe.index'));

app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
Expand Down
17 changes: 0 additions & 17 deletions examples/developer-guide/dashboard/06_testing/routes.json
Expand Up @@ -4,22 +4,5 @@
"verbs": ["get"],
"path": "/",
"call": "tribframe.index"
},
"header": {
"verbs":["get"],
"path": "/header",
"call": "header.index"
},
"body": {
"verbs": ["get"],
"path": "/body",
"call": "body.index"
},
"footer": {
"verbs": ["get"],
"path": "/footer",
"call": "footer.index"
}


}]
7 changes: 6 additions & 1 deletion examples/developer-guide/dashboard/07_binders/app.js
Expand Up @@ -19,12 +19,17 @@ app.set('port', process.env.PORT || 8666);
libmojito.extend(app);

app.use(libmojito.middleware());
app.mojito.attachRoutes();

// To use the routing configured in `routes.json`, which
// is deprecated, you uncomment this line.
// app.mojito.attachRoutes();

app.get('/status', function (req, res) {
res.send('200 OK');
});

app.get('/', libmojito.dispatch('tribframe.index'));

app.listen(app.get('port'), function () {
debug('Server listening on port ' + app.get('port') + ' ' +
'in ' + app.get('env') + ' mode');
Expand Down
Expand Up @@ -25,7 +25,7 @@ YUI.add('blog', function (Y, NAME) {
var view_type = "yui", feedURL = "http://www.yuiblog.com/blog/feed/", title = "YUI Blog Posts";


ac.models.get('model').getData({}, feedURL, function (data) {
ac.models.get('blog').getData({}, feedURL, function (data) {
// add mojit specific css
ac.assets.addCss('./index.css');

Expand Down
17 changes: 0 additions & 17 deletions examples/developer-guide/dashboard/07_binders/routes.json
Expand Up @@ -4,22 +4,5 @@
"verbs": ["get"],
"path": "/",
"call": "tribframe.index"
},
"header": {
"verbs":["get"],
"path": "/header",
"call": "header.index"
},
"body": {
"verbs": ["get"],
"path": "/body",
"call": "body.index"
},
"footer": {
"verbs": ["get"],
"path": "/footer",
"call": "footer.index"
}


}]
3 changes: 3 additions & 0 deletions examples/developer-guide/dashboard/08_adv_config/app.js
Expand Up @@ -19,6 +19,9 @@ app.set('port', process.env.PORT || 8666);
libmojito.extend(app);

app.use(libmojito.middleware());
// To use the routing configured in `routes.json`, which
// is deprecated, you uncomment this line.
// app.mojito.attachRoutes();

app.get('/', function (req, res, next) {
req.params.view_type = "yui";
Expand Down
3 changes: 3 additions & 0 deletions examples/developer-guide/dashboard/09_hb_templates/app.js
Expand Up @@ -19,6 +19,9 @@ app.set('port', process.env.PORT || 8666);
libmojito.extend(app);

app.use(libmojito.middleware());
// To use the routing configured in `routes.json`, which
// is deprecated, you uncomment this line.
// app.mojito.attachRoutes();

app.get('/', function (req, res, next) {
req.params.view_type = "yui";
Expand Down
4 changes: 4 additions & 0 deletions examples/developer-guide/dashboard/10_localization/app.js
Expand Up @@ -18,6 +18,10 @@ app = express();
app.set('port', process.env.PORT || 8666);
libmojito.extend(app);

// To use the routing configured in `routes.json`, which
// is deprecated, you uncomment this line.
// app.mojito.attachRoutes();

app.use(libmojito.middleware());

app.get('/', function (req, res, next) {
Expand Down
Expand Up @@ -9,7 +9,7 @@

YUI.add("lang/PageLayout_en-US", function (Y) {
Y.Intl.add(
"PageLayout", // associated module
"pagelayout", // associated module
"en-US", // BCP 47 language tag
// key-value pairs for this module and language
{
Expand Down
Expand Up @@ -8,7 +8,7 @@

YUI.add("lang/PageLayout_es-419", function (Y) {
Y.Intl.add(
"PageLayout", // associated module
"pagelayout", // associated module
"es-419", // BCP 47 language tag
// key-value pairs for this module and language
{
Expand Down
Expand Up @@ -8,7 +8,7 @@

YUI.add("lang/PageLayout_zh-Hans", function (Y) {
Y.Intl.add(
"PageLayout", // associated module
"pagelayout", // associated module
"zh-Hans", // BCP 47 language tag
// key-value pairs for this module and language
{
Expand Down

0 comments on commit f42c9d5

Please sign in to comment.