Hi, On Thu, Oct 30, 2008 at 9:27 AM, Jerome Velociter <[email protected]> wrote:
Hello all,
I started working on a {{map}} macro (http://jira.xwiki.org/jira/browse/XWIKI-2784). This raise the question of how (or if) we should work when writing macros depending on JS APIs (being here google maps, yahoo maps, etc.).
The variants I've envisaged so far :
1a. We write all the needed JavaScript in the macro itself. We do it in Strings we transform in lists of WordBlock + SpaceBlock we append as children of a XMLBlock "script". I find this a little painful and not very natural.
1b. We write all the needed JavaScript in the macro itself. We do it in Strings we pass as content of a html/xhtml macros blocks.
2a. We write most of the JavaScript in a JSX object (for example a sort of facade to some google maps APIs), and only the needed calls in the macro itself (for example the call to load a map in a div element). For the code in the macro, we use the same strategy as 1a, except that there is just one of such XML block, and it's relatively short. The JSX Strategy in 2a/2b has that clear advantage to make it much simpler on the server side, but as a counterpart, the macro needs to be distributed as a xar + jar, while in 1) it's a jar only.
2b. Same as 2a using the strategy in 1b for the part in the macro. This is the way I have my prototype working right now. I admit I don't really know what to think about the fact I'm building macros blocks (a velocity one for the jsx "use" call, and a html one for the javascript call) inside the macro itself. I hope you can tell more about this, and let me know if it's a bad practice.
3. We don't do such macro :) We consider it's not what wiki macro should be and we decide to have such macros only as velocity macros which are much simpler to write in that case. This does not change anything for the wysiwyg users, as far as I understand, but it does for the wiki users.{{map location="Paris, France"}} is much more elegant than {{velocity}}#map("Paris, France"){{/velocity}} ; and is much better too in terms of configuration (in velocity we would need to give values to all parameters, even if we want to use default value for most of them).
WDYT ? Are there some variants I did not envisage ?
IMO JSX should be a component supporting loading jar/fs resources files and not only wiki pages. In your case you would ask JSX to use a provided resource URL (or even better a list of JSXSource containing : [WIKIJSXSource, URLJSXSource] to first try wiki then the defaut js you provide to be able to overload it in the wiki). So I would say : 4. load you js from resource file and insert it as XMLBlock (you don't need to cut it in Word/SpaceBlock, you just create a "scrip" XMLBlock and set you whole js as the String content of the XMLBlock) waiting for JSX to support it.
Regards, Jerome. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne