CDMS recently asked whether is was possible to display a set of plots on a confluence page, such that one plot at a time can be selected and viewed (this is something that is done using custom javascript on their existing documentation pages). There did not seem to be any existing confluence macro or plugin which exactly satisfied their requirements, so I looked into building a custom confluence macro. After a little reading and downloading the Atlassian SDK it turned out to be quite easy to create simple plugins for confluence to add functionality like this. Basically all that was needed was:

  1. A small Java class which extends BaseMacro and has a single execute method which takes the user's options and performs any necessary "business logic" (in this case scanning for images attached to the current page which match the user's selection requirements).
  2. A velocity macro which takes the output of the Java class and renders it as HTML
  3. A simple javascript function which uses jquery to switch the plot images when the user selects a plot
  4. A helpfile (velocity), a plugin descriptor (xml) and a maven pom (xml)

The complete source code can be found here, and the result is shown below:

Unknown macro: {plotset}

Feel free to ask if you are interested in help getting started creating your own custom macros for confluence.