Skip to content

Creating your first Etherpad plugin

johnyma22 edited this page Feb 26, 2012 · 16 revisions

Creating your own plugin in Etherpad Lite is really simple. You will need some basic Javascript understanding. This documentation is written for linux users but can be extremely simply transferred over to other operating systems.

Step 1.

cd {DIR_WHERE_ETHERPAD_LITE_IS_INSTALLED/plugins-available}
mkdir ep_my_example
cd ep_my_example
npm init

You can safely accept all the default settings suggested by npm init

Step 2.

Edit your plugin config file package.json

nano package.json
{
  "name": "ep_my_example",  // Your plugin name must begin with ep_  
  "description": "Adds an Apple response on /apples",
  "version": "0.0.1",
  "author": "RedHog (Egil Moeller) <[email protected]>",
  "contributors": ["johnyma22 (John McLear) <[email protected]>"],
  "dependencies": {},
  "engines": { "node": ">= 0.4.1 < 0.7.0" }
}

Step 3.

Edit your plugin config file ep.json

nano ep.json
{
  "parts": [
    {
      "name": "apples",
      "hooks": {
        "expressCreateServer": "ep_my_example/apples:expressCreateServer"
      }
    }
  ]
}

Step 4.

Create your actual plugin Javascript code.

nano apples.js
exports.expressCreateServer = function (hook_name, args, cb) {
  args.app.get('/apples', function(req, res) {
    res.send("<em>Abra cadabra</em>");
  });
}

Step 5.

Install your plugin:

npm install ep_my_example

Step 6.

Start your server and test:

cd ../..
bin/run.sh
lynx http://YOUR_SERVER_IP:YOUR_SERVER_PORT/apples

Step 7.

[Read some more about the plugin framework including how to manage parts.] (https://github.com/Pita/etherpad-lite/wiki/More-Etherpad-plugin-reading)

Clone this wiki locally