On Tue, Jun 12, 2012 at 3:46 PM, David Delbecq <[email protected]> wrote:
Hello,
To customize our entreprise wiki, we have identified a few plugins / macros that we need to develop. I have checked the online xwiki documentation / tutorial, but i find them quite uncomplete, so here i am with my questions :)
1) It is my understanding that, if my macro need some specific javascript (eg jquery.js) and css, i must use xwiki skin extension. While i can find easily how to create xwiki velocity code that use those extension, i found no explanation on how to do this in java from within "public List<Block> execute(T parameters, String content, MacroTransformationContext context)"? Where can i find example of embedding javascript/css inside a java macro jar or xar?
2) Extensions are provided as xar, maven archetype for xwiki java macro generates a .jar. How do i generate a xar with maven so that in one archive i have both my macro, the css and the js?
No, what we call "extension" can be anything, including jar. They xar and jar are just not put in the same place. A XAR is a set of wiki pages, nothing more.
3) Most extension referenced on xwiki main site are open source, but where are the source? I can only find the compiled xar files on download
There is a source field to put a link on the sources, it's possible some of them are not properly setup and should be fixed. Also a XAR does not contains binary, it's a zip containing pages as XML which are the source too so you always have the sources when talking about a XAR.
4) Is there some recommanded way to pass complex parameters to macros? I need to create some dynamic menu that will get as parameter a list of node + links + icon to show + subnodes + for each subnodes icons / links + subsubnode etc. Is it good practice to just put some kind of json in the body of macro, something like
{{mymenu width="200px"}} [ { name: "node1", link: "MySpace.MyPage1", icon: "somelinktoanattachement"} , { name: "node2", link: "MySpace.MyPage2", icon: "somelinktoanattachement"}, { name: "node3", link: "MySpace.MyPage3", submenu: [ { name: "node3.1", link: "MySpace.MyPage31", icon: "somelinktoanattachement"}, { name: "node3.2", link: "MySpace.MyPage32", icon: "somelinktoanattachement"} ] } ]
{{/mymenu}}
Yes when you need so very advanced data for the macro we generally pass it in the content. See http://extensions.xwiki.org/xwiki/bin/view/Extension/Chart+Macro for example.
And in this case, are there already some stock xwiki methode to transform json into objet array?
I'm sure there is plenty of tools in Java to parse JSON so no need for XWiki to provide an dedicated API for it. In standard XE we embedded http://json-lib.sourceforge.net/ by default which seems to be what you need. What we use generally is wiki table syntax (like in chart macro) and then use the wiki syntax parse to get it. There is no real recommended syntax in general, you need to use what you think is best to represent your datas.
Thank you,
David Delbecq
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne