Skip to content

Workflow of Hilary #36

@penghou620

Description

@penghou620

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions