Skip to content

Instantly share code, notes, and snippets.

@wireframe
Created August 27, 2008 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save wireframe/7516 to your computer and use it in GitHub Desktop.
Save wireframe/7516 to your computer and use it in GitHub Desktop.
firefox ubiquity command for posting delicious bookmarks
CmdUtils.CreateCommand({
name: "delicious",
homepage: "http://ryan.codecrate.com/",
author: { name: "Ryan Sonnek", email: "ryan@codecrate.com"},
contributors: ["Ryan Sonnek"],
license: "MIT",
description: "Tags the current site using delicious",
icon: "http://delicious.com/favicon.ico",
help: "Save the current url to delicious with the tags input by the user. Any selected text on the page will be recorded as the note.",
takes: {notes: noun_arb_text},
modifiers: {
tagged: noun_arb_text,
entitled: noun_arb_text
},
preview: function(pblock, notes, mods) {
var params = this.post_params(notes, mods);
html = "title: " + params.description + "<br />";
html += "tags: " + params.tags + "<br />";
html += "note: " + params.extended + "<br />";
pblock.innerHTML = html;
},
execute: function(notes, mods) {
jQuery.ajax({
type: "POST",
dataType: "xml",
url: "https://api.del.icio.us/v1/posts/add",
data: this.post_params(notes, mods),
error: function() {
displayMessage("Error saving bookmark to delicious");
},
success: function(xml) {
var result = jQuery(xml).find("result");
var code = result.attr("code");
if (code == "done") {
displayMessage("Bookmark saved to delicious!");
} else {
displayMessage("Error saving bookmark to delicious: " + code);
}
}
});
},
post_params: function(notes, mods) {
var document = context.focusedWindow.document;
var params = {
url: document.location,
description: mods.entitled.text || document.title,
extended: notes.text,
tags: mods.tagged.text
};
return params;
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment