PDA

View Full Version : Ext-API Docs with Ubiquity



jonathan.soeder
3 Sep 2008, 12:52 PM
UPDATE: Devnull submitted a much better looking version. Here it is below:



CmdUtils.CreateCommand({
name: "ext2-docs",
icon: "http://extjs.com/favicon.ico",
description: "Searches the Ext 2.x API documentation",
help: "Enter a full or partial name of the Ext class you are looking for",
takes: {
"class": noun_arb_text
},
preview: function(pblock, directObject){
var searchTerm = directObject.text;
var pTemplate = "Searches Ext for <b>${query}</b>";
var pData = {
query: searchTerm
};
pblock.innerHTML = CmdUtils.renderTemplate(pTemplate, pData);
var url = "http://ajax.googleapis.com/ajax/services/search/web";
var params = {
v: "1.0",
q: "site:http://extjs.com/deploy/dev/docs/output/ " + searchTerm
};
jQuery.get(url, params, function(data){
var numToDisplay = 3;
var results = data.responseData.results.splice(0, numToDisplay);
var matches;
for (var i in results) {
if (matches = results[i].unescapedUrl.match(/http:\/\/extjs.com\/deploy\/dev\/docs\/output\/(.*)\.html$/)) {
results[i].unescapedUrl = "http://extjs.com/deploy/dev/docs/?class=" + matches[1];
}
}
pblock.innerHTML = CmdUtils.renderTemplate({
file: "google-search.html"
}, {
results: results
});
}, "json");
},
execute: function(theClass){
var URL = "http://www.google.com/search?q=site:http://extjs.com/deploy/dev/docs/output/ " + theClass.text;
Utils.openUrlInBrowser(URL);
}



Thanks to the poster who posted an ubiquity command to search the Ext Forums for showing me the way. I added the above command so that I can reference the documentation to an Ext class by simply hitting alt-space and then typing "ext-docs Ext.form.FormPanel".

There might be an easier way to pull up something with prettier output. I'm looking into it.

devnull
4 Sep 2008, 12:35 PM
Here's a somewhat prettier version: :)


CmdUtils.CreateCommand({
name: "ext-docs",
icon: "http://extjs.com/favicon.ico",
description: "Searches the Ext API documentation",
help: "Enter a full or partial name of the Ext class you are looking for",
takes: {
"class": noun_arb_text
},
preview: function(pblock, directObject){
var searchTerm = directObject.text;
var pTemplate = "Searches Ext for <b>${query}</b>";
var pData = {
query: searchTerm
};
pblock.innerHTML = CmdUtils.renderTemplate(pTemplate, pData);
var url = "http://ajax.googleapis.com/ajax/services/search/web";
var params = {
v: "1.0",
q: "site:http://extjs.com/deploy/ext/docs/output/ " + searchTerm
};
jQuery.get(url, params, function(data){
var numToDisplay = 3;
var results = data.responseData.results.splice(0, numToDisplay);
pblock.innerHTML = CmdUtils.renderTemplate({
file: "google-search.html"
}, {
results: results
});
}, "json");
},
execute: function(theClass){
var URL = "http://www.google.com/cse?cx=011693920879787039234%3Atlvkzfk9hy4&q=" + theClass.text;
Utils.openUrlInBrowser(URL);
}
});

Online installer at http://www.merkurboys.com/ext/ext-docs.html

jonathan.soeder
5 Sep 2008, 10:42 AM
Real nice! I was just starting to figure out how to get jquery involved... beat me to it. You're a peach of a man.

devnull
5 Sep 2008, 11:02 AM
Oh I "borrowed" someone's Java API search lol.
Don't I feel dumb though, just realized this is searching 1.1 docs, Doh!
Working on an update...

devnull
5 Sep 2008, 11:13 AM
Ahh there we go.


CmdUtils.CreateCommand({
name: "ext2-docs",
icon: "http://extjs.com/favicon.ico",
description: "Searches the Ext 2.x API documentation",
help: "Enter a full or partial name of the Ext class you are looking for",
takes: {
"class": noun_arb_text
},
preview: function(pblock, directObject){
var searchTerm = directObject.text;
var pTemplate = "Searches Ext for <b>${query}</b>";
var pData = {
query: searchTerm
};
pblock.innerHTML = CmdUtils.renderTemplate(pTemplate, pData);
var url = "http://ajax.googleapis.com/ajax/services/search/web";
var params = {
v: "1.0",
q: "site:http://extjs.com/deploy/dev/docs/output/ " + searchTerm
};
jQuery.get(url, params, function(data){
var numToDisplay = 3;
var results = data.responseData.results.splice(0, numToDisplay);
var matches;
for (var i in results) {
if (matches = results[i].unescapedUrl.match(/http:\/\/extjs.com\/deploy\/dev\/docs\/output\/(.*)\.html$/)) {
results[i].unescapedUrl = "http://extjs.com/deploy/dev/docs/?class=" + matches[1];
}
}
pblock.innerHTML = CmdUtils.renderTemplate({
file: "google-search.html"
}, {
results: results
});
}, "json");
},
execute: function(theClass){
var URL = "http://www.google.com/search?q=site:http://extjs.com/deploy/dev/docs/output/ " + theClass.text;
Utils.openUrlInBrowser(URL);
}
});


The online installer will now install both versions. As I understand things, it should auto-update if you are subscribed.

devnull
5 Sep 2008, 11:23 AM
The Ext 2 docs dont quite link right so I will keep working on that though. Should just be a matter of some regex work though :)
Ok, updated the code above, it now links to the API docs application correctly.