The make plugin script will create files for a new plugin to handle items of a new type. The files include an about page with an example of the new item type ready to be rendered by the new plugin. gist ![]()
See Make a New Plugin for a slightly higher level description of the plugin construction process.
# Setup
A common configuration is to make a FedWiki directory that contains clones of any repos in use during development. Download the gist to this directory.
mkdir ~/FedwikiPlugins cd ~/FedwikiPlugins
Download the gist to this directory. Here we use wget to download the gist to create the mkplugin.sh file, and then change it's permissions to make it executable:
wget http://bit.ly/1T2Paly -O mkplugin.sh chmod +x mkplugin.sh
The script is a command line tool that take one argument.
./mkplugin.sh CoolThing
This will create a plugin for items of type coolthing. To view the files the script creates you can use the following command:
Files
ls -la ~/FedwikiPlugins/wiki-plugin-coolthing
which should result in an output like the following:
-rw-r--r-- 1 ward 44 Dec 13 10:17 .gitignore -rw-r--r-- 1 ward 26 Dec 13 10:17 .npmignore -rw-r--r-- 1 ward 170 Dec 13 10:17 ReadMe.md drwxr-xr-x 5 ward 170 Dec 13 10:17 client -rw-r--r-- 1 ward 86 Dec 13 10:17 factory.json -rw-r--r-- 1 ward 762 Dec 13 10:17 gruntfile.js drwxr-xr-x 9 ward 306 Dec 13 10:17 node_modules -rw-r--r-- 1 ward 807 Dec 13 10:17 package.json drwxr-xr-x 3 ward 102 Dec 13 10:17 pages drwxr-xr-x 5 ward 170 Dec 13 10:17 test
As you can see the script creates a "pages" directory. inside this directory the script has already created created for you a basic documentation page, About CoolThing Plugin, that includes an example of a coolthing.
You can edit the json for this page using your favourite editor or use:
nano -w wiki-plugin-coolthing/pages/about-coolthing-plugin
Substitute coolthing for the name of the plugin you chose above - just look for the file already created for you and edit that.
Commands
The script concludes by suggesting commands that will be used in development.
Package: cd wiki-plugin-coolthing/ Install: npm install Build: grunt build; grunt watch Publish: npm link; (cd ../wiki-node; npm link wiki-plugin-coolthing) Server: (restart once to notice new plugin) Browse: open localhost:3000/about-coolthing-plugin.html Develop: vi client/coolthing.coffee Commit: git init; git commit -a -m 'mkplugin'
Step through each of these commands, starting with change to the plugin's package directory:
cd wiki-plugin-coolthing/
Further commands are entered here.
Install the dependents specified in the package.json file. The long list will print as installation proceeds. Optional packages may fail to build.
npm install
Build the generated code, compiling coffeescript and bundling requirements with browserify. Watch for subsequent versions and build them too.
grunt build; grunt watch
Publish the new plugin locally using npm link. This links your development plugin to a global space on your system which can then be subscribed to by your wiki application using npm link. One command makes the package available, another adds it to the server's plugins.
Start (or restart) the local server. Once the server notices the new plugin it will serve updated versions without further attention.
Start browsing the generated help page which includes an example of the plugin in use. It just displays text on a gray background.
Edit the generated plugin to do more interesting things. Refresh the browser when the build completes. Try the Chrome inspector's option that disables caching.
Commit the generated files and your improvements to a local git repository.
Publication
Revise the contact information in the package.json file
If you make a GitHub repo by the same name then it is easy to publish your code with two git commands that they will suggest. doc ![]()
If you make an npm module by the same name then you can publish your module following their instructions. doc ![]()
If you npm install from your plugin directory rather than using the npm link mechanism you will be copying exactly the files that others will see when they install from npm.
As a published npm module other federated wiki server operators can offer your plugin by adding one like to their packages.json file.
As a published npm module with continued support you are welcome to request your module be included in the package.json included in the wiki-node module. github ![]()