Skip to content

Instantly share code, notes, and snippets.

@gerdk gerdk/x
Created Apr 9, 2009

Embed
What would you like to do?
CmdUtils.CreateCommand({
name: "wp_blog",
takes: { search: noun_arb_text },
locale: "en-US",
homepage: "http://gkoenig.wordpress.com",
icon: "http://s.wordpress.org/favicon.ico",
author: { name: "Gerd Koenig" },
license: "MPL",
description: "Searches for a term in wordpress.com blogs",
preview: function(previewBlock, directObject) {
var apiUrl = "http://en.search.wordpress.com/?q=";
var searchText = jQuery.trim(directObject.text);
if(searchText.length < 2) {
previewBlock.innerHTML = "Searches in wordpress.com blogs";
return;
}
var previewTemplate = "Looking for <b>${query}</b> in wordpress.com blogs...";
var previewData = {query: searchText};
previewBlock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
Utils.parseRemoteDocument(
"http://en.search.wordpress.com/?q=" + directObject.text,
null,
function(document) {
var resultados = jQuery('.searchresults', document.body).html();
previewBlock.innerHTML = resultados;
},
function() {
previewBlock.innerHTML = "Error";
}
);
},
execute: function(directObject) {
var searchUrl = "http://en.search.wordpress.com/?q=";
var searchParams = directObject.text;
Utils.openUrlInBrowser(searchUrl + "/" + searchParams);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.