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)
#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 url 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 OpenSocial 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.





