Google Moderator + Confluence Take 2

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.

Google Moderator + Confluence

I’m late to the party on discovering Google Moderator, but it looks like a very easy way to capture, vote on and then prioritise requirements, ideas and suggestions.  Which always seems to have been a problem for all the organisations I’ve worked for, as it was whoever shouted loudest or whoever was the “VIP” got what they wanted rather than development effort being focused on the features that would benefit the majority of users.

Posts on Google Moderator tend to be very high-level and the teams I’ve worked with capture more detailed requirements using Atlassian Confluence so I wanted to have a play with embedding Google Moderator into Confluence – which turned out to be really easy for a basic integration.

Here’s what you need to do:

Add the Google Moderator Javascript to a Main Layout

  1. Login as the owner of a Confluence Space
  2. Navigate to Browse -> Space Admin -> Layout
  3. Select Create Custom next to Main Layout

 

Then add the following to the section of the Main Layout:

<script type="text/javascript" src="http://www.google.com/moderator/static/moderator-embed-api.js"></script>

E.g.

Create a User Macro

You don’t need to do this, but I decided to create a User Macro so people could embed Google Moderator with a simple {moderator} macro rather than needing to know the Javascript code for embedding directly.

  1. Login as a Confluence Administrator
  2. Navigate to Browse -> Confluence Admin -> User Macros -> Create a User Macro
  3. Populate with the following information:
Macro Name: moderator
Macro Body: unchecked
Output: Macro generates HTML markup
Template:
<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>

Use the {moderator} Macro on a Page

Just edit a page in the normal way and add the {moderator} macro to the page.

View the Results

Next Steps

The above works quite well for a basic integration, but I’d like to have more control over the look and feel of Google Moderator on a page so I’m going to see if I can create a Confluence plugin or OpenSocial gadgets using the Google Moderator API.