A while ago I posted how to integrate Google Moderator with Confluence , but it was a hard-coded solution which would only embed one Moderator series. After (finally) getting off my backside I've now got an improved User Macro which allows you to enter the URL of any Moderator series as a parameter to the macro.
Most of the steps are the same as the previous blog post , but the template for the macro has been changed from:
<div id="moderator-embed-target"></div>
<script type="text/javascript">
var mod = new MODERATOR("http://www.google.com/moderator/[ID of your Moderator series]);
mod.hl = "en";
mod.width = 1000;
mod.height = 500;
mod.embed("moderator-embed-target");
</script>
to:
#set ($url = ($paramurl))
#if ($url)
<div id="moderator-embed-target"></div>
<script type="text/javascript">
var mod = new MODERATOR("${url}");
mod.hl = "en";
mod.width = 1000;
mod.height = 500;
mod.embed("moderator-embed-target");
</script>
#else
<div class="errorBox">You must specify a <strong>url<strong> parameter.<div>
#end
This small change now allows you to enter something similar to:
{google-moderator:url=http://www.google.com/moderator/#16/e=22571}
into the body of a Confluence page, where the URL is just copied and pasted from the home page of your Google Moderator series. This results in:
If you forget to enter a URL parameter by just entering:
{google-moderator}
you will be presented with:
I still need to work on turning this into a "proper" plugin or Open Social gadget, but it's more flexible than the old macro.
FOOTNOTE: I didn't use $generalUtil.urlEncode($paramurl) in the macro as when the URL is encoded the macro fails to render.
2 comments:
Nice work, Andrew. Creative use of user macros - love it!
Not sure if you knew or not, but we are about to ship Confluence 3.4 over the next coming weeks. In 3.4 we introduced the ability to easily expose user macros in the Confluence Macro Browser. This includes the ability to define custom fields as inputs for your user macro (in your case you could use it for the moderator URL). This might make it easy enough for you to share the macro in the macro browser without writing a 'full blown' macro - if you don't need to.
We shipped this feature in milestone 2 of Confluence 3.4 (a development build). You can checkout an example of how you can specify macro parameters in the 3.4-m2 release notes.
Sherif Mansour
Confluence Product Manager
Thanks Sherif, I'll check out 3.4 and look at porting the macro to the macro browser.
What I really want to do is write a plugin or gadget to break apart the Google Moderator functionality so I can have something like a "Top Suggestions" panel alongside other Confluence content rather than it taking up the entire page.
Post a Comment