Improved Unfuddle Tickets Plugin.

This commit is contained in:
Dario Solera 2011-01-29 11:56:23 +00:00
parent d60b6881cb
commit 0c2552c2eb
2 changed files with 57 additions and 24 deletions

View file

@ -3,29 +3,40 @@
<xsl:output method="html"/>
<xsl:template match="/">
<div id="UnfuddleTicketsDiv">
<!-- JavaScript -->
<script type="text/javascript">
// <![CDATA[
function ToggleTicketDetails(ticketId) {
var descr = document.getElementById("ticket_description_" + ticketId);
if(descr.style["display"] == "none") descr.style["display"] = "";
else descr.style["display"] = "none";
}
// ]]>
</script>
<!-- Highest -->
<xsl:if test="count(/root/ticket-report/groups/group/title[text() = 'Highest']/parent::group/tickets) &gt; 0">
<h2 class="separator">Priority: Highest</h2>
<h2 class="separator">Highest Priority</h2>
</xsl:if>
<xsl:apply-templates select="/root/ticket-report/groups/group/title[text() = 'Highest']/parent::group/tickets"/>
<!-- High -->
<xsl:if test="count(/root/ticket-report/groups/group/title[text() = 'High']/parent::group/tickets) &gt; 0">
<h2 class="separator">Priority: High</h2>
<h2 class="separator">High Priority</h2>
</xsl:if>
<xsl:apply-templates select="/root/ticket-report/groups/group/title[text() = 'High']/parent::group/tickets"/>
<!-- Normal -->
<xsl:if test="count(/root/ticket-report/groups/group/title[text() = 'Normal']/parent::group/tickets) &gt; 0">
<h2 class="separator">Priority: Normal</h2>
<h2 class="separator">Normal Priority</h2>
</xsl:if>
<xsl:apply-templates select="/root/ticket-report/groups/group/title[text() = 'Normal']/parent::group/tickets"/>
<!-- Low -->
<xsl:if test="count(/root/ticket-report/groups/group/title[text() = 'Low']/parent::group/tickets) &gt; 0">
<h2 class="separator">Priority: Low</h2>
<h2 class="separator">Low Priority</h2>
</xsl:if>
<xsl:apply-templates select="/root/ticket-report/groups/group/title[text() = 'Low']/parent::group/tickets"/>
<!-- Lowest -->
<xsl:if test="count(/root/ticket-report/groups/group/title[text() = 'Lowest']/parent::group/tickets) &gt; 0">
<h2 class="separator">Priority: Lowest</h2>
<h2 class="separator">Lowest Priority</h2>
</xsl:if>
<xsl:apply-templates select="/root/ticket-report/groups/group/title[text() = 'Lowest']/parent::group/tickets"/>
</div>
@ -35,20 +46,20 @@
<thead>
<tr class="tableheader">
<th style="white-space: nowrap; text-align: left; width: 50px;">
#
</th>
#
</th>
<th style="white-space: nowrap; text-align: left;">
Summary
</th>
Summary
</th>
<th style="white-space: nowrap; text-align: left; width: 80px;">
Status
</th>
Status
</th>
<th style="white-space: nowrap;width: 70px;">
Priority
</th>
Priority
</th>
<th style="white-space: nowrap; text-align: left;width: 120px;">
Milestone
</th>
Milestone
</th>
</tr>
</thead>
<tbody>
@ -59,6 +70,7 @@
<br />
</xsl:template>
<xsl:template match="/root/ticket-report/groups/group/tickets/ticket">
<xsl:variable name="number" select="number"/>
<tr>
<xsl:if test="position() mod 2 != 1">
<xsl:attribute name="class">priority_{priority} tablerowalternate</xsl:attribute>
@ -68,10 +80,16 @@
</xsl:if>
<xsl:variable name="priority" select="priority"/>
<td class='priority_{priority}' style="text-align: left;">
<xsl:value-of select="number"/>
<a href="#" onclick="javascript:ToggleTicketDetails('{number}'); return false;">
<xsl:value-of select="number"/>
</a>
</td>
<td class='priority_{priority}'>
<xsl:value-of select="summary" disable-output-escaping="yes"/>
<a href="#" onclick="javascript:ToggleTicketDetails('{number}'); return false;">
<b>
<xsl:value-of select="summary" disable-output-escaping="yes"/>
</b>
</a>
</td>
<td class='priority_{priority}'>
<xsl:variable name="c" select="substring(status,1,1)"/>
@ -90,12 +108,24 @@
<td class='priority_{priority}'>
<xsl:variable name="milestoneID" select="milestone-id"/>
<xsl:if test="$milestoneID = ''">
None
</xsl:if>
None
</xsl:if>
<xsl:if test="$milestoneID != ''">
<xsl:value-of select="/root/milestones/milestone/id[text()=$milestoneID]/parent::milestone/title"/>
</xsl:if>
</td>
</tr>
<tr style="display: none;" id="ticket_description_{number}">
<xsl:if test="position() mod 2 != 1">
<xsl:attribute name="class">tablerowalternate</xsl:attribute>
</xsl:if>
<xsl:if test="position() mod 2 != 0">
<xsl:attribute name="class">tablerow</xsl:attribute>
</xsl:if>
<td colspan="5" style="padding: 10px;">
<!-- This could also be description-formatted -->
<xsl:value-of select="description" disable-output-escaping="yes"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>

View file

@ -22,7 +22,7 @@ namespace ScrewTurn.Wiki.Plugins.PluginPack {
private const string ConfigHelpHtmlValue = "Config consists of three lines:<br/><i>&lt;Url&gt;</i> - The base url to the Unfuddle API (i.e. http://account_name.unfuddle.com/api/v1/projects/project_ID)<br/><i>&lt;Username&gt;</i> - The username to the unfuddle account to use for authentication<br/><i>&lt;Password&gt;</i> - The password to the unfuddle account to use for authentication<br/>";
private const string LoadErrorMessage = "Unable to load ticket report at this time.";
private static readonly Regex UnfuddleRegex = new Regex(@"{unfuddle}", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
private static readonly ComponentInformation Info = new ComponentInformation("Unfuddle Tickets Plugin", "Threeplicate Srl", "3.0.2.538", "http://www.screwturn.eu", "http://www.screwturn.eu/Version/PluginPack/UnfuddleTickets2.txt");
private static readonly ComponentInformation Info = new ComponentInformation("Unfuddle Tickets Plugin", "Threeplicate Srl", "3.0.4.575", "http://www.screwturn.eu", "http://www.screwturn.eu/Version/PluginPack/UnfuddleTickets2.txt");
private string _config;
private IHostV30 _host;
@ -77,14 +77,17 @@ namespace ScrewTurn.Wiki.Plugins.PluginPack {
if(block.Key != -1) {
string unfuddleTickets = null;
if(HttpContext.Current != null)
if(HttpContext.Current != null) {
unfuddleTickets = HttpContext.Current.Cache["UnfuddleTicketsStore"] as string;
}
if(string.IsNullOrEmpty(unfuddleTickets))
if(string.IsNullOrEmpty(unfuddleTickets)) {
unfuddleTickets = LoadUnfuddleTicketsFromWeb();
}
if(string.IsNullOrEmpty(unfuddleTickets))
if(string.IsNullOrEmpty(unfuddleTickets)) {
unfuddleTickets = LoadErrorMessage;
}
do {
buffer.Insert(block.Key, unfuddleTickets);
@ -211,7 +214,7 @@ namespace ScrewTurn.Wiki.Plugins.PluginPack {
return null;
}
var tickets = GetXml("/ticket_reports/dynamic?sort_by=priority&sort_direction=DESC&conditions_string=status-neq-closed&group_by=priority&fields_string=number,priority,summary,milestone,status,version", _username, _password);
var tickets = GetXml("/ticket_reports/dynamic?sort_by=priority&sort_direction=DESC&conditions_string=status-neq-closed&group_by=priority&fields_string=number,priority,summary,milestone,status,version,description&formatted=true", _username, _password);
if(tickets == null) {
LogWarning("Exception occurred while pulling unfuddled ticket information from the API.");
return null;