public
Last active

firefox ubiquity command for posting delicious bookmarks

  • Download Gist
delicious-ubiquity-command.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
 
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;
}
})

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.