Skip to content

Instantly share code, notes, and snippets.

@eversonl
Created February 12, 2009 18:50
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/62810 to your computer and use it in GitHub Desktop.
Save eversonl/62810 to your computer and use it in GitHub Desktop.
search 0-21 with google
<?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's archives.</p>
<script src="fake-infrastructure.js"></script>
<style>
div[id] {display: none}
script {display: block; white-space: pre; font-family: monospace}
</style>
<div id="google-search">
{if results.length}
{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>
{/for}
<small>${tipsMessage}</small>
{else}
${noResultsMessage}
{/if}
</div>
<script class="commands"><![CDATA[
CmdUtils.makeSearchCommand({
names: ["0-21"],
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.",
help: "You can use the keyboard shortcut ctrl + alt + number to open one " +
"of the Google results shown in the preview.",
preview: function google_preview(pblock, {object}) {
var searchTerm = object.text;
var searchTerm = "site:0-21.co.uk "+object.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) return void this.previewDefault(pblock);
var url = "http://ajax.googleapis.com/ajax/services/search/web";
var params = {v: "1.0", q: searchTerm};
CmdUtils.previewGet(pblock, url, params, function google_get(data) {
var {results} = data.responseData;
results.forEach(function (r, i) { r.key = i + 1 });
var noResultsMessage = _(
"Your search - ${searchTerm} - did not match any documents.",
{searchTerm: object.html.bold()});
var tipsMessage = _(
"Tip: You can go to any result in this preview by pressing " +
"control, alt, and the result number at the same time.");
pblock.innerHTML = CmdUtils.renderTemplate(
feed.dom.getElementById("google-search").innerHTML,
{ results: results,
noResultsMessage: noResultsMessage,
tipsMessage: tipsMessage });
}, "json");
}
});
]]></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment