Skip to content

Instantly share code, notes, and snippets.

@mcepl
Created March 28, 2011 19:27
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 mcepl/891100 to your computer and use it in GitHub Desktop.
Save mcepl/891100 to your computer and use it in GitHub Desktop.
Ubiquity shorten URL
"use strict";
function getShortURL(which, args) {
var baseURL = ""; var params = {};
if (which == "is.gd") {
baseURL = "http://is.gd/create.php";
params = {
format: "simple",
url: encodeURIComponent(args.object.text)
};
}
else if (which == "hurl") {
baseURL = 'http://hurl.test.redhat.com/new?' + encodeURIComponent(args.object.text);
params = "";
}
jQuery.get(baseURL, params, function(tinyUrl) {
Utils.clipboard.set({
text: tinyUrl
});
});
};
CmdUtils.CreateCommand({
names: ["is.gd"],
description: "Replaces the selected URL with a is.gd.",
arguments: [{role: "object",
nountype: noun_type_url,
label: "url to shorten"}],
execute: function (args) {
getShortURL("is.gd", args);
}
});
CmdUtils.CreateCommand({
names: ["hurl"],
description: "Replaces the selected URL with a hurl",
arguments: [{role: "object",
nountype: noun_type_url,
label: "url to shorten"}],
execute: function (args) {
getShortURL("hurl", args);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment