Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow of Hilary #36

Open
penghou620 opened this issue Mar 7, 2013 · 0 comments
Open

Workflow of Hilary #36

penghou620 opened this issue Mar 7, 2013 · 0 comments
Labels

Comments

@penghou620
Copy link

The way it generally works in OAE is you request something like
/docs/index.html which has a script tag that pulls in requirejs with a
list of scripts to load. For that file it looks like:

  <script data-main="/shared/oae/api/oae.bootstrap.js"
  src="/shared/vendor/js/require-jquery.js"></script>
  <script>require(["/docs/js/doc.js"]);</script>

The /docs/js/doc.js then makes ajax requests to the Hilary apis to get
back json data. In this case, that looks like:

  $.ajax({
    url: '/api/doc/module/' + module,
    success: function(docs) {
    callback(docs);
  }, error:
  function(err) {
    callback(null);
  }
 });

It then renders that json into the page like this:

  oae.api.util.renderTemplate($('#doc_docs_template'), {
    'docs': docs,
    'module': module
  }, $('#doc_docs_container'));

The thing to notice there is that the template was in the html, it's just
commented out inside a div, and the rendered output gets written to a
different div on the page.

So the markup and client side js are just served from static files in the
3akai-ux package. For the Hilary apis we register the paths under the
/api directory. For the /api/doc/module that we used in this example it's
in Hilary node_modules/oae-doc/lib/rest.js and looks like this:

  var OAE = require('oae-util/lib/oae');
  ...
  OAE.tenantServer.get('/api/doc/module/:moduleId', function(req, res) {

That tells the server that it should answer http GET requests that start
with "/api/doc/module" with this function and to treat the next path
element as a variable called "moduleId". Inside that function we call to
the oae-doc/lib/api.js to perform the logic, which if it used the
database would make calls to something like oae-doc/lib/dao.js which
would contain the CQL calls for cassandra.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant