Permalink
Browse files

fixes #562 - added missing code for controller.server.js (copied from…

… examples/developer-guide/model_yql/mojits/flickr/controller.server.js)~examples ~documentation
  • Loading branch information...
1 parent 8457913 commit 3c03345b94f8c5d7e3df366c222939f650484a22 Dmitry Savintsev committed Sep 25, 2012
Showing with 37 additions and 0 deletions.
  1. +37 −0 docs/dev_guide/code_exs/calling_yql.rst
@@ -309,6 +309,43 @@ To set up and run ``model_yql``:
#. Modify the mojit controller to get data from the model by replacing the code in ``controller.server.js`` with the following:
+ .. code-block:: javascript
+
+ YUI.add('flickr', function(Y, NAME) {
+
+ Y.namespace('mojito.controllers')[NAME] = {
+ init: function(config) {
+ this.config = config;
+ },
+ index: function(ac) {
+ // Use aliases to params addon
+ // if they exist.
+ var count, model, page, q, start;
+ if (ac.params.hasOwnProperty('url')) {
+ q = ac.params.url('q') || 'muppet';
+ page = (ac.params.url('page') || 0) / 1;
+ count = (ac.params.url('size') || 20) / 1;
+ } else {
+ q = ac.params.getFromUrl('q') || 'muppet';
+ page = (ac.params.getFromUrl('page') || 0) / 1;
+ count = (ac.params.getFromUrl('count') || 20) / 1;
+ }
+ start = page * count;
+ model = ac.models.flickr;
+ model.search(q, start, count, function(photos) {
+ ac.done(
+ {
+ photos: photos,
+ page: page,
+ count: count,
+ start: start
+ }
+ );
+ });
+ }
+ };
+ }, '0.0.1', {requires: []});
+
#. Create the file ``assets/index.css`` for the application's CSS with the following:
.. code-block:: css

0 comments on commit 3c03345

Please sign in to comment.