Exposing AgileZen stories in Confluence Wiki

Dennis Newel's Avatar

Dennis Newel

25 Jan, 2012 05:51 PM via web

This is more of a hint than a question :) but i though others might be interested so here's how i managed to get a list of stories shown in Confluence Wiki (4.1).

(I'm assuming an API key etc. has been setup and that you want to display stories based on tags)

First off, add a new "Wiki Markup" macro so that you can get around the new editor.
Then add this javascript:

{html}
<div id="AgileZen"></div>
<script type="text/javascript">
var project = <project number>;
var apikey = '<api key>';
var tag = '<tag>';
var url = "https://agilezen.com/api/v1/projects/" + project + "/stories?callback=displayStories&apikey=" + apikey + "&where=tag:" + tag;
function displayStories(res) {
  var html = "";
  html += "<table class='confluenceTable'>";
  html += "  <tbody>";
  html += "    <tr>";
  html += "      <th class='confluenceTh'>ID</th>";
  html += "      <th class='confluenceTh'>Text</th>";
  html += "      <th class='confluenceTh'>Size</th>";
  html += "      <th class='confluenceTh'>Priority</th>";
  html += "      <th class='confluenceTh'>Status</th>";
  html += "      <th class='confluenceTh'>Owner</th>";
  html += "    </tr>";
  var i;
  for (i=0;i<res.items.length;i++) {
    html += "    <tr>";
    html += "      <td class='confluenceTd'>" + res.items[i]["id"] + "</td>";
    html += "      <td class='confluenceTd'>" + res.items[i]["text"] + "</td>";
    html += "      <td class='confluenceTd'>" + res.items[i]["size"] + "</td>";
    html += "      <td class='confluenceTd'>" + res.items[i]["priority"] + "</td>";
    html += "      <td class='confluenceTd'>" + res.items[i]["status"] + "</td>";
    html += "      <td class='confluenceTd'>" + res.items[i]["owner"]["name"] + "</td>";
    html += "    </tr>";
  }
  html += "</tbody></table>";
  document.getElementById("AgileZen").innerHTML = html;
} 
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= url;
head.appendChild(script);
</script>
{html}

Remember to add your own project, API key and tag.

Save the page and you should now see a nice wiki-formatted table of stories

  1. Support Staff 2 Posted by Mary on 20 Apr, 2012 06:35 PM

    Mary's Avatar

    Hi Dennis,

    I just wanted to let you know how much we appreciate you sharing your Javascript for the wiki, this is great! Thank you and have a great weekend :)

    Sincerely,

    Mary

  2. 3 Posted by Dennis Newel on 23 Apr, 2012 03:47 PM

    Dennis Newel's Avatar

    :) no worries.

    It's still working quite well and i'm using it to expose my personal kanban board to the rest of the company.

  3. 4 Posted by JBB on 28 Apr, 2012 07:41 PM

    JBB's Avatar

    Wow - thanks for this. Very useful!

Reply to this discussion

Internal reply

Formatting help or Preview

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Recent Discussions

19 Apr, 2011 11:29 AM
14 May, 2012 01:36 PM
15 May, 2012 07:58 PM
16 May, 2012 06:03 PM
16 May, 2012 08:28 PM