Skip to content

Instantly share code, notes, and snippets.

@lamdor
Created October 26, 2008 21:34
Show Gist options
  • Save lamdor/19951 to your computer and use it in GitHub Desktop.
Save lamdor/19951 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: "delicious-search",
icon: "http://delicious.com/favicon.ico",
homepage: "http://delicous.com/",
author: { name: "Luke Amdor", email: "luke.amdor@gmail.com"},
license: "MIT",
description: "Searches through your delicous bookmarks",
help: "just delicous-search and it will show a list of bookmarks that match",
takes: {"tag": noun_arb_text},
delicious_base: "http://delicious.com",
preview: function( pblock, input ) {
pblock.innerHTML = "Retreives bookmarks for tag";
if (input.text && input.text.length >= 1) {
Utils.parseRemoteDocument(
this._search_url(input.text),
null,
function(document) {
var previewHtml = "";
var previewTemplate = '<a href="${href}">${text}</a><br />';
var bookmarks = jQuery(document).find("#my-bookmarklist").find("a.taggedlink");
bookmarks.map(function() {
var link_href = jQuery(this).attr("href");
var link_text = jQuery(this).text();
previewHtml += CmdUtils.renderTemplate(previewTemplate, {href: link_href, text: link_text});
});
pblock.innerHTML = previewHtml;
},
function() {
pblock.innerHTML = "Error";
}
);
}
},
execute: function(input) {
Utils.openUrlInBrowser(this._search_url(input.text));
},
_search_url: function(search_text) {
return this.delicious_base + "/search" + Utils.paramsToString({context:'userpost', p:search_text});
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment