On Tue, Aug 4, 2009 at 9:29 AM, Asiri Rathnayake <asiri.rathnayake(a)gmail.com
wrote:
The wiki macro bridge has been released with 2.0M2. ...
If you come across any problems while you are at it, we can improve wiki
macro bridge :)
Thanks for reminding me about the Xwiki macro bridge. Looks great and is a
big improvement over how things were done previously. Your message was
timely as helped me answer one of my big questions about having groovy or
clojure macros available on virtual-wiki setup:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WikiMacroTutorial
- Wiki macro authors need to have programming rights
- Wiki macros can only be defined inside the main wiki, though they can
be used throughout a farm
I wrote my first macro-bridge macro (see attachment Main.TestMacroBridge.xar
) in groovy in preparation for my experiments with scripting in Clojure. The
hardest thing was finding out that the name of "context" had changed to
"xcontext" for groovy and other JSR-223 languages, whereas velocity (and
WikiMacroTutorial) uses "context". This has been discussed on the lists (
http://markmail.org/message/o2trzrnv5xts6x6v ), and the WikiMacroTutorial
needs updating to reflect the final status & naming-conventions.
My macro is quite simple. but does a lot, taken from here:
http://www.ibm.com/developerworks/java/library/j-pg05199/index.html
Usage: {{weather_by_zip zip=92625 /}}
Code:
...............................
Objects of type XWiki.WikiMacroClass WikiMacroClass 0: weather_by_zip
{{script language=groovy}}
def rss = new XmlSlurper().parseText(("
http://weather.yahooapis.com/forecastrss?p=" +
xcontext.macro.params.zip).toURL().text) println rss.channel.title println
"Sunrise: ${rss.channel.astronomy.@sunrise}" println "Sunset:
${rss.channel.astronomy.@sunset}" println "Currently:" println
"\t" +
rss.channel.item.condition.@date println "\t" +
rss.channel.item.condition.@temp println "\t" +
rss.channel.item.condition.@text {{/script}}
Objects of type XWiki.WikiMacroParameterClass WikiMacroParameterClass 0: zip
...............................
May be you can put it to test by trying to implement your chart macro ;)
It would be more useful to offer all-new
Exhibit<http://www.simile-widgets.org/exhibit/> functionality
with tighter integration into the Xwiki back-end, e.g.
having document/space and other Xwiki "model" information abstractly
available to an Exhibit-based "view/controller" to provide a "faceted
views"
presentation of Xwiki documents and contents. FYI, My existing Exhibit
integration with Xwiki demo:
http://nielsmayer.com/xwiki/bin/view/Exhibit/Presidents4 (source:
http://nielsmayer.com/xwiki/bin/download/Exhibit/Presidents4/Presidents4Pkg…)
My main commitment right now is an experiment to see if I can get
JSR223-supported Clojure scripting in Xwiki.
This message didn't give me much hope of success right now (
http://groups.google.com/group/clojure/msg/ad811b69d448e3db ) but I'll give
Clojure on Xwiki a try anyways, and revisit later if it's just a matter of
getting more solid JSR223 support for Clojure as development progresses.
Niels
http://nielsmayer.com