Skip to content
ejfox edited this page Mar 11, 2013 · 10 revisions

The tributary plugin system allows you to customize the tributary environment to enable new functionality. Tributary's core functionality is being rewritten as plugins to make it easier to improve.

A current restriction is that plugins need to be served from a CORS enabled host.

Using a plugin

You can load a plugin by giving tributary a url to your plugin.json file:

var tb = Tributary();  
tb.loadPlugin(
  "/static/plugins/play/plugin.json",  
  options,  //Object: options to pass to the plugin if any  
  function(err) { 
    //error callback 
  });  

Official plugins

  • Play
    This provides a run loop, including some special features for playing with time.
  • Simple
    This is a demonstration plugin which is easy to start with. It only adds some text to the screen and changes on variable on the tributary object

Developing a plugin

Plugins are currently expected to provide the following files:

  • plugin.json
  • index.js
  • index.html
  • style.css

The index.html and style.css may be empty.
index.js must be of the form:

Tributary.plugin("myPluginId", myPluginFunction);

function myPluginFunction(tributary, plugin) {
  plugin.activate = function() {}; //initialize, add things to the page
  plugin.deactivate = function() {}; //remove things from the tributary object or page as needed
  //you have access to plugin.options which includes
  //plugins.options.elId (a unique id for a div created for the plugin)
  return plugin;
}

Your plugin.json is a manifest like:

{
  "id": "play"
, "description": "time controls, play with time!"
, "url": "/static/plugins/play"
, "js": "index.js"
, "html": "index.html"
, "css": "style.css"
}

The js, html, and css objects are optional, so you can create a plugin that is just js or just css and html, depending on what you want your plugin to do.

The plugin architecture code can be found:
here

Default plugins are loaded by tributary: here

Clone this wiki locally