Skip to content

Instantly share code, notes, and snippets.

@eversonl
Created February 18, 2009 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eversonl/66494 to your computer and use it in GitHub Desktop.
Save eversonl/66494 to your computer and use it in GitHub Desktop.
dev dont use
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<head>
<title>Ubiquity 0-21 Google Search Command</title>
</head>
<body>
<p>This page contains a Ubiquity command for Googling 0-21.co.uk.</p>
<script src="fake-infrastructure.js"></script>
<div id="google-search" style="display: none;">
{for result in results}
<div class="gresult">
<div>
${result.key}: <a href="${result.unescapedUrl}" accesskey="${result.key}">${result.title}</a>
</div>
<xul:description class="gresult-content">${result.content}</xul:description>
<div class="gresult-url">${result.visibleUrl}</div>
</div>
{forelse}
<b>Your search - ${searchTerm} - did not match any documents. </b>
{/for}
<small>Tip: You can go to any result in this preview by using its number as an access key. (Linux and Windows: alt-number, Mac: control-number)</small>
</div>
<script class="commands"><![CDATA[
CmdUtils.makeSearchCommand({
name: "0-21 Search",
url: "http://www.google.com/search?q=site:0-21.co.uk+{QUERY}",
icon: "http://www.0-21.co.uk/favicon.ico",
description: "Searches 0-21 (via Google) for your words.",
preview: function(pblock, directObject) {
var searchTerm = "site:0-21.co.uk "+directObject.text;
// Don't even display any text before fetching search results,
// since the results come back nearly instantaneously. In the
// future, we can display a throbber.
if(searchTerm.length < 1) {
pblock.innerHTML = "Searches 0-21 for your keywords.";
return;
}
var url = "http://ajax.googleapis.com/ajax/services/search/web";
var params = { v: "1.0", q: searchTerm };
CmdUtils.previewGet( pblock, url, params, function(data) {
var numToDisplay = 3;
var results = data.responseData.results.splice( 0, numToDisplay );
//for access keys
for(var i=0;i<results.length;i++){
var result = results[i];
result.key = i+1;
}
pblock.innerHTML = CmdUtils.renderTemplate( jQuery("#google-search", feed.dom).html(),
{results:results, searchTerm:searchTerm}
);
}, "json");
}
});
]]></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment