Skip to content
nrabinowitz edited this page May 7, 2012 · 2 revisions

Modules will extend the base Module class. Everything in the interface except name is optional, and will be filled with reasonable defaults.

Module interface

  • name:String - Display name for module

  • type:String - Default type for module resources (see types.js for possible types)

  • dataType:String - $.ajax dataType option, to help with parsing and content negotiation (default: json)

  • toDataUri(uri):Function - Translate HTML URI to a data URI for a particular resource (default: same)

  • noFetch:Boolean: - If set, no remote resources will be fetched for this module (default: false)

  • corsEnabled:Boolean: - Whether the service is CORS-enabled. If not set, a YQL-based proxy will be used for non-JSONP resources.

  • parseData(data):Function - Translate resource data to a clean data object (default: same)

  • getType(data):Function - Get the type of a resource based on resource data (default: no-op)

  • detailView(resource):Function - Make HTML for the detail view (shown in popup) of a given resource (default: ui.detailView)

  • initialize: Function - Additional module initialization (default: no-op)

Development process for new modules

  • Fork the project.

  • Add a new folder for your module(s) to src/modules. The folder provides the namespace for your modules.

  • Create your modules. Modules should follow the Require.js Asynchronous Module Definition (AMD) API, i.e. a function, wrapped in a define() call, with optional dependencies. Dependencies might include one or more library dependencies; in particular, jQuery and Mustache will already be loaded and can be accessed with "jquery" and "mustache", respectively.

  • Your module should return an object that will extend the base Module class. At minimum, it should have a name property. A basic module shell might look like this:

      define(function() {
          return {
              name: 'My Module',
              type: 'place',
              toDataUri: function(uri) {
                  // TODO: Return a mapped data URI
              }
              parseData: function() {
                  // TODO: Return parsed data
              }
          }
      });
    
  • Add your module to the module registry at src/registry.js.

  • Add any 3rd-party library dependencies to src/lib, so that other modules can use them as well.

  • Submit a pull request, and we'll check it out!

Clone this wiki locally