Make Plugin Script

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. coffee javascript

See Make a New Plugin for a slightly higher level description of the plugin construction process.

An older version of the script worked with the simple plugins directory we once used. github

We also have an already generated example in github: wiki-plugin-example

Files

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.

The script is a command line tool that take one argument.

./mkplugin.sh CoolThing

This will create a plugin for items of type coolthing. Create a documentation page, About CoolThing Plugin, that includes an example of a coolthing.

-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

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'

Change to the plugin's package directory. 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.

Build the generated code, compiling coffeescript and bundling requirements with browserify. Watch for subsequent versions and build them too.

Publish the new plugin locally using symbolic links. 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

scripts

scripts

Updated `mkplugin` scripts 4 July 2018 to update the developer dependencies in the generated `package.json`.

Updated `mkplugin.js.sh` 28 September 2019 to use named functions for more informative debugging.

# Testing

Install in a local clone of wiki.

npm i $(npm pack ../wiki-client/ | tail -1)