Skip to content

Instantly share code, notes, and snippets.

@awood
Created August 28, 2009 18:11
Show Gist options
  • Save awood/177130 to your computer and use it in GitHub Desktop.
Save awood/177130 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
names: ["rhbug"],
arguments: [{role: "object",
nountype: noun_arb_text,
label: "bug number"}],
description: "Look up a bug in Red Hat's Bugzilla.",
author: { name: "Alex Wood", email: "[email protected]"},
icon: "https://bugzilla.redhat.com/images/favicon.ico",
_bugPage: function(id) {
return "https://bugzilla.redhat.com/show_bug.cgi?id=" + encodeURIComponent(id);
},
preview: function( pblock, {object: {text}} ) {
if (! text) {
this.previewDefault(pblock);
return;
}
var bugLocation = this._bugPage(text);
CmdUtils.previewGet( pblock, bugLocation, null, function(data) {
var results = jQuery(data);
var summary = jQuery("#comment_text_0", results).html();
var template = "<pre>${summary}</pre>";
pblock.innerHTML = CmdUtils.renderTemplate(template, { summary:summary });
}, "html");
},
execute: function(args) {
Utils.openUrlInBrowser(this._bugPage(args.object.text));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment