Wefis Plugins
How to extend wefis' functionality
Wefis supports a minimal 'plugins' system which allows users to extend the functionality of wefis...
Introduction to this text
There are four types of plugin which wefis supports: previews, editing, custom icons, and multimode tools... This document will explain how each one is called, with what parameters, and what the expected output should be...
All plugins should be placed in the /plugins/ directory in the wefis root, which may not exist if you do not have any plugins...
All plugins have to be enabled by individual users in order to be accessible!
Preview Plugin
Wefis allows the creation of custom previews for a specific extension. The name of the script should be [ext].ext where [ext] is the extension of the file after the last dot (.). This should be a perl script, correctly formatted, etc... It should include the special first line (#!/usr/bin/perl) like any normal perl script... The name of the file for which the preview is to be generated is contained in a variable called $plugin_file. The script should then print out the file preview as normal text, keeping the minimal width of the preview pane in mind... If the script is sucessfull, it should return 1, or 0 on failure. A failure results in a GUI error message, containing all text printed out until that point.
Edit Plugin
This is very similar to the plugin type above. It should be called [ext].edit, and be a valid perl script returning 0 on error, with an error message printed out before, or 0 on error. The variable $plugin_file contains the filename to edit.
The plugin is responsable for the entire saving process, and should add all necessary buttons. It can use some javascript functions, as documented below in a later version of this document... It shoudld also, in principle, provide a 'fullscreen' view editing, in which case the script can call the javascript function browseTo(); to return the user to the previous file-view. However, to prevent any dead-ends, the GUI adds a 'cancel' button which will return the user to the main view without saving any data.
Custom icons
Okay, not technically a plugin... If the an image of type [ext].png is given in /img/, then that image will be used as an icon for the .ext filetype.
Multimode plugin
This plugin should be called [anything].multi and be placed in the /plugins/ folder.
This plugin is loaded in two steps: init, and action, as determined by the perl variable $plugin_action..:
a) $plugin_action == "init": The plugin should init, and set the following variables: $plugin_name , the name you wish users to see your plugin as in the menu, and $plugin_descr the value your script will receive later...
b) $plugin_action == "run": The plugin should only run if $plugin_descr matches the one specified upon init!! If the plugin can run, the following variables are set: $plugin_file (name of the file to process), and $plugin_param (extra parameter specified by the user, treat with care!!). The plugin should return true, even if it does not run or do anything, otherwise a failure notice will be reported...
This script is run recursively on a file-per-file basis, so please do not print out an exessive amount of text!!!
If you produce a plugin which you believe will be useful to other users, they can be hosted along with wefis on the sourceforge site if you should so wish!
If you find bugs, or would like to donate to this project, please go to our project page: Project Page.
We would like to thank sourceforge.net for their support:
Close