XWiki – Customize presentation with wiki macros
About a week ago I decided to move my web content from myxwiki.org to rathnayake.org. The decision was mainly because I wanted have a personal server which I can use for all sorts of wacky experiments. As an added benefit, now I can host my content under a personal domain. With this move I began working on some of the articles that I always wanted to publish. But there I was bit worried; the default presentational macros of XWiki did not match my taste. For an example, xwiki has three macros for presenting informative messages:
Clearly this wasn’t enough for me, I wanted more aesthetically pleasing, customizable and reusable presentational elements for my work. At this point it came to my mind that coupling XWiki skin extension support with XWiki wiki macros would provide a solution for my problem; I spent several hours with both the technologies and finally came up with the mbox macro:
NOTE: You can download & view source code for mbox macro at MBox macro page.
So how customizable is this new mbox macro? There are two possibilities here. On one hand we can mix-and-match various parameters of the mbox macro to create different presentational elements. For an example, we can quickly put together a warning mbox element like below:
Output of above warning mbox would be:
NOTE: Tango icon library provides a wealth of icons that can be used with mbox macro.
The other approach towards customizing mbox macro is to edit the MBox style sheet extension or the MBox wiki macro Definition itself (both residing inside MBox macro page). Still, this approach might not qualify as a method of customizing, rather it is like a central control box where you can alter the presentation of your content by editing just one wiki page. All your wiki pages will be updated instantly to reflect your new instructions.
Finally what about re-usability? This is where it gets really interesting: xwiki macros can be nested, which means you can derive new macros encapsulating existing ones. I’ll leave the details out for now, just have a look at my mnote macro which is derived from the mbox macro:
NOTE: You can refer MNote macro page for source code and installation instructions.
As we saw above, wiki macros allow authorised users to define new presentational elements which are customizable, reusable and extensible. I should conclude my post stating that this is only one cool feature of XWiki, there are host of other XWiki features which when used wisely makes XWiki a great application / publishing platform. I will be posting more about these cool XWiki features in coming months



