Extension Points

Extension points are places built into Visallo that can define additional behavior. Custom plugins can also define extension points that can be implemented by other plugins.

An extension point is simply a mapping from a string – the namespaced extension point name – to a JavaScript object. What kind of object is defined by the consumer of the extension point.

All registered extension points are viewable in the admin panel, under UI Extensions, and in the table of contents in this document. This document focuses on tutorials for the extension points, for code-level documentation, view the Extension Point Api.

Register an extension point

To register some custom behavior, require the public/v1/api module, and use the registry member.

require(['public/v1/api'], function(visallo) {
    var registry = visallo.registry;
    registry.registerExtension([extension point name], [extension point object])
})

For example, to add an item to the menu bar, use the Menu bar extension point:

visallo.registry.registerExtension('org.visallo.menubar', {
    title: i18n('org.visallo.examples.menubar.title'),
    identifier: 'org-visallo-examples-menubar',
    action: {
        type: 'pane',
        componentPath: 'org/visallo/examples/menubar/Pane'
    },
    welcomeTemplatePath: 'hbs!org/visallo/examples/menubar/welcome',
    icon: '../img/glyphicons/white/glyphicons_066_tags@2x.png',
    options: {
        placementHint: 'top',
        placementHintAfter: 'search',
    }
});

Visallo plugins can also define their own extension points. They do not need to be defined ahead of time, simply ask the registry for all registered extensions using a unique point name. registry.extensionsForPoint

registry.extensionsForPoint([extension point name]);
// Returns array of registered objects

It is good practice to define some documentation for your new extension point. Documenting provides a validation function, and a description shown in the admin panel under UI Extensions. Document the extension point prior to requesting extensionsForPoint. registry.documentExtensionPoint

registry.documentExtensionPoint('org.visallo.menubar',
    'Add items to menubar',
    function(e) {
        return ('title' in e) &&
            ('identifier' in e) &&
            ('action' in e) &&
            ('icon' in e);
    },
    'http://docs.visallo.org/extension-points/front-end/menubar'
);

If you call documentExtensionPoint before extensionsForPoint all the extensions returned are guaranteed to have passed validation.

Invalid extensions are logged as warnings in the JavaScript console.

This documentation appears in the admin pane under UI Extensions. Add an external documentation URL using an optional 4th parameter.

registry.documentExtensionPoint('com.example.point',
    'Description...',
    function () { return true; },
    'http://example.com/docs'
);

results matching ""

    No results matching ""