Writing plugins for a PYBOSSA server

PYBOSSA has a plugin system that allows you to write your own custom features and add them to a running PYBOSSA server without the need of touching the server code. For instance, you could create a new endpoint for an admin dashboard (with new views, templates, etc.) or build a new scheduler like in this example.

The PYBOSSA plugin system is powered by Flask-plugins

To create a plugin, you will have to make a folder with the name of your plugin and add it to the plugins folder in your PYBOSSA server. If you have the PYBOSSA code in a directory called pybossa, then the plugins folder will be pybossa/pybossa/plugins.

The least you need to include in that folder is the following:

1
2
3
your_plugin_folder
|-- info.json
|-- __init__.py

flask.ext.plugins.Plugin. On the other hand, info.json needs to follow the schema:

1
2
3
4
5
6
7
8
{
    "identifier": "identifier",
    "name": "PluginClass",
    "author": "[email protected]",
    "license": "AGPLv3",
    "description": "whatever",
    "version": "0.0.1"
}

You could also create a more sofisticated plugin, including your own templates, models, forms… everything you need:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
your_plugin_folder
|-- info.json                Contains the Plugin's metadata
|-- license.txt              The full license text of your plugin
|-- __init__.py              The plugin's main class is located here
|-- views.py
|-- models.py
|-- forms.py
|-- static
|   |-- style.css
|-- templates
    |-- myplugin.html

For more information and examples, please refer to the Flask-plugins documentation.