nodebb-plugin-cobi-boilerplate
v0.0.8
Published
Boilerplate code to easily set up a new plugin development enviromnent
Downloads
2
Readme
This directory has been slightly altered by Maximilian Nies
to better suit the development processes at COBI-Soft. You just need to clone this repo and swap out all occurrences of "boilerplate" with the name of your plugin.
Setup
Clone this repo into a new directory and replace every occurrence of boilerplate
with the name of your plugin.
Development
You can either develop the plugin directly in your NodeBB environement by moving the files of your plugin directory into its own folder inside of the node_modules
folder of your NodeBB environment or you can develop it in a separate environement in which case you need to publish it and install it in your NodeBB environment. (Of course, any time you update the code, you need to publish and install it again).
Developing your plugin in a separate environment allows you to keep everything in order and later publish it to git (since any node_moduels
files will of course be ignored in your NodeBB environment and not published to git). It also pretty much forces you to inclue the latest version of your plugin in your package.json
.
Publishing a package to npm
In order for you to be able to install your plugin in your NodeBB environment, you need to publish it to npm publically.
To do this, simply run the command npm publish --access public
in your plugin's environment. Note that you need to adapt your package.json
code according to your respective plugin and version. Also make sure to adapt the name of your plugin here to the following format: nodebb-plugin-my-new-plugin
(You cannot publish a package with the same or previous version number)
Installing the plugin
Now that you published your plugin and its access modifier is set to public, you can simply npm install
it. Since NodeBB does the heavy lifting for us, prefixing the plugin with nodebb-plugin
is all we need to do to make NodeBB recognize this package as a plugin. You will need to restart NodeBB after installing (or updating) a plugin with ./nodebb restart
.
Enabling the plugin
By default, your plugin will not be enabled. To enable the plugin, head to the admin panel at http://localhost:4567/admin
. Head to http://localhost:4567/admin/extend/plugins#download
and click the installed
tab. Here, simply find your plugin and click "Activate". Now, rebuild and restart the process and you should be done.
Adding a menu item to the admin dashboard
If you want to add a settings page to the admin dashboard to allow you to configure settings, the necessary files are in ./static/templates/admin/plugins
.
The menu entry is added in ./library.js
using the plugin.addAdminNavigation
method.
From the official NodeBB:
Quickstart Plugin for NodeBB
A starter kit for quickly creating NodeBB plugins. Comes with a pre-setup LESS file, server side JS script with an action:app.load
hook, and a client-side script. Most plugins need at least one of the above, so this ought to save you some time. For a full list of hooks have a look at our wiki page, and for more information about creating plugins please visit our documentation portal.
Fork/Clone this or copy it, and using your favourite text editor find and replace all instances of nodebb-plugin-cobi-boilerplate
with nodebb-plugin-cobi-your-plugins-name
. Change the author's name in the LICENSE and package.json files.
Hello World
Really simple, just edit static/lib/main.js
and paste in console.log('hello world');
, and that's it!
Installation
npm install nodebb-plugin-cobi-boilerplate