Skip to content

Instantly share code, notes, and snippets.

@tghw
Created February 19, 2009 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tghw/67153 to your computer and use it in GitHub Desktop.
Save tghw/67153 to your computer and use it in GitHub Desktop.
Ubiquity command for FogBugz
CmdUtils.CreateCommand({
name: "fogbugz",
takes: {"text": noun_arb_text},
modifiers: {"new": noun_arb_text},
homepage: "http://www.fogbugz.com/",
icon: "http://www.fogcreek.com/FogBugz/favicon.ico",
author: { name: "Tyler Hicks-Wright", email: "support@copilot.com"},
description: "FogBugz",
help: "Select some text to search FogBugz.",
execute: function(directObject, mods){
var FOGBUGZ_URL = "http://YOUR_FOGBUGZ_SITE/";
var url, text;
if (jQuery.trim(mods["new"].text).length)
{
url = FOGBUGZ_URL + "default.asp?pg=pgEditBug&command=new&sTitle={QUERY}";
text = jQuery.trim(mods["new"].text);
}
else
{
url = FOGBUGZ_URL + "default.asp?searchFor={QUERY}&pre=preMultiSearch&pg=pgList&pgBack=pgSearch&search=2";
text = directObject.text;
}
var urlString = url.replace("{QUERY}", text);
Utils.openUrlInBrowser(urlString);
},
preview: function(pblock, directObject, mods) {
var previewText, previewTemplate, previewData;
if (jQuery.trim(mods["new"].text).length > 0)
{
previewText = jQuery.trim(mods["new"].text);
previewTemplate = "Create new case in FogBugz with title '${query}'";
previewData = {query: previewText};
pblock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
}
else
{
previewText = jQuery.trim(directObject.text);
if(previewText.length <= 0){
pblock.innerHTML = "Search FogBugz";
return;
}
previewTemplate = "Search FogBugz for ${query}";
previewData = {query: previewText};
pblock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment