Custom Content Fitnesse Plugin
Ever found yourself wanting to add new javascript files to fitnesse for added functionality? Ever wanted to replace the default javascript files with your own, as well as add/or replace css files too?
Sadly, you’ve probably discovered that you can’t, since the html is generated on page request, and the elements in the head are added during the generation process. Further, fitnesse.js is replaced by a copy in the jar each time fitnesse starts. Don’t you wish it could be easier?
If so, then this plugin is for you. It allows you to add your own javascript and css files, with some handy features as well. You can configure explicitly what files you want to include in the plugins.properties file, or you can leave these configuration variables blank and the plugin will scan the /files/javascript and /files/css directories and include all of the files it finds in the head.
Using the plugin is easy… just download it, put it in your classpath, and add this to your plugins.properties file (again… if you don’t have this file, create it and stick it in the directory you run fitnesse from).
HtmlPageFactory=org.jamescarr.fitnesse.html.CustomHtmlPageFactory
# Custom Html Page Configuration
fitnesse_root=/home/jamescarr/fitnesse/FitNesseRoot
As you can see above, I also specify where the FitNesseRoot directory is… as this may be different according to your own configuration. You must have this set! Otherwise, the plugin just flat out won’t work (and you’ll probably get some exception stack traces dumped to the console).
By default, it will include any files it finds directly under css and javascript directories, ignoring subdirectories. To specify exactly what files to use, use something like the following:
javascript_files=dynamicTableMaker/all.js;fitnesse.js
css_files=fitnesse_cold_theme.css;fitnesse_print.css
These are relative to FitNesseRoot/files/javascript/ and FitNesseRoot/files/css/ respectively, using a semicolon to seperate specific files to use. This will only include the files that are specified rather than all of them found in directories, and can make it easier to handle subdirectories.
Well, let me know if anyone finds this useful… I’ve been using it for my dynamic table editor plugin that I’ll (hopefully) be releasing soon.
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!














October 30th, 2007 at 6:14 pm
How do I create the plugins.properties file? is it just a notepad file?
Does this go in the fitnesse folder or the fitnesse root folder?
April 16th, 2009 at 8:49 am
Would it be possible to see the source code for this? The download only contains class files.
Thanks!
February 5th, 2010 at 7:33 pm
Have you seen Richnesse: http://sourceforge.net/projects/richnesse/develop
?? Can I use your plugin for this?
February 5th, 2010 at 7:41 pm
Does plugin.properties go where the fitnesse jar lives or in fitnesse root?