aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data/lib/attachments.js (renamed from data/lib/collectingMetadata.js)51
-rw-r--r--data/lib/comments.js53
-rw-r--r--data/lib/flags.js161
-rw-r--r--data/lib/history.js29
-rw-r--r--data/mozlib/mozpage.js76
-rw-r--r--data/tweaks/bug-page-mod.js86
-rw-r--r--lib/main.js4
-rw-r--r--tools/results-of-XMLRPC-research.txt177
-rw-r--r--tools/testXMLRPC.py20
9 files changed, 451 insertions, 206 deletions
diff --git a/data/lib/collectingMetadata.js b/data/lib/attachments.js
index 5bd956c..40bc719 100644
--- a/data/lib/collectingMetadata.js
+++ b/data/lib/attachments.js
@@ -7,57 +7,6 @@
// http://www.opensource.org/licenses/mit-license.php
"use strict";
-function Comment(comment) {
- var nameSpan = comment.querySelector(".bz_comment_user a.email");
- var timeSpan = comment.getElementsByClassName("bz_comment_time")[0];
-
- this.author = parseMailto(nameSpan).trim();
- this.element = comment;
- this.date = parseBZCommentDate(timeSpan.textContent.trim());
- this.timeSpan = timeSpan;
-}
-
-Comment.prototype.getText = function getText() {
- return (this.element.getElementsByTagName("pre")[0].textContent.trim());
-};
-
-function CommentList(doc) {
- var commentElems = document.getElementById("comments").
- getElementsByClassName("bz_comment");
- var comments = {};
- Array.forEach(commentElems, function (item) {
- var com = new Comment(item);
- if (com.element) {
- comments[ISODateString(com.date)] = com;
- }
- });
- this.comments = comments;
-}
-
-/**
- * Set background color of all comments made by reporter in ReporterColor color
- *
- */
-CommentList.prototype.colorComments = function colorComments() {
- var reporter = getReporter();
- var com = null, idx = null;
- for (idx in this.comments) {
- com = this.comments[idx];
- if (com.author === reporter) {
- com.element.style.backgroundColor = ReporterColor.toString();
- }
- }
-};
-
-CommentList.prototype.getAllCommentsText = function getAllCommentsText() {
- var outStr = "", idx = null;
- for (idx in this.comments) {
- outStr += this.comments[idx].getText() + "\n";
- }
- return outStr;
-};
-// -----------------------------------------------------------
-
/**
* Parse the row with the attachment and create new Attachment object
*
diff --git a/data/lib/comments.js b/data/lib/comments.js
new file mode 100644
index 0000000..3b35517
--- /dev/null
+++ b/data/lib/comments.js
@@ -0,0 +1,53 @@
+// Released under the MIT/X11 license
+// http://www.opensource.org/licenses/mit-license.php
+"use strict";
+
+function Comment(comment) {
+ var nameSpan = comment.querySelector(".bz_comment_user a.email");
+ var timeSpan = comment.getElementsByClassName("bz_comment_time")[0];
+
+ this.author = parseMailto(nameSpan).trim();
+ this.element = comment;
+ this.date = parseBZCommentDate(timeSpan.textContent.trim());
+ this.timeSpan = timeSpan;
+}
+
+Comment.prototype.getText = function getText() {
+ return this.element.getElementsByTagName("pre")[0].textContent.trim();
+}
+
+function CommentList(doc) {
+ var commentElems = document.getElementById("comments").
+ getElementsByClassName("bz_comment");
+ var comments = {};
+ Array.forEach(commentElems, function(item) {
+ var com = new Comment(item);
+ if (com.element) {
+ comments[ISODateString(com.date)] = com;
+ }
+ });
+ this.comments = comments;
+}
+
+/**
+ * Set background color of all comments made by reporter in ReporterColor color
+ *
+ */
+CommentList.prototype.colorComments = function colorComments() {
+ var reporter = getReporter();
+ var com = null;
+ for (var idx in this.comments) {
+ com = this.comments[idx];
+ if (com.author === reporter) {
+ com.element.style.backgroundColor = ReporterColor.toString();
+ }
+ }
+}
+
+CommentList.prototype.getAllCommentsText = function getAllCommentsText() {
+ var outStr = "";
+ for (var idx in this.comments) {
+ outStr += this.comments[idx].getText() + "\n";
+ }
+ return outStr;
+}
diff --git a/data/lib/flags.js b/data/lib/flags.js
new file mode 100644
index 0000000..ffbdb02
--- /dev/null
+++ b/data/lib/flags.js
@@ -0,0 +1,161 @@
+// Released under the MIT/X11 license
+// http://www.opensource.org/licenses/mit-license.php
+"use strict";
+
+/*
+var d = Date.prototype;
+d.__defineGetter__("year", function() { return this.getFullYear(); });
+d.__defineSetter__("year", function(y) { this.setFullYear(y); });
+ */
+
+/**
+ *
+ */
+function FlagElement(element,column) {
+ this.element = element;
+ this.id = element.id;
+ var label = column.querySelector("label[for='" + this.id + "']");
+ this.key = label.textContent.trim().
+ replace(/\s*:?$/, "").replace('\u2011', '-', 'g');
+}
+
+FlagElement.prototype.__defineSetter__("value", function () {
+ selectOption(this.id, what);
+});
+
+FlagElement.prototype.__defineGetter__("value", function () {
+ return document.getElementById(id).value;
+});
+
+FlagElement.prototype.set = function set() {
+ this.value = "+";
+};
+
+FlagElement.prototype.reject = function reject() {
+ this.value = "-";
+};
+
+FlagElement.prototype.ask = function ask() {
+ this.value = "?";
+};
+
+FlagElement.prototype.unset = function unset() {
+ this.value = "--";
+};
+
+FlagElement.prototype.toString = function toString() {
+ return this.value;
+};
+
+/**
+ * Abstract model of flags found on BMO (and later hopefully not
+ * only there)
+ *
+ * @return Object with function properties:
+ * - set Approve flag (currently "+"),
+ * - reject Reject flag (currently "-"),
+ * - ask ask for decision (currently "?"),
+ * - unset clear the flag to the initial state (currently "--"), and
+ * - dump dump internal variable to console
+ */
+function FlagList() {
+ this.flags = {};
+ var tdColumn2 = document.getElementById("custom_flags");
+ var flag_selects = tdColumn2.getElementsByTagName("select");
+ Array.forEach(flag_selects, function(sel) {
+ var object = new FlagElement(sel, tdColumn2);
+ this.flags[object.id] = object;
+ });
+}
+
+FlagList.prototype.set = function set(label) {
+ this.flags[label].set();
+};
+
+FlagList.prototype.reject = function reject(label) {
+ this.flags[label].reject();
+};
+
+FlagList.prototype.ask = function ask(label) {
+ this.flags[label].ask();
+};
+
+FlagList.prototype.unset = function unset(label) {
+ this.flags[label].unset();
+};
+
+FlagList.prototype.toString = function toString() {
+ var out = "flags:\n";
+ for (var key in this.flags) {
+ out += this.flags[key] + ",\n";
+ }
+ return out;
+};
+
+// =================================================
+
+/*
+ flagNames ... list of all tag names
+ flags ... dictionary of td elements keyed by flag names
+
+ function trimContent(el) {
+ return el.textContent.trim();
+}
+ */
+ /**
+ * Finds history item in the collected flags, returns WHAT??? FIXME
+ *
+ * @param item a History Item
+ * (which I should rewrite into proper objects as well? FIXME)
+ * @return FIXME
+ */
+ function findFlag(item) {
+ // This does actually makes sense because "added"/"removed" property of
+ // changes item can contain multiple flags FIXME
+ /**
+ * Is name among flagNames? If yes, return array with one element ...
+ * found name as a key to flags dict.
+ *
+ * @param name String to be looked up
+ * @return Array with one element String with flagName corresponding to
+ * the key of flags dict.
+ */
+ function lookup(name) {
+ name = name.replace('\u2011', '-', 'g');
+ for (var i = 0; i < flagNames.length; ++i) {
+ var quotedFlagName = flagNames[i].replace('.', '\\.', 'g').
+ replace('\u2011', '-', 'g');
+ if ((new RegExp('^' + quotedFlagName)).test(name)) {
+ return flagNames[i];
+ }
+ }
+ return null;
+ }
+
+ var base = item[4] ? 2 : 0; // Is this strange way how to avoid following
+ // condition to be satisified, or it is possible that item[0] can actually be
+ // "Flag"?
+ // handle normal flags
+ if (trimContent(item[base]) == 'Flag') { // FIXME This is acutally bug, it could
+ // be "Flags" as well in HTML
+ var result = [];
+ // This could contain actual value of the flag (or flags) as one string
+ // separated by commas with (optional) values in parenthesis
+ var tmp = lookup(trimContent(item[base + 1]));
+ if (tmp) {
+ result.push(tmp);
+ }
+ // Or it could be also elsewhere? Seems weird.... hopefully not needed
+ // with JSON
+ tmp = lookup(trimContent(item[base + 2]));
+ if (tmp) {
+ result.push(tmp);
+ }
+
+ return result;
+ }
+ // handle special pseudo-flags
+ return lookup(trimContent(item[base]));
+ }
+
+ // ========================================================
diff --git a/data/lib/history.js b/data/lib/history.js
new file mode 100644
index 0000000..e0dca8b
--- /dev/null
+++ b/data/lib/history.js
@@ -0,0 +1,29 @@
+// Released under the MIT/X11 license
+// http://www.opensource.org/licenses/mit-license.php
+"use strict";
+
+function HistoryItem(historyRaw) {
+
+}
+
+History.prototype.getText = function getText() {
+ return this.element.getElementsByTagName("pre")[0].textContent.trim();
+}
+
+function HistoryList(raw) {
+ this.formatVersion = raw.version;
+ this.bugs = [];
+ this.faults = [];
+ raw.result.bugs.forEach(function (historyItemRaw) {
+ var tmpHsItem = new HistoryItem(historyItemRaw);
+ if (tmpHsItem) {
+ this.bugs.push(tmpHsItem);
+ }
+ });
+ raw.result.faults.forEach(function (faultItemRaw) {
+ console.log("HistoryList init: fault = " +
+ faultItemRaw.toSource());
+ });
+ console.log("HistoryList: this.bugs = " +
+ this.bugs.toSource());
+}
diff --git a/data/mozlib/mozpage.js b/data/mozlib/mozpage.js
index c1aa53e..7acf801 100644
--- a/data/mozlib/mozpage.js
+++ b/data/mozlib/mozpage.js
@@ -1,81 +1,7 @@
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
+"use strict";
-/**
- *
- */
-function Flag(element,column) {
- this.element = element;
- this.id = element.id;
- var label = column.querySelector("label[for='" + this.id + "']");
- this.key = label.textContent.trim().replace(/\s*:?$/, "");
-}
-
-Flag.prototype = {
- get id() { return this.id },
- set value(what) {
- selectOption(this.id, what);
- },
- set: function() {
- this.value = "+";
- },
- reject: function() {
- this.value = "-";
- },
- ask: function() {
- this.value = "?";
- },
- unset: function() {
- this.value = "--";
- },
- toString: function() {
- return this.value;
- }
-};
-
-/**
- * Abstract model of flags found on BMO (and not only there)
- *
- * @return Object with function properties:
- * - set Approve flag (currently "+"),
- * - reject Reject flag (currently "-"),
- * - ask ask for decision (currently "?"),
- * - unset clear the flag to the initial state (currently "--"), and
- * - dump dump internal variable to console
- */
-function FlagList() {
- this.flags = {};
- var tdColumn2 = document.getElementById("custom_flags");
- var flag_selects = tdColumn2.getElementsByTagName("select");
- Array.forEach(flag_selects, function(sel) {
- var object = new Flag(sel, tdColumn2);
- this.flags[object.id] = object;
- });
-}
-
-FlagList.prototype = {
- set: function(label) {
- this.flags[label].set();
- },
- reject: function(label) {
- this.flags[label].reject();
- },
- ask: function(label) {
- this.flags[label].ask();
- },
- unset: function(label) {
- this.flags[label].unset();
- },
- toString: function() {
- var out = "flags:\n";
- for (var key in this.flags) {
- out += this.flags[key] + ",\n";
- }
- return out;
- }
-};
-
-// -----------------------------------------------------
var mozFlags = new FlagList();
// Currently empty message handler
diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js
index b0d25eb..db7ce9f 100644
--- a/data/tweaks/bug-page-mod.js
+++ b/data/tweaks/bug-page-mod.js
@@ -110,57 +110,9 @@ function tweakBugzilla(things, cData) {
));
document.getElementsByTagName("head")[0].appendChild(style);
- // collect the flag names, FIXME this is exactly the same as
- // mozFlags._init() function in mozpage.js
- var flagNames = [], flags = {}, flagOccurrences = {};
- var flagRows = document.querySelectorAll("#flags tr");
- for (var i = 0; i < flagRows.length; ++i) {
- var item = flagRows[i].querySelectorAll("td");
- if (!item[1])
- continue;
- var name = trimContent(item[1]).replace('\u2011', '-', 'g');
- flagNames.push(name);
- flags[name] = item[1];
- }
- flagRows = document.querySelectorAll(".field_label[id^=field_label_cf_]");
- for (var i = 0; i < flagRows.length; ++i) {
- var name = trimContent(flagRows[i]).replace(/\:$/, '')
- .replace('\u2011', '-', 'g');
- flagNames.push(name);
- flags[name] = flagRows[i];
- }
- var flagCounter = 1;
+ // here is the whole flagnames stuff FIXME
- // =================================================
- function findFlag(item) {
- function lookup(name) {
- name = name.replace('\u2011', '-', 'g');
- for (var i = 0; i < flagNames.length; ++i) {
- var quotedFlagName = flagNames[i].replace('.', '\\.', 'g')
- .replace('\u2011', '-', 'g');
- if ((new RegExp('^' + quotedFlagName)).test(name)) {
- return [flagNames[i]];
- }
- }
- return [];
- }
- var base = item[4] ? 2 : 0;
- // handle normal flags
- if (trimContent(item[base]) == 'Flag') {
- var result = [];
- var tmp = lookup(trimContent(item[base + 1]));
- if (tmp.length) {
- result.push(tmp[0]);
- }
- tmp = lookup(trimContent(item[base + 2]));
- if (tmp.length) {
- result.push(tmp[0]);
- }
- return result;
- }
- // handle special pseudo-flags
- return lookup(trimContent(item[base]));
- }
+ var flagCounter = 1; // I am not sure what is this counter good for FIXME
var DataStore = new DataStoreCtor();
@@ -175,39 +127,15 @@ function tweakBugzilla(things, cData) {
tbplbotSpamCollapser();
}
+var history = null;
+
// ===================================================
-function processHistory(history) {
+function processHistory(historyRaw) {
// FIXME Remove remaining code to special function ... callback
// preprocessDuplicateMarkers(document, iframe.contentDocument);
+
+ history = new HistoryList(historyRaw);
- /*
- * This is an example of the history we get: { "version": "1.1", "result": {
- * "bugs": [ { "history": [ { "when": "2011-04-04T00:19:04Z", "who":
- * "cebbert@redhat.com", "changes": [ { "removed": "", "added":
- * "xgl-maint@redhat.com", "field_name": "cc", "field": "CC" }, { "removed":
- * "kernel", "added": "xorg-x11-drv-ati", "field_name": "component", "field":
- * "Component" }, { "removed": "kernel-maint@redhat.com", "added":
- * "xgl-maint@redhat.com", "field_name": "assigned_to", "field": "AssignedTo" } ] }, {
- * "when": "2011-04-12T22:48:22Z", "who": "mcepl@redhat.com", "changes": [ {
- * "attachment_id": 488889, "removed": "application/octet-stream", "added":
- * "text/plain", "field_name": "attachments.mimetype", "field": "Attachment
- * mime type" } ] }, { "when": "2011-04-13T17:07:04Z", "who":
- * "mcepl@redhat.com", "changes": [ { "removed": "", "added":
- * "needinfo?(suckfish@ihug.co.nz)", "field_name": "flagtypes.name", "field":
- * "Flags" } ] }, { "when": "2011-04-21T12:17:33Z", "who": "mcepl@redhat.com",
- * "changes": [ { "removed": "xgl-maint@redhat.com", "added":
- * "jglisse@redhat.com", "field_name": "assigned_to", "field": "AssignedTo" } ] }, {
- * "when": "2011-04-28T22:53:58Z", "who": "mcepl@redhat.com", "changes": [ {
- * "attachment_id": 488889, "removed": "text/plain", "added":
- * "application/octet-stream", "field_name": "attachments.mimetype", "field":
- * "Attachment mime type" } ] }, { "when": "2011-04-28T22:59:18Z", "who":
- * "mcepl@redhat.com", "changes": [ { "attachment_id": 488889, "removed":
- * "application/octet-stream", "added": "text/plain", "field_name":
- * "attachments.mimetype", "field": "Attachment mime type" } ] } ], "id":
- * 692250, "alias": [
- * ] } ], "faults": [
- * ] } }
- */
// UserNameCache
var userNameCache = {};
function getUserName(email) {
diff --git a/lib/main.js b/lib/main.js
index 67fa5a7..5d66d4f 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -97,7 +97,9 @@ var contentScriptLibraries = [
self.data.url("lib/rpcutils.js"),
self.data.url("lib/jumpNextBug.js"),
self.data.url("lib/queries.js"),
- self.data.url("lib/collectingMetadata.js"),
+ self.data.url("lib/comments.js"),
+ self.data.url("lib/attachments.js"),
+ self.data.url("lib/flags.js"),
self.data.url("tweaks/preprocessDuplicates.js"),
self.data.url("tweaks/viewSource.js"),
self.data.url("lib/color.js"),
diff --git a/tools/results-of-XMLRPC-research.txt b/tools/results-of-XMLRPC-research.txt
new file mode 100644
index 0000000..7b0eab6
--- /dev/null
+++ b/tools/results-of-XMLRPC-research.txt
@@ -0,0 +1,177 @@
+
+<tr>
+ <td rowspan="1" valign="top">sarika1187@gmail.com
+ </td>
+ <td rowspan="1" valign="top">2010-12-26 00:55:18 PST
+ </td>
+ <td>
+ Flag
+ </td><td>
+ </td><td>another-flag?(sarika1187@gmail.com)
+ </td>
+ </tr>
+
+History of https://landfill.bugzilla.org/bugzilla-tip/show_bug.cgi?id=6513
+{
+ "bugs": [
+ {
+ "alias": "CracklyVoice",
+ "id": 6513,
+ "history": [
+ {
+ "changes": [
+ {
+ "removed": "",
+ "field_name": "flagtypes.name",
+ "added": "another-flag?, another-flag2+, blocker+"
+ }
+ ],
+ "who": "joel.reuter@expeditors.com",
+ "when": <DateTime"20090121T04: 43: 41"at7fcbe3f53a70>
+ },
+ ]
+ }
+ ]
+}
+
+Another history
+https://landfill.bugzilla.org/bugzilla-tip/show_bug.cgi?id=6196
+
+ <tr>
+ <td rowspan="1" valign="top">badevcich
+ </td>
+ <td rowspan="1" valign="top">2007-12-13 15:38:22 PST
+ </td>
+
+ <td>
+ Flags
+ </td><td>
+ </td><td>another-flag?(badevcich)
+ </td>
+ </tr>
+
+{
+ "bugs": [
+ {
+ "alias": "GreatScott",
+ "id": 6196,
+ "history": [
+ {
+ "changes": [
+ {
+ "removed": "",
+ "field_name": "flagtypes.name",
+ "added": "another-flag?(badevcich@gmail.com)"
+ }
+ ],
+ "who": "badevcich@gmail.com",
+ "when": "<DateTime '20071213T23: 38: 22' at 7fbda0544908>"
+ }
+ ]
+ }
+ ]
+}
+
+
+-----------------------
+{
+ "version": "1.1",
+ "result": {
+ "bugs": [
+ {
+ "history": [
+ {
+ "when": "2011-04-04T00:19:04Z",
+ "who": "cebbert@redhat.com",
+ "changes": [
+ {
+ "removed": "",
+ "added": "xgl-maint@redhat.com",
+ "field_name": "cc",
+ "field": "CC"
+ },
+ {
+ "removed": "kernel",
+ "added": "xorg-x11-drv-ati",
+ "field_name": "component",
+ "field": "Component"
+ },
+ {
+ "removed": "kernel-maint@redhat.com",
+ "added": "xgl-maint@redhat.com",
+ "field_name": "assigned_to",
+ "field": "AssignedTo"
+ }
+ ]
+ },
+ {
+ "when": "2011-04-12T22:48:22Z",
+ "who": "mcepl@redhat.com",
+ "changes": [
+ {
+ "attachment_id": 488889,
+ "removed": "application/octet-stream",
+ "added": "text/plain",
+ "field_name": "attachments.mimetype",
+ "field": "Attachment mime type"
+ }
+ ]
+ },
+ {
+ "when": "2011-04-13T17:07:04Z",
+ "who": "mcepl@redhat.com",
+ "changes": [
+ {
+ "removed": "",
+ "added": "needinfo?(suckfish@ihug.co.nz)",
+ "field_name": "flagtypes.name",
+ "field": "Flags"
+ }
+ ]
+ },
+ {
+ "when": "2011-04-21T12:17:33Z",
+ "who": "mcepl@redhat.com",
+ "changes": [
+ {
+ "removed": "xgl-maint@redhat.com",
+ "added": "jglisse@redhat.com",
+ "field_name": "assigned_to",
+ "field": "AssignedTo"
+ }
+ ]
+ },
+ {
+ "when": "2011-04-28T22:53:58Z",
+ "who": "mcepl@redhat.com",
+ "changes": [
+ {
+ "attachment_id": 488889,
+ "removed": "text/plain",
+ "added": "application/octet-stream",
+ "field_name": "attachments.mimetype",
+ "field": "Attachment mime type"
+ }
+ ]
+ },
+ {
+ "when": "2011-04-28T22:59:18Z",
+ "who": "mcepl@redhat.com",
+ "changes": [
+ {
+ "attachment_id": 488889,
+ "removed": "application/octet-stream",
+ "added": "text/plain",
+ "field_name": "attachments.mimetype",
+ "field": "Attachment mime type"
+ }
+ ]
+ }
+ ],
+ "id": 692250,
+ "alias": []
+ }
+ ],
+ "faults": []
+ }
+}
diff --git a/tools/testXMLRPC.py b/tools/testXMLRPC.py
new file mode 100644
index 0000000..9fbaaea
--- /dev/null
+++ b/tools/testXMLRPC.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# A tool for investigating bugzilla XML-RPC values
+
+import xmlrpclib
+XMLRPC_URL = "https://landfill.bugzilla.org/bugzilla-tip/xmlrpc.cgi"
+
+proxy = xmlrpclib.ServerProxy(XMLRPC_URL)
+loginDict = {
+ "login": "ceplma00@yahoo.com",
+ "password": "kyrios",
+ "remember": True
+}
+res = proxy.User.login(loginDict)
+
+historyDict = {
+ "ids": [ 6196 ]
+}
+
+res = proxy.Bug.history(historyDict)
+print res