This macro makes it easy to convert comma-separated lists into tables. Here's the syntax:
{csvtable} column 1 head,column 2 head col 1 value, col 2 value col 1 value, col 2 value {csvtable}
Column heads and values would be applied in a table, like so:
column 1 head | column 2 head |
---|---|
col 1 value | col 2 value |
col 1 value | col 2 value |
Technologies
The simple example code here illustrates how you can use a plugin to format text in Clearspace content.
What's Included
build.xml -- Ant build file.
plugin.xml -- Plugin descriptor required by Clearspace.
src/com.jivesoftware.clearspace.plugins.csv.CSVMacro.java -- Macro class that gets the text between the tags and generates HTML needed to display it in a table.
Building and Deploying the Code
The Ant build.xml file at the root of the plugin includes a build.plugins target you can use to compile the code and package it into a JAR file. There's also a deploy.plugins target that copies the JAR into the <jiveHome>/plugins directory that accompanies your Clearspace distribution. Paths into your test Clearspace distribution assume that this plugin project is in the standalone Clearspace distribution at: <root>/plugins/plugins/<plugin_name>. Be sure to update the targets if you're testing another way, such as with the Clearspace WAR distribution.
Be sure to read the notes below about dependencies. The JAR files you'll need are included as part of Clearspace.
Running the Sample
Build and deploy the code.
Open Clearspace and create a wiki document. Add whatever text you like, but be sure to add the csvtable macro using the syntax described above.
Preview or publish the document to see its output.
Dependencies
In addition to requiring Java 1.5, this code requires a few of the libraries you'll find in the WEB-INF/lib directory of your Clearspace installation, listed below.
clearspace-<version>.jar
If you'd rather deploy the plugin manually, you can do that in one of two ways:
Just copy the plugin JAR file into the <jiveHome>/plugins directory. Your running Clearspace instance will deploy it automatically.
Open the admin console and navigate to System > Settings > Plugins, then browse for your plugin JAR file.
Comments