Labs/Bespin/DesignDocs/PluginAPI: Difference between revisions

Jump to navigation Jump to search
 
Line 113: Line 113:


Plugin modules are implemented not as Dojo modules, but rather as [https://wiki.mozilla.org/ServerJS/Modules/SecurableModules ServerJS Securable Modules]. This would allow seamless interop for plugins that have both client and server side JS components.
Plugin modules are implemented not as Dojo modules, but rather as [https://wiki.mozilla.org/ServerJS/Modules/SecurableModules ServerJS Securable Modules]. This would allow seamless interop for plugins that have both client and server side JS components.
Here's an example of a single file plugin that adds commands and adds/removes a DOM element:
    exports.info = {
        name: "Something Fun",
        provides: [
            ["bespin.command", {
                name: "woot",
                pointer: ":woot"
            }],
            ["bespin.command", {
                name: "hello",
                takes: ["name"],
                pointer: ":hello"
            }]
        ]
    }
   
    exports.woot = function(instruction) {
        instruction.addOutput("woot!");
    }
   
    exports.activate = function() {
        dojo.create("div", {
            id: "fun",
            style: "opacity: 0; position: absolute; top: 0; left: 0; padding: 2em; background: white"
        }, document.body);
    }
   
    exports.deactivate = function() {
        dojo.query("#fun").orphan();
    }
   
    exports.hello = function(instruction, name) {
        instruction.addOutput("Hi there, " + name);
    }


=== Plugin installation ===
=== Plugin installation ===
canmove, Confirmed users, Bureaucrats and Sysops emeriti
1,093

edits

Navigation menu