Bugzilla renderer/backend patch



Hello.

I've attached a patch for the bugzilla backend and bugzilla renderer.
Here's what it does:

* Moves the status color-coding routines from the backend to the
  renderer.
* Incorporates Lukas Lipka's new color codes.  (Thanks, Lukas!)
* Added the missing img closing tag in the xhtml output.  (Oops.)

Let me know if I can commit this patch to cvs.

Thanks!

-- 
Kevin Godby <godbyk yahoo com>
diff -ruN pristine-dashboard/backends/BugzillaBackend.cs kmg-dashboard/backends/BugzillaBackend.cs
--- pristine-dashboard/backends/BugzillaBackend.cs	2004-03-06 06:00:40.000000000 -0600
+++ kmg-dashboard/backends/BugzillaBackend.cs	2004-04-19 14:09:24.000000000 -0500
@@ -2,8 +2,6 @@
 // backend-bugzilla.cs: A backend which displays bugzilla bugs based
 // on their bug numbers.
 //
-// FIXME: Choose good bug colors.
-//
 // Nat Friedman <nat nat org>
 //
 
@@ -134,8 +132,6 @@
 				return null;
 			}
 
-			string status_color = this.GetStatusColor (status);
-
 			string bug_url = String.Format ("{0}/show_bug.cgi?id={1}", bugzilla_host, bug_num);
 
 			Match match = new Match ("BugzillaBug", c);
@@ -143,33 +139,11 @@
 			match ["Product"] = product;
 			match ["Owner"]   = owner;
 			match ["Summary"] = summary;
-
-			string statushtml = "<font color=\"" + status_color + "\">" + status + "</font>";
-			match ["Status"]  = statushtml;
+			match ["Status"]  = status;
 
 			return match;
 		}
 
-		private string GetStatusColor (string status)
-		{
-			switch (status) {
-
-			case "RESOLVED":
-				return "#00dd00";
-
-			case "NEEDINFO":
-				return "#cad505";
-
-			case "ASSIGNED":
-				return "#1438e8";
-
-			default:
-				return "#000000";
-
-			}
-		}
-					      
-
 		private string GetXmlText (XmlDocument xml, string tag)
 		{
 			XmlNode node;
diff -ruN pristine-dashboard/renderers/BugzillaBugMatchRenderer.cs kmg-dashboard/renderers/BugzillaBugMatchRenderer.cs
--- pristine-dashboard/renderers/BugzillaBugMatchRenderer.cs	2004-03-04 14:15:05.000000000 -0600
+++ kmg-dashboard/renderers/BugzillaBugMatchRenderer.cs	2004-04-19 14:09:37.000000000 -0500
@@ -5,6 +5,7 @@
 //
 // Author:
 //   Kevin Godby <godbyk yahoo com>
+//   Lukas Lipka <lukas pmad net>
 //
 
 using System;
@@ -37,8 +38,6 @@
 			xw.WriteAttributeString ("cellpadding", "0");
 			xw.WriteAttributeString ("cellspacing", "0");
 			
-			// We're using .WriteRaw because all html is generated
-			// with sw inside the loop -- so we should be safe
 			foreach (Match m in matches)
 				HTMLRenderSingleBugzillaBug (m, xw);
 
@@ -64,15 +63,13 @@
 			if (Owner.IndexOf ("@") != -1)
 				Owner = Owner.Substring (0, (Owner.LastIndexOf ("@") - 1));
 
-			// StringWriter sw = new StringWriter ();
-			// XmlWriter xw = new XmlTextWriter (sw);
-
 			xw.WriteStartElement ("tr");
 			xw.WriteStartElement ("td");
 			xw.WriteAttributeString ("valign", "top");
 
 			xw.WriteStartElement ("img");	// Bug icon
 			xw.WriteAttributeString ("src", Icon);
+			xw.WriteEndElement ();	// img
 			xw.WriteEndElement ();	// td
 
 			xw.WriteStartElement ("td");
@@ -90,16 +87,47 @@
 			xw.WriteString (Owner);
 			xw.WriteEndElement ();	// a href
 
-			xw.WriteRaw (" " + Status);
+			xw.WriteStartElement ("font");
+			xw.WriteAttributeString ("color", GetStatusColor (Status));
+			xw.WriteString (Status);
+			xw.WriteEndElement ();	// font
 
 			xw.WriteEndElement ();	// font
 			xw.WriteEndElement ();	// td
 			xw.WriteEndElement ();	// tr
 
-			// xw.Close ();
+		}
+		
+		private string GetStatusColor (string status)
+		{
+			switch (status) {
+
+			case "RESOLVED":
+				return "#00dd00";
+
+			case "NEEDINFO":
+				return "#cad505";
+
+			case "ASSIGNED":
+				return "#1438e8";
+
+			case "VERIFIED":
+				return "#acadaf";
+
+			case "UNCONFIRMED":
+				return "#acadaf";
+
+			case "NEW":
+			case "REOPENED":
+				return "#ff0000";
+
+			case "CLOSED":
+				return "#000000";
 
-			// return sw.ToString ();
+			default:
+				return "#000000";
 
+			}
 		}
 	}
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]