How to write a module

From Friend2Friend Wiki

Jump to: navigation, search

Contents

Specify the XML!

The most important step in creating a module!! The basic datatype of F2F is XML, which is defined by an XML schema. Unless you are very familiar with these, these are most conveniently created in an XML editor, such as XML Spy.

Define the Resources

The most important of these are most likely the services, which might make up the entirity of the module's resources. If you wish to store data, datastores will be needed.

If the module is aimed at the client, it will probably use displays and images, and likely also hooks (e.g. to create icons for the XML data in file manager/desktop).

Make the Module Definition File

This is an XML file, easily created by hand in an XML editor, defining the resources available to the module, and the implementations. A skeleton file can be created automatically from an XML Schema using the make-module service from the dev module, and this can then be completed by adding custom resources, specifying input arguments and output (the equivalent of .H files for C functions).

Implement the resource scripts

Scripted resources (i.e. services, displays & hooks) need XSL transforms. Images and scripts just need to be present, while datastores should be specified if they are not designed to be empty (It is common to either start with some sample data or to put in a single root node, and hang other elements off it). See the modules already coded for a bunch of conventions of pathnames which it might be helpful to follow.

Compile the module

Make a single folder containing the module's schema, definition file and all the files associated with the resources. The last element is the machine generated XML files (schemas) created when the module is compiled. This is currently achieved through the server administrator's GUI.

Finally...

If it's any good, please submit it to the F2F team:-) If you publish it on a publicly accessible F2F server, tell us so we can take a look. We will be recording a list of the first 100 modules published for posterity :-)

Personal tools